mirror of https://github.com/OCA/web.git
[UPD] web_m2x_options_manager: Add option to prevent Create/Edit wizard to pop up
parent
ffb66eb0f8
commit
c1677bbe84
|
@ -25,6 +25,11 @@ msgstr ""
|
||||||
msgid "Add"
|
msgid "Add"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: web_m2x_options_manager
|
||||||
|
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit_wizard
|
||||||
|
msgid "Create & Edit Wizard"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: web_m2x_options_manager
|
#. module: web_m2x_options_manager
|
||||||
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
|
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
|
||||||
msgid "Create & Edit Option"
|
msgid "Create & Edit Option"
|
||||||
|
@ -50,6 +55,13 @@ msgstr ""
|
||||||
msgid "Created on"
|
msgid "Created on"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: web_m2x_options_manager
|
||||||
|
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit_wizard
|
||||||
|
msgid ""
|
||||||
|
"Defines behaviour for 'Create & Edit' Wizard\n"
|
||||||
|
"Set to False to prevent 'Create & Edit' Wizard to pop up"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: web_m2x_options_manager
|
#. module: web_m2x_options_manager
|
||||||
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
|
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
|
||||||
msgid ""
|
msgid ""
|
||||||
|
|
|
@ -77,6 +77,13 @@ class M2xCreateEditOption(models.Model):
|
||||||
string="Create & Edit Option",
|
string="Create & Edit Option",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option_create_edit_wizard = fields.Boolean(
|
||||||
|
default=True,
|
||||||
|
help="Defines behaviour for 'Create & Edit' Wizard\n"
|
||||||
|
"Set to False to prevent 'Create & Edit' Wizard to pop up",
|
||||||
|
string="Create & Edit Wizard",
|
||||||
|
)
|
||||||
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
(
|
(
|
||||||
"model_field_uniqueness",
|
"model_field_uniqueness",
|
||||||
|
@ -142,6 +149,9 @@ class M2xCreateEditOption(models.Model):
|
||||||
if mode == "force" or k not in options:
|
if mode == "force" or k not in options:
|
||||||
options[k] = val == "true"
|
options[k] = val == "true"
|
||||||
node.set("options", str(options))
|
node.set("options", str(options))
|
||||||
|
if not self.option_create_edit_wizard:
|
||||||
|
node.set("can_create", "false")
|
||||||
|
node.set("can_write", "false")
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def get(self, model_name, field_name):
|
def get(self, model_name, field_name):
|
||||||
|
|
|
@ -29,6 +29,7 @@ class TestM2xCreateEditOption(SavepointCase):
|
||||||
"model_id": self.res_partner_model.id,
|
"model_id": self.res_partner_model.id,
|
||||||
"option_create": "set_true",
|
"option_create": "set_true",
|
||||||
"option_create_edit": "set_true",
|
"option_create_edit": "set_true",
|
||||||
|
"option_create_edit_wizard": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.categories_opt = self.env["m2x.create.edit.option"].create(
|
self.categories_opt = self.env["m2x.create.edit.option"].create(
|
||||||
|
@ -37,6 +38,7 @@ class TestM2xCreateEditOption(SavepointCase):
|
||||||
"model_id": self.res_partner_model.id,
|
"model_id": self.res_partner_model.id,
|
||||||
"option_create": "set_true",
|
"option_create": "set_true",
|
||||||
"option_create_edit": "set_true",
|
"option_create_edit": "set_true",
|
||||||
|
"option_create_edit_wizard": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.company_opt = self.env["m2x.create.edit.option"].create(
|
self.company_opt = self.env["m2x.create.edit.option"].create(
|
||||||
|
@ -45,6 +47,7 @@ class TestM2xCreateEditOption(SavepointCase):
|
||||||
"model_id": self.res_users_model.id,
|
"model_id": self.res_users_model.id,
|
||||||
"option_create": "force_true",
|
"option_create": "force_true",
|
||||||
"option_create_edit": "set_true",
|
"option_create_edit": "set_true",
|
||||||
|
"option_create_edit_wizard": False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -82,11 +85,25 @@ class TestM2xCreateEditOption(SavepointCase):
|
||||||
safe_eval(title_node.attrib.get("options"), nocopy=True),
|
safe_eval(title_node.attrib.get("options"), nocopy=True),
|
||||||
{"create": True, "create_edit": True},
|
{"create": True, "create_edit": True},
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
(
|
||||||
|
title_node.attrib.get("can_create"),
|
||||||
|
title_node.attrib.get("can_write"),
|
||||||
|
),
|
||||||
|
("true", "true"),
|
||||||
|
)
|
||||||
categ_node = form_doc.xpath("//field[@name='category_id']")[0]
|
categ_node = form_doc.xpath("//field[@name='category_id']")[0]
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
safe_eval(categ_node.attrib.get("options"), nocopy=True),
|
safe_eval(categ_node.attrib.get("options"), nocopy=True),
|
||||||
{"create": False, "create_edit": True},
|
{"create": False, "create_edit": True},
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
(
|
||||||
|
categ_node.attrib.get("can_create"),
|
||||||
|
categ_node.attrib.get("can_write"),
|
||||||
|
),
|
||||||
|
("true", "true"),
|
||||||
|
)
|
||||||
|
|
||||||
# Check fields on res.users tree view (contained in ``user_ids`` field)
|
# Check fields on res.users tree view (contained in ``user_ids`` field)
|
||||||
tree_arch = res["fields"]["user_ids"]["views"]["tree"]["arch"]
|
tree_arch = res["fields"]["user_ids"]["views"]["tree"]["arch"]
|
||||||
|
@ -96,6 +113,13 @@ class TestM2xCreateEditOption(SavepointCase):
|
||||||
safe_eval(company_node.attrib.get("options"), nocopy=True),
|
safe_eval(company_node.attrib.get("options"), nocopy=True),
|
||||||
{"create": True, "create_edit": True},
|
{"create": True, "create_edit": True},
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
(
|
||||||
|
company_node.attrib.get("can_create"),
|
||||||
|
company_node.attrib.get("can_write"),
|
||||||
|
),
|
||||||
|
("false", "false"),
|
||||||
|
)
|
||||||
|
|
||||||
# Update options, check that node has been updated too
|
# Update options, check that node has been updated too
|
||||||
self.title_opt.option_create_edit = "force_false"
|
self.title_opt.option_create_edit = "force_false"
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
/>
|
/>
|
||||||
<field name="option_create" />
|
<field name="option_create" />
|
||||||
<field name="option_create_edit" />
|
<field name="option_create_edit" />
|
||||||
|
<field name="option_create_edit_wizard" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
|
|
Loading…
Reference in New Issue