[MIG] web_m2x_options_manager: Migration to 18.0

pull/2975/head
chaule97 2024-10-28 10:31:13 +07:00
parent 5f257c3ae4
commit 55db77be66
7 changed files with 26 additions and 17 deletions

View File

@ -75,6 +75,12 @@ Contributors
- Duong (Tran Quoc) <duongtq@trobz.com>
- Chau Le <chaulb@trobz.com>
Other credits
-------------
The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp
Maintainers
-----------

View File

@ -6,7 +6,7 @@
"summary": 'Adds an interface to manage the "Create" and'
' "Create and Edit" options for specific models and'
" fields.",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Web",

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="res_partner_demo_form_view" model="ir.ui.view">
<field name="name">res.partner.demo.form.view</field>
<field name="model">res.partner</field>
@ -15,15 +14,14 @@
<field name="category_id" options="{'create': False}" />
<!-- One2many -->
<field name="user_ids">
<tree>
<!-- Many2one within tree -->
<list>
<!-- Many2one within list -->
<field name="company_id" options="{'create': False}" />
</tree>
</list>
</field>
</group>
</sheet>
</form>
</field>
</record>
</odoo>

View File

@ -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 api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools.cache import ormcache
from odoo.tools.safe_eval import safe_eval
@ -123,7 +123,7 @@ class M2xCreateEditOption(models.Model):
def _check_field_in_model(self):
for opt in self:
if opt.field_id.model_id != opt.model_id:
msg = _(
msg = self.env._(
"'%(field_name)s' is not a valid field for model '%(model_name)s'!",
field_name=opt.field_name,
model_name=opt.model_name,
@ -134,7 +134,7 @@ class M2xCreateEditOption(models.Model):
def _check_field_type(self):
ttypes = ("many2many", "many2one")
if any(o.field_id.ttype not in ttypes for o in self):
msg = _("Only Many2many and Many2one fields can be chosen!")
msg = self.env._("Only Many2many and Many2one fields can be chosen!")
raise ValidationError(msg)
def _apply_options(self, node):
@ -145,14 +145,14 @@ class M2xCreateEditOption(models.Model):
options = safe_eval(options, dict(self.env.context or [])) or {}
for k in ("create", "create_edit"):
opt = self["option_%s" % k]
opt = self[f"option_{k}"]
if opt == "none":
continue
mode, val = opt.split("_")
if k not in options:
options[k] = val == "true"
if mode == "force":
options["no_%s" % k] = val == "false"
options[f"no_{k}"] = val == "false"
if not self.option_create_edit_wizard:
options["no_quick_create"] = True
node.set("options", str(options))

View File

@ -0,0 +1 @@
The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp

View File

@ -380,7 +380,8 @@ Many2one and Many2many fields directly from the ir.model form view.</p>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-6">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
</ul>
</li>
</ul>
@ -420,8 +421,13 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Chau Le &lt;<a class="reference external" href="mailto:chaulb&#64;trobz.com">chaulb&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
<p>The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_model_form_inherit" model="ir.ui.view">
<field name="name">view.model.form.inherit</field>
<field name="model">ir.model</field>
@ -17,7 +16,7 @@
nolabel="1"
context="{'default_model_name': model}"
>
<tree editable="bottom">
<list editable="bottom">
<field name="model_name" column_invisible="1" />
<field
name="field_id"
@ -28,11 +27,10 @@
<field name="option_create" />
<field name="option_create_edit" />
<field name="option_create_edit_wizard" />
</tree>
</list>
</field>
</page>
</xpath>
</field>
</record>
</odoo>