Bugs are tracked on GitHub Issues.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+feedback.
+
Do not contact contributors directly about support or help with technical issues.
OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
This module is part of the OCA/web project on GitHub.
+
+
From 7a7030cf20bb443dde10d33afbf13c5809f8aa09 Mon Sep 17 00:00:00 2001
From: Maksym Yankin
Date: Mon, 18 Oct 2021 13:12:56 +0300
Subject: [PATCH 04/15] [UPD] web_m2x_options_manager: Add option to prevent
Create/Edit wizard to pop up
---
.../i18n/web_m2x_options_manager.pot | 12 ++++++++++
.../models/m2x_create_edit_option.py | 10 ++++++++
.../tests/test_m2x_create_edit_option.py | 24 +++++++++++++++++++
web_m2x_options_manager/views/ir_model.xml | 1 +
4 files changed, 47 insertions(+)
diff --git a/web_m2x_options_manager/i18n/web_m2x_options_manager.pot b/web_m2x_options_manager/i18n/web_m2x_options_manager.pot
index 40c6acd7d..3559937a3 100644
--- a/web_m2x_options_manager/i18n/web_m2x_options_manager.pot
+++ b/web_m2x_options_manager/i18n/web_m2x_options_manager.pot
@@ -25,6 +25,11 @@ msgstr ""
msgid "Add"
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
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
msgid "Create & Edit Option"
@@ -50,6 +55,13 @@ msgstr ""
msgid "Created on"
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
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
msgid ""
diff --git a/web_m2x_options_manager/models/m2x_create_edit_option.py b/web_m2x_options_manager/models/m2x_create_edit_option.py
index 07ae01e77..29c4a7b56 100644
--- a/web_m2x_options_manager/models/m2x_create_edit_option.py
+++ b/web_m2x_options_manager/models/m2x_create_edit_option.py
@@ -77,6 +77,13 @@ class M2xCreateEditOption(models.Model):
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 = [
(
"model_field_uniqueness",
@@ -142,6 +149,9 @@ class M2xCreateEditOption(models.Model):
if mode == "force" or k not in options:
options[k] = val == "true"
node.set("options", str(options))
+ if not self.option_create_edit_wizard:
+ node.set("can_create", "false")
+ node.set("can_write", "false")
@api.model
def get(self, model_name, field_name):
diff --git a/web_m2x_options_manager/tests/test_m2x_create_edit_option.py b/web_m2x_options_manager/tests/test_m2x_create_edit_option.py
index de6e1d8c0..27640df5b 100644
--- a/web_m2x_options_manager/tests/test_m2x_create_edit_option.py
+++ b/web_m2x_options_manager/tests/test_m2x_create_edit_option.py
@@ -29,6 +29,7 @@ class TestM2xCreateEditOption(SavepointCase):
"model_id": self.res_partner_model.id,
"option_create": "set_true",
"option_create_edit": "set_true",
+ "option_create_edit_wizard": True,
}
)
self.categories_opt = self.env["m2x.create.edit.option"].create(
@@ -37,6 +38,7 @@ class TestM2xCreateEditOption(SavepointCase):
"model_id": self.res_partner_model.id,
"option_create": "set_true",
"option_create_edit": "set_true",
+ "option_create_edit_wizard": True,
}
)
self.company_opt = self.env["m2x.create.edit.option"].create(
@@ -45,6 +47,7 @@ class TestM2xCreateEditOption(SavepointCase):
"model_id": self.res_users_model.id,
"option_create": "force_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),
{"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]
self.assertEqual(
safe_eval(categ_node.attrib.get("options"), nocopy=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)
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),
{"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
self.title_opt.option_create_edit = "force_false"
diff --git a/web_m2x_options_manager/views/ir_model.xml b/web_m2x_options_manager/views/ir_model.xml
index d05011571..f0e6502d4 100644
--- a/web_m2x_options_manager/views/ir_model.xml
+++ b/web_m2x_options_manager/views/ir_model.xml
@@ -27,6 +27,7 @@
/>
+
From 33b2953b5eae8672384c00201dc3d8860ea40ecf Mon Sep 17 00:00:00 2001
From: oca-travis
Date: Fri, 22 Oct 2021 09:58:15 +0000
Subject: [PATCH 05/15] [UPD] Update web_m2x_options_manager.pot
---
web_m2x_options_manager/i18n/web_m2x_options_manager.pot | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/web_m2x_options_manager/i18n/web_m2x_options_manager.pot b/web_m2x_options_manager/i18n/web_m2x_options_manager.pot
index 3559937a3..1014c9ca5 100644
--- a/web_m2x_options_manager/i18n/web_m2x_options_manager.pot
+++ b/web_m2x_options_manager/i18n/web_m2x_options_manager.pot
@@ -26,13 +26,13 @@ msgid "Add"
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"
+#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
+msgid "Create & Edit Option"
msgstr ""
#. module: web_m2x_options_manager
-#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
-msgid "Create & Edit Option"
+#: 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
From 2bcc7a19996e3fc39db634831e89442978238fb8 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Fri, 22 Oct 2021 10:16:58 +0000
Subject: [PATCH 06/15] web_m2x_options_manager 14.0.1.1.0
---
web_m2x_options_manager/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/web_m2x_options_manager/__manifest__.py b/web_m2x_options_manager/__manifest__.py
index 68d81d280..3a39a7366 100644
--- a/web_m2x_options_manager/__manifest__.py
+++ b/web_m2x_options_manager/__manifest__.py
@@ -6,7 +6,7 @@
"summary": 'Adds an interface to manage the "Create" and'
' "Create and Edit" options for specific models and'
" fields.",
- "version": "14.0.1.0.0",
+ "version": "14.0.1.1.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Web",
From ece722d5d7fa9ae138a9f8328bde9f03fa51123d Mon Sep 17 00:00:00 2001
From: Germana
Date: Mon, 15 Nov 2021 15:36:05 -0400
Subject: [PATCH 07/15] [MIG] web_m2x_options_manager: Migration to 15.0
- Fix postprocess inherit (removed from v15), and use _postprocess_tag_field
for create/edit options: In v14 it worked with inheriting the "postprocess"
method because in each recursive call it passed a section of the view, in the
way that it went through all the child nodes of the root node, and passed through
the fields, and now in v15 the method "_postprocess_view "it just does the while,
and we never go through the nodes.
- Fix pylint errors: xml-deprecated-tree-attributte, attribute-string-redundant,
translation-positional-used
---
web_m2x_options_manager/__manifest__.py | 2 +-
web_m2x_options_manager/models/ir_ui_view.py | 6 +++---
web_m2x_options_manager/models/m2x_create_edit_option.py | 9 ++++++---
.../tests/test_m2x_create_edit_option.py | 4 ++--
web_m2x_options_manager/views/ir_model.xml | 2 +-
5 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/web_m2x_options_manager/__manifest__.py b/web_m2x_options_manager/__manifest__.py
index 3a39a7366..623712a8b 100644
--- a/web_m2x_options_manager/__manifest__.py
+++ b/web_m2x_options_manager/__manifest__.py
@@ -6,7 +6,7 @@
"summary": 'Adds an interface to manage the "Create" and'
' "Create and Edit" options for specific models and'
" fields.",
- "version": "14.0.1.1.0",
+ "version": "15.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Web",
diff --git a/web_m2x_options_manager/models/ir_ui_view.py b/web_m2x_options_manager/models/ir_ui_view.py
index 172ef6696..66393622d 100644
--- a/web_m2x_options_manager/models/ir_ui_view.py
+++ b/web_m2x_options_manager/models/ir_ui_view.py
@@ -7,10 +7,10 @@ from odoo import models
class IrUiView(models.Model):
_inherit = "ir.ui.view"
- def postprocess(self, node, current_node_path, editable, name_manager):
- res = super().postprocess(node, current_node_path, editable, name_manager)
+ def _postprocess_tag_field(self, node, name_manager, node_info):
+ res = super()._postprocess_tag_field(node, name_manager, node_info)
if node.tag == "field":
- mname = name_manager.Model._name
+ mname = name_manager.model._name
fname = node.attrib["name"]
field = self.env[mname]._fields.get(fname)
if field and field.type in ("many2many", "many2one"):
diff --git a/web_m2x_options_manager/models/m2x_create_edit_option.py b/web_m2x_options_manager/models/m2x_create_edit_option.py
index 29c4a7b56..d3c5bb1ea 100644
--- a/web_m2x_options_manager/models/m2x_create_edit_option.py
+++ b/web_m2x_options_manager/models/m2x_create_edit_option.py
@@ -36,7 +36,6 @@ class M2xCreateEditOption(models.Model):
compute="_compute_model_name",
inverse="_inverse_model_name",
store=True,
- string="Model Name",
)
option_create = fields.Selection(
@@ -125,8 +124,12 @@ class M2xCreateEditOption(models.Model):
def _check_field_in_model(self):
for opt in self:
if opt.field_id.model_id != opt.model_id:
- msg = _("'%s' is not a valid field for model '%s'!")
- raise ValidationError(msg % (opt.field_name, opt.model_name))
+ msg = _(
+ "%(field)s is not a valid field for model %(model)s!",
+ field=opt.field_name,
+ model=opt.model_name,
+ )
+ raise ValidationError(msg)
@api.constrains("field_id")
def _check_field_type(self):
diff --git a/web_m2x_options_manager/tests/test_m2x_create_edit_option.py b/web_m2x_options_manager/tests/test_m2x_create_edit_option.py
index 27640df5b..7f61c9c2b 100644
--- a/web_m2x_options_manager/tests/test_m2x_create_edit_option.py
+++ b/web_m2x_options_manager/tests/test_m2x_create_edit_option.py
@@ -4,11 +4,11 @@
from lxml import etree
from odoo.exceptions import ValidationError
-from odoo.tests.common import SavepointCase
+from odoo.tests.common import TransactionCase
from odoo.tools.safe_eval import safe_eval
-class TestM2xCreateEditOption(SavepointCase):
+class TestM2xCreateEditOption(TransactionCase):
def setUp(self):
super(TestM2xCreateEditOption, self).setUp()
ref = self.env.ref
diff --git a/web_m2x_options_manager/views/ir_model.xml b/web_m2x_options_manager/views/ir_model.xml
index f0e6502d4..e52a1b864 100644
--- a/web_m2x_options_manager/views/ir_model.xml
+++ b/web_m2x_options_manager/views/ir_model.xml
@@ -17,7 +17,7 @@
nolabel="1"
context="{'default_model_name': model}"
>
-
+
Date: Tue, 16 Nov 2021 23:23:42 +0000
Subject: [PATCH 08/15] [UPD] Update web_m2x_options_manager.pot
---
.../i18n/web_m2x_options_manager.pot | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/web_m2x_options_manager/i18n/web_m2x_options_manager.pot b/web_m2x_options_manager/i18n/web_m2x_options_manager.pot
index 1014c9ca5..b7598b32e 100644
--- a/web_m2x_options_manager/i18n/web_m2x_options_manager.pot
+++ b/web_m2x_options_manager/i18n/web_m2x_options_manager.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 14.0\n"
+"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -16,7 +16,7 @@ msgstr ""
#. module: web_m2x_options_manager
#: code:addons/web_m2x_options_manager/models/m2x_create_edit_option.py:0
#, python-format
-msgid "'%s' is not a valid field for model '%s'!"
+msgid "%(field)s is not a valid field for model %(model)s!"
msgstr ""
#. module: web_m2x_options_manager
@@ -81,9 +81,6 @@ msgid ""
msgstr ""
#. module: web_m2x_options_manager
-#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model__display_name
-#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model_fields__display_name
-#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_ui_view__display_name
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__display_name
msgid "Display Name"
msgstr ""
@@ -114,11 +111,6 @@ msgstr ""
msgid "Fields"
msgstr ""
-#. module: web_m2x_options_manager
-#: model_terms:ir.ui.view,arch_db:web_m2x_options_manager.view_model_form_inherit
-msgid "Fields Description"
-msgstr ""
-
#. module: web_m2x_options_manager
#: model_terms:ir.ui.view,arch_db:web_m2x_options_manager.view_model_form_inherit
msgid "Fill"
@@ -137,17 +129,11 @@ msgid "Force Remove"
msgstr ""
#. module: web_m2x_options_manager
-#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model__id
-#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model_fields__id
-#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_ui_view__id
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__id
msgid "ID"
msgstr ""
#. module: web_m2x_options_manager
-#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model____last_update
-#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model_fields____last_update
-#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_ui_view____last_update
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option____last_update
msgid "Last Modified on"
msgstr ""
From 921792f8c17d0e5504b3a26ced81d469b1f52db3 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Tue, 16 Nov 2021 23:25:59 +0000
Subject: [PATCH 09/15] [UPD] README.rst
---
web_m2x_options_manager/README.rst | 10 +++++-----
web_m2x_options_manager/static/description/index.html | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/web_m2x_options_manager/README.rst b/web_m2x_options_manager/README.rst
index 0355c3525..26a7498a5 100644
--- a/web_m2x_options_manager/README.rst
+++ b/web_m2x_options_manager/README.rst
@@ -14,13 +14,13 @@ Web M2X Options Manager
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
- :target: https://github.com/OCA/web/tree/14.0/web_m2x_options_manager
+ :target: https://github.com/OCA/web/tree/15.0/web_m2x_options_manager
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_m2x_options_manager
+ :target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_m2x_options_manager
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/162/14.0
+ :target: https://runbot.odoo-community.org/runbot/162/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -50,7 +50,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -82,6 +82,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-This module is part of the `OCA/web `_ project on GitHub.
+This module is part of the `OCA/web `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/web_m2x_options_manager/static/description/index.html b/web_m2x_options_manager/static/description/index.html
index 66f76efac..5d15168ea 100644
--- a/web_m2x_options_manager/static/description/index.html
+++ b/web_m2x_options_manager/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
Allows managing the “Create…” and “Create and Edit…” options for Many2one
and Many2many fields directly from the ir.model form view.
Table of contents
@@ -396,7 +396,7 @@ Button “Empty” will remove every option.
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -423,7 +423,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-
This module is part of the OCA/web project on GitHub.
+
This module is part of the OCA/web project on GitHub.