diff --git a/setup/web_m2x_options_manager/odoo/addons/web_m2x_options_manager b/setup/web_m2x_options_manager/odoo/addons/web_m2x_options_manager new file mode 120000 index 000000000000..53b3da28cacb --- /dev/null +++ b/setup/web_m2x_options_manager/odoo/addons/web_m2x_options_manager @@ -0,0 +1 @@ +../../../../web_m2x_options_manager \ No newline at end of file diff --git a/setup/web_m2x_options_manager/setup.py b/setup/web_m2x_options_manager/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/web_m2x_options_manager/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_m2x_options_manager/README.rst b/web_m2x_options_manager/README.rst index 26a7498a5e63..803940c13a0a 100644 --- a/web_m2x_options_manager/README.rst +++ b/web_m2x_options_manager/README.rst @@ -2,10 +2,13 @@ Web M2X Options Manager ======================= -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e2c7c70fbcb74be8ffaed3747c322112463936bb6fbb5a48c42d659a5f8ddce7 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -14,16 +17,16 @@ 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/15.0/web_m2x_options_manager + :target: https://github.com/OCA/web/tree/16.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-15-0/web-15-0-web_m2x_options_manager + :target: https://translation.odoo-community.org/projects/web-16-0/web-16-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/15.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| Allows managing the "Create..." and "Create and Edit..." options for `Many2one` and `Many2many` fields directly from the `ir.model` form view. @@ -49,8 +52,8 @@ 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 `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -68,6 +71,7 @@ Contributors * `Camptocamp `__: * Silvio Gregorini +* Duong (Tran Quoc) Maintainers ~~~~~~~~~~~ @@ -82,6 +86,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/__manifest__.py b/web_m2x_options_manager/__manifest__.py index 623712a8b572..8c3aae5d430a 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": "15.0.1.0.0", + "version": "16.0.1.0.0", "author": "Camptocamp, Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Web", 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 b7598b32ede5..1014c9ca57cd 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 15.0\n" +"Project-Id-Version: Odoo Server 14.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 "%(field)s is not a valid field for model %(model)s!" +msgid "'%s' is not a valid field for model '%s'!" msgstr "" #. module: web_m2x_options_manager @@ -81,6 +81,9 @@ 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 "" @@ -111,6 +114,11 @@ 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" @@ -129,11 +137,17 @@ 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 "" diff --git a/web_m2x_options_manager/models/ir_model.py b/web_m2x_options_manager/models/ir_model.py index e514465720d3..dbf1c02778db 100644 --- a/web_m2x_options_manager/models/ir_model.py +++ b/web_m2x_options_manager/models/ir_model.py @@ -1,7 +1,7 @@ # Copyright 2021 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models +from odoo import fields, models class IrModel(models.Model): @@ -36,17 +36,4 @@ def _fill_m2x_create_edit_option(self): class IrModelFields(models.Model): _inherit = "ir.model.fields" - - @api.model - def name_search(self, name="", args=None, operator="ilike", limit=100): - res = super().name_search(name, args, operator, limit) - if not (name and self.env.context.get("search_by_technical_name")): - return res - domain = list(args or []) + [("name", operator, name)] - new_fids = self.search(domain, limit=limit).ids - for fid in [x[0] for x in res]: - if fid not in new_fids: - new_fids.append(fid) - if limit and limit > 0: - new_fids = new_fids[:limit] - return self.browse(new_fids).sudo().name_get() + _rec_names_search = ["name", "field_description"] diff --git a/web_m2x_options_manager/models/ir_ui_view.py b/web_m2x_options_manager/models/ir_ui_view.py index 66393622d334..23f26b4bf0cc 100644 --- a/web_m2x_options_manager/models/ir_ui_view.py +++ b/web_m2x_options_manager/models/ir_ui_view.py @@ -11,8 +11,7 @@ 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 - fname = node.attrib["name"] - field = self.env[mname]._fields.get(fname) + field = name_manager.model._fields.get(node.get("name")) if field and field.type in ("many2many", "many2one"): rec = self.env["m2x.create.edit.option"].get(mname, field.name) if rec: 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 d3c5bb1ea0fa..2712b26274da 100644 --- a/web_m2x_options_manager/models/m2x_create_edit_option.py +++ b/web_m2x_options_manager/models/m2x_create_edit_option.py @@ -22,7 +22,6 @@ class M2xCreateEditOption(models.Model): field_name = fields.Char( related="field_id.name", store=True, - string="Field Name", ) model_id = fields.Many2one( @@ -125,9 +124,9 @@ def _check_field_in_model(self): for opt in self: if opt.field_id.model_id != opt.model_id: msg = _( - "%(field)s is not a valid field for model %(model)s!", - field=opt.field_name, - model=opt.model_name, + "'%(field_name)s' is not a valid field for model '%(model_name)s'!", + field_name=opt.field_name, + model_name=opt.model_name, ) raise ValidationError(msg) @@ -144,17 +143,19 @@ def _apply_options(self, node): options = node.attrib.get("options") or {} if isinstance(options, str): options = safe_eval(options, dict(self.env.context or [])) or {} + for k in ("create", "create_edit"): opt = self["option_%s" % k] if opt == "none": continue mode, val = opt.split("_") - if mode == "force" or k not in options: + if k not in options: options[k] = val == "true" - node.set("options", str(options)) + if mode == "force": + options["no_%s" % k] = val == "false" if not self.option_create_edit_wizard: - node.set("can_create", "false") - node.set("can_write", "false") + options["no_quick_create"] = True + node.set("options", str(options)) @api.model def get(self, model_name, field_name): diff --git a/web_m2x_options_manager/readme/CONTRIBUTORS.rst b/web_m2x_options_manager/readme/CONTRIBUTORS.rst index 02ad49af4196..491d1f18c088 100644 --- a/web_m2x_options_manager/readme/CONTRIBUTORS.rst +++ b/web_m2x_options_manager/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * `Camptocamp `__: * Silvio Gregorini +* Duong (Tran Quoc) diff --git a/web_m2x_options_manager/static/description/index.html b/web_m2x_options_manager/static/description/index.html index 5d15168ea21a..f7afc49def3b 100644 --- a/web_m2x_options_manager/static/description/index.html +++ b/web_m2x_options_manager/static/description/index.html @@ -3,7 +3,7 @@ - + Web M2X Options Manager