Skip to content

Commit

Permalink
[FIX] cetmix_tower_server: resolve conflict
Browse files Browse the repository at this point in the history
Task: 4055
  • Loading branch information
tendil committed Jan 17, 2025
1 parent a943e9e commit 3822a13
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 0 additions & 1 deletion cetmix_tower_server/models/cx_tower_access_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ def _default_access_level(self):
Char: `access_level` field selection value
"""
return "2"

29 changes: 29 additions & 0 deletions cetmix_tower_server/models/cx_tower_variable_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,35 @@ def _inverse_value_char(self):
)
)

@api.constrains("access_level", "variable_id")
def _check_access_level_consistency(self):
"""
Ensure that the access level of the variable value is not lower than
the access level of the associated variable.
"""
for rec in self:
if rec.variable_id and rec.access_level < rec.variable_id.access_level:
raise ValidationError(
_(
"The access level for Variable Value '%(value)s' cannot be"
"lower than the access level of its Variable '%(variable)s'.\n"
"Variable Access Level: %(var_level)s\n"
"Variable Value Access Level: %(val_level)s",
value=rec.value_char or "Undefined",
variable=rec.variable_id.name,
var_level=dict(
rec.fields_get(["access_level"])["access_level"][
"selection"
]
)[rec.variable_id.access_level],
val_level=dict(
rec.fields_get(["access_level"])["access_level"][
"selection"
]
)[rec.access_level],
)
)

def _used_in_models(self):
"""Returns information about models which use this mixin.
Expand Down
1 change: 0 additions & 1 deletion cetmix_tower_server/views/cx_tower_variable_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
</field>
</record>


<record id="cx_tower_variable_view_tree" model="ir.ui.view">
<field name="name">cx.tower.variable.view.tree</field>
<field name="model">cx.tower.variable</field>
Expand Down

0 comments on commit 3822a13

Please sign in to comment.