Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web_m2x_options_manager/demo/res_partner_demo_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
<!-- Many2one w/ options -->
<field
name="parent_id"
options="{'create': False, 'create_edit': False}"
options="{'create': false, 'create_edit': false}"
/>
<!-- Many2many w/ options -->
<field
name="category_id"
options="{'create': False, 'create_edit': False}"
options="{'create': false, 'create_edit': false}"
/>
</group>
</sheet>
Expand Down
2 changes: 1 addition & 1 deletion web_m2x_options_manager/models/m2x_create_edit_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _get_node_options_eval_context(self):
"""
self.ensure_one()
eval_ctx = dict(self.env.context or [])
eval_ctx.update({"context": dict(eval_ctx)})
eval_ctx.update({"context": dict(eval_ctx), "true": True, "false": False})
return eval_ctx

def _read_own_options(self):
Expand Down
16 changes: 11 additions & 5 deletions web_m2x_options_manager/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ def _get_field(cls, model_name, field_name):
def _get_model(cls, model_name):
return cls.env["ir.model"]._get(model_name)

@staticmethod
def _eval_node_options(node):
opt = node.attrib.get("options")
if opt:
return safe_eval(opt, nocopy=True)
@classmethod
def _eval_node_options(cls, node):
opt = node.attrib.get("options") or {}
if isinstance(opt, str):
return safe_eval(opt, cls._get_node_options_eval_context(), nocopy=True)
return {}

@classmethod
def _get_node_options_eval_context(cls):
eval_ctx = dict(cls.env.context or [])
eval_ctx.update({"context": dict(eval_ctx), "true": True, "false": False})
return eval_ctx

@classmethod
def _get_test_view(cls):
return cls.env.ref("web_m2x_options_manager.res_partner_demo_form_view")
Expand Down