mirror of https://github.com/OCA/web.git
[MIG] web_m2x_options_manager : Migration to 16.0.
parent
a14f9a6c07
commit
3e18b4ebf9
|
@ -0,0 +1 @@
|
|||
../../../../web_m2x_options_manager
|
|
@ -0,0 +1,6 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
|
@ -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 <https://github.com/OCA/web/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 <https://github.com/OCA/web/issues/new?body=module:%20web_m2x_options_manager%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_m2x_options_manager%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
|
@ -68,6 +71,7 @@ Contributors
|
|||
* `Camptocamp <https://www.camptocamp.com>`__:
|
||||
|
||||
* Silvio Gregorini
|
||||
* Duong (Tran Quoc) <duongtq@trobz.com>
|
||||
|
||||
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 <https://github.com/OCA/web/tree/15.0/web_m2x_options_manager>`_ project on GitHub.
|
||||
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_m2x_options_manager>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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 ""
|
||||
|
|
|
@ -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 @@ class IrModel(models.Model):
|
|||
|
||||
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"]
|
||||
|
|
|
@ -11,8 +11,7 @@ class IrUiView(models.Model):
|
|||
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:
|
||||
|
|
|
@ -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 @@ class M2xCreateEditOption(models.Model):
|
|||
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 @@ class M2xCreateEditOption(models.Model):
|
|||
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):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
* `Camptocamp <https://www.camptocamp.com>`__:
|
||||
|
||||
* Silvio Gregorini
|
||||
* Duong (Tran Quoc) <duongtq@trobz.com>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
|
||||
<title>Web M2X Options Manager</title>
|
||||
<style type="text/css">
|
||||
|
||||
|
@ -366,8 +366,10 @@ ul.auto-toc {
|
|||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:e2c7c70fbcb74be8ffaed3747c322112463936bb6fbb5a48c42d659a5f8ddce7
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_m2x_options_manager"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_m2x_options_manager"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_m2x_options_manager"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_m2x_options_manager"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>Allows managing the “Create…” and “Create and Edit…” options for <cite>Many2one</cite>
|
||||
and <cite>Many2many</cite> fields directly from the <cite>ir.model</cite> form view.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
|
@ -395,8 +397,8 @@ Button “Empty” will remove every option.</p>
|
|||
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
|
||||
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
|
||||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_m2x_options_manager%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_m2x_options_manager%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
|
@ -414,6 +416,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||
<li>Silvio Gregorini</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Duong (Tran Quoc) <<a class="reference external" href="mailto:duongtq@trobz.com">duongtq@trobz.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
|
@ -423,7 +426,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||
<p>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.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_m2x_options_manager">OCA/web</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_m2x_options_manager">OCA/web</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -75,7 +75,7 @@ class TestM2xCreateEditOption(TransactionCase):
|
|||
)
|
||||
|
||||
def test_apply_options(self):
|
||||
res = self.env["res.partner"].fields_view_get(self.view.id)
|
||||
res = self.env["res.partner"].get_view(self.view.id)
|
||||
|
||||
# Check fields on res.partner form view
|
||||
form_arch = res["arch"]
|
||||
|
@ -97,37 +97,24 @@ class TestM2xCreateEditOption(TransactionCase):
|
|||
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"]
|
||||
tree_doc = etree.XML(tree_arch)
|
||||
company_node = tree_doc.xpath("//field[@name='company_id']")[0]
|
||||
company_node = form_doc.xpath("//field[@name='company_id']")[0]
|
||||
self.assertEqual(
|
||||
safe_eval(company_node.attrib.get("options"), nocopy=True),
|
||||
{"create": True, "create_edit": True},
|
||||
{
|
||||
"create": False,
|
||||
"no_create": False,
|
||||
"create_edit": True,
|
||||
"no_quick_create": 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"
|
||||
res = self.env["res.partner"].fields_view_get(self.view.id)
|
||||
res = self.env["res.partner"].get_view(self.view.id)
|
||||
form_arch = res["arch"]
|
||||
form_doc = etree.XML(form_arch)
|
||||
title_node = form_doc.xpath("//field[@name='title']")[0]
|
||||
self.assertEqual(
|
||||
safe_eval(title_node.attrib.get("options"), nocopy=True),
|
||||
{"create": True, "create_edit": False},
|
||||
{"create": True, "create_edit": False, "no_create_edit": True},
|
||||
)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<field name="model_name" invisible="1" />
|
||||
<field
|
||||
name="field_id"
|
||||
context="{'search_by_technical_name': True, 'display_technical_name': True}"
|
||||
context="{'display_technical_name': True}"
|
||||
domain="[('ttype', 'in', ('many2many', 'many2one')), ('model_id.model', '=', model_name)]"
|
||||
options="{'create': False, 'create_edit': False}"
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue