Skip to content

Commit 54eef80

Browse files
committed
[IMP] attribute_set: remove deprecated code
1 parent 64e9353 commit 54eef80

File tree

3 files changed

+12
-45
lines changed

3 files changed

+12
-45
lines changed

attribute_set/models/attribute_attribute.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from lxml import etree
1212

13-
from odoo import _, api, fields, models
13+
from odoo import api, fields, models
1414
from odoo.exceptions import ValidationError
1515

1616
from ..utils.orm import setup_modifiers
@@ -46,7 +46,6 @@ class AttributeAttribute(models.Model):
4646
string="Attribute Nature",
4747
required=True,
4848
default="custom",
49-
store=True,
5049
)
5150

5251
attribute_type = fields.Selection(
@@ -271,7 +270,7 @@ def _onchange_domain(self):
271270
ast.literal_eval(self.domain)
272271
except ValueError:
273272
raise ValidationError(
274-
_(
273+
self.env._(
275274
"`%(domain)s` is an invalid Domain name.\n"
276275
"Specify a Python expression defining a list of triplets.\n"
277276
"For example : `[('color', '=', 'red')]`",
@@ -295,7 +294,7 @@ def button_add_options(self):
295294
# context since 17.0 will be dropped in views
296295
# unless we suffix it's key with _view_ref
297296
"context": {"attribute_id_view_ref": self.id},
298-
"name": _("Options Wizard"),
297+
"name": self.env._("Options Wizard"),
299298
"view_mode": "form",
300299
"res_model": "attribute.option.wizard",
301300
"type": "ir.actions.act_window",
@@ -423,7 +422,7 @@ def write(self, vals):
423422
]
424423
):
425424
raise ValidationError(
426-
_(
425+
self.env._(
427426
"Can't change the type of an attribute. "
428427
"Please create a new one."
429428
)
@@ -441,7 +440,7 @@ def write(self, vals):
441440
]
442441
):
443442
raise ValidationError(
444-
_(
443+
self.env._(
445444
"""Can't change the attribute's Relational Model in order to
446445
avoid conflicts with existing objects using this attribute.
447446
Please create a new one."""
@@ -453,7 +452,7 @@ def write(self, vals):
453452
[("serialized", "!=", vals["serialized"]), ("id", "in", self.ids)]
454453
):
455454
raise ValidationError(
456-
_(
455+
self.env._(
457456
"""It is not allowed to change the boolean 'Serialized'.
458457
A serialized field can not be change to non-serialized \
459458
and vice versa."""

attribute_set/utils/orm.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,14 @@
66

77

88
def transfer_field_to_modifiers(field, modifiers):
9-
default_values = {}
10-
state_exceptions = {}
11-
for attr in ("invisible", "readonly", "required"):
12-
state_exceptions[attr] = []
13-
default_values[attr] = bool(field.get(attr))
14-
for state, modifs in field.get("states", {}).items():
15-
for modif in modifs:
16-
if default_values[modif[0]] != modif[1]:
17-
state_exceptions[modif[0]].append(state)
18-
19-
for attr, default_value in default_values.items():
20-
if state_exceptions[attr]:
21-
modifiers[attr] = [
22-
("state", "not in" if default_value else "in", state_exceptions[attr])
23-
]
24-
else:
25-
modifiers[attr] = default_value
9+
"""This module is not used all over the project, but may has a value"""
10+
pass
2611

2712

2813
# Don't deal with groups, it is done by check_group().
2914
# Need the context to evaluate the invisible attribute on tree views.
3015
# For non-tree views, the context shouldn't be given.
3116
def transfer_node_to_modifiers(node, modifiers, context=None, in_tree_view=False):
32-
if node.get("attrs"):
33-
modifiers.update(safe_eval(node.get("attrs")))
34-
35-
if node.get("states"):
36-
if "invisible" in modifiers and isinstance(modifiers["invisible"], list):
37-
# TODO combine with AND or OR, use implicit AND for now.
38-
modifiers["invisible"].append(
39-
("state", "not in", node.get("states").split(","))
40-
)
41-
else:
42-
modifiers["invisible"] = [
43-
("state", "not in", node.get("states").split(","))
44-
]
45-
4617
for a in ("invisible", "readonly", "required"):
4718
if node.get(a):
4819
try:
@@ -72,7 +43,6 @@ def simplify_modifiers(modifiers):
7243

7344
def transfer_modifiers_to_node(modifiers, node):
7445
if modifiers:
75-
simplify_modifiers(modifiers)
7646
node.set("modifiers", json.dumps(modifiers))
7747

7848

attribute_set/views/attribute_attribute_view.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
nolabel="1"
1515
required="1"
1616
/>
17+
<!-- The field created by this Attribute will be related to the model given
18+
by 'default_model_id' through the menu's context that led to this view -->
19+
<field name="model_id" invisible="context.get('default_model_id')" />
1720
<separator invisible="nature == 'native'" />
1821
<group>
1922
<group invisible="nature == 'native'">
20-
<group invisible="context.get('default_model_id')">
21-
<!-- The field created by this Attribute will be related to the model given
22-
by 'default_model_id' through the menu's context that led to this view -->
23-
<field name="model_id" />
24-
</group>
25-
<group invisible="nature == 'native'">
23+
<group>
2624
<field
2725
name="field_description"
2826
required="nature == 'custom'"

0 commit comments

Comments
 (0)