3
0
Fork 0

[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
16.0
Germana 2021-11-15 15:36:05 -04:00 committed by Quoc Duong
parent 4625b5b976
commit 4d3ecc1f18
5 changed files with 13 additions and 10 deletions

View File

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

View File

@ -7,10 +7,10 @@ from odoo import models
class IrUiView(models.Model): class IrUiView(models.Model):
_inherit = "ir.ui.view" _inherit = "ir.ui.view"
def postprocess(self, node, current_node_path, editable, name_manager): def _postprocess_tag_field(self, node, name_manager, node_info):
res = super().postprocess(node, current_node_path, editable, name_manager) res = super()._postprocess_tag_field(node, name_manager, node_info)
if node.tag == "field": if node.tag == "field":
mname = name_manager.Model._name mname = name_manager.model._name
fname = node.attrib["name"] fname = node.attrib["name"]
field = self.env[mname]._fields.get(fname) field = self.env[mname]._fields.get(fname)
if field and field.type in ("many2many", "many2one"): if field and field.type in ("many2many", "many2one"):

View File

@ -36,7 +36,6 @@ class M2xCreateEditOption(models.Model):
compute="_compute_model_name", compute="_compute_model_name",
inverse="_inverse_model_name", inverse="_inverse_model_name",
store=True, store=True,
string="Model Name",
) )
option_create = fields.Selection( option_create = fields.Selection(
@ -125,8 +124,12 @@ class M2xCreateEditOption(models.Model):
def _check_field_in_model(self): def _check_field_in_model(self):
for opt in self: for opt in self:
if opt.field_id.model_id != opt.model_id: if opt.field_id.model_id != opt.model_id:
msg = _("'%s' is not a valid field for model '%s'!") msg = _(
raise ValidationError(msg % (opt.field_name, opt.model_name)) "%(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") @api.constrains("field_id")
def _check_field_type(self): def _check_field_type(self):

View File

@ -4,11 +4,11 @@
from lxml import etree from lxml import etree
from odoo.exceptions import ValidationError 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 from odoo.tools.safe_eval import safe_eval
class TestM2xCreateEditOption(SavepointCase): class TestM2xCreateEditOption(TransactionCase):
def setUp(self): def setUp(self):
super(TestM2xCreateEditOption, self).setUp() super(TestM2xCreateEditOption, self).setUp()
ref = self.env.ref ref = self.env.ref

View File

@ -17,7 +17,7 @@
nolabel="1" nolabel="1"
context="{'default_model_name': model}" context="{'default_model_name': model}"
> >
<tree string="Fields Description" editable="bottom"> <tree editable="bottom">
<field name="model_name" invisible="1" /> <field name="model_name" invisible="1" />
<field <field
name="field_id" name="field_id"