Skip to content

Commit 0811ee0

Browse files
committed
[FIX] web_m2x_options_manager: fix m2o dialog
Current implementation behind field ``option_create_edit_wizard`` was inconsistent with other options' values: if ``option_create_edit_wizard`` was unflagged, users could not access the "Create" and "Create & Edit" options even if ``option_create[_edit]`` were set to '[set|force]_true'. This commit fixes this issue.
1 parent 68b9db7 commit 0811ee0

File tree

2 files changed

+5
-28
lines changed

2 files changed

+5
-28
lines changed

web_m2x_options_manager/models/m2x_create_edit_option.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,8 @@ def _apply_options(self, node):
148148
mode, val = opt.split("_")
149149
if mode == "force" or k not in options:
150150
options[k] = val == "true"
151+
options["m2o_dialog"] = self.option_create_edit_wizard
151152
node.set("options", str(options))
152-
if not self.option_create_edit_wizard:
153-
node.set("can_create", "false")
154-
node.set("can_write", "true")
155153

156154
@api.model
157155
def get(self, model_name, field_name):

web_m2x_options_manager/tests/test_m2x_create_edit_option.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,12 @@ def test_apply_options(self):
8383
title_node = form_doc.xpath("//field[@name='title']")[0]
8484
self.assertEqual(
8585
safe_eval(title_node.attrib.get("options"), nocopy=True),
86-
{"create": True, "create_edit": True},
87-
)
88-
self.assertEqual(
89-
(
90-
title_node.attrib.get("can_create"),
91-
title_node.attrib.get("can_write"),
92-
),
93-
("true", "true"),
86+
{"create": True, "create_edit": True, "m2o_dialog": True},
9487
)
9588
categ_node = form_doc.xpath("//field[@name='category_id']")[0]
9689
self.assertEqual(
9790
safe_eval(categ_node.attrib.get("options"), nocopy=True),
98-
{"create": False, "create_edit": True},
99-
)
100-
self.assertEqual(
101-
(
102-
categ_node.attrib.get("can_create"),
103-
categ_node.attrib.get("can_write"),
104-
),
105-
("true", "true"),
91+
{"create": False, "create_edit": True, "m2o_dialog": True},
10692
)
10793

10894
# Check fields on res.users tree view (contained in ``user_ids`` field)
@@ -111,14 +97,7 @@ def test_apply_options(self):
11197
company_node = tree_doc.xpath("//field[@name='company_id']")[0]
11298
self.assertEqual(
11399
safe_eval(company_node.attrib.get("options"), nocopy=True),
114-
{"create": True, "create_edit": True},
115-
)
116-
self.assertEqual(
117-
(
118-
company_node.attrib.get("can_create"),
119-
company_node.attrib.get("can_write"),
120-
),
121-
("false", "true"),
100+
{"create": True, "create_edit": True, "m2o_dialog": False},
122101
)
123102

124103
# Update options, check that node has been updated too
@@ -129,5 +108,5 @@ def test_apply_options(self):
129108
title_node = form_doc.xpath("//field[@name='title']")[0]
130109
self.assertEqual(
131110
safe_eval(title_node.attrib.get("options"), nocopy=True),
132-
{"create": True, "create_edit": False},
111+
{"create": True, "create_edit": False, "m2o_dialog": True},
133112
)

0 commit comments

Comments
 (0)