Skip to content

[FIX] base: missing xmlid for mixin fields - #52275

Closed
Julien00859 wants to merge 1 commit into
odoo:masterfrom
odoo-dev:master-2235368-field_without_xmlid-juc
Closed

[FIX] base: missing xmlid for mixin fields#52275
Julien00859 wants to merge 1 commit into
odoo:masterfrom
odoo-dev:master-2235368-field_without_xmlid-juc

Conversation

@Julien00859

Copy link
Copy Markdown
Member

We want to create a XMLID for every first exhibition of a field in a
model. That is, we just want one XMLID by field by model and not one
XMLID by field by class. Previous implementation was determining the
"first field exhibition" by making sure the field was created and used
as part of the same module.

This assumption is invalid when we consider mixins. A mixin is an
abstract model that define fields and methods to be included in other
models. As it is abstract, it does not exhibits the field by itself. The
field will only be exhibited when included in a concrete model via
inheritance. When it is included in another module, the XMLID creation
is discarded.

Take a module M1 that defines a model A, take another module M2 that
defines a mixin X with a field X1. In a third module M3, extend A to
inherit from X. While M3.A is the first model module to exhibit the
field X1, the XMLID creation was discarded because "M2" != "M3".

See #49354 (comment)

Task: 2235368
Closes #49354

@Julien00859
Julien00859 requested a review from rco-odoo June 2, 2020 15:21
@Julien00859

Copy link
Copy Markdown
Member Author

My little finger's telling me this may be incomplete... While this indeed fixes #49354, I'm not 100% sure I am not introducing new XMLIDs where we should not. Also, how could we test it ?

@robodoo robodoo added the CI 🤖 Robodoo has seen passing statuses label Jun 2, 2020
@C3POdoo C3POdoo added the RD research & development, internal work label Jun 2, 2020

@rco-odoo rco-odoo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not cover all cases, for instance when the mixin is not an abstract model, but the latter case is silly design. But if it covers our case, that's a step towards the good solution.

Maybe we could merge this into saas-13.4? @beledouxdenis

Comment thread odoo/addons/base/models/ir_model.py Outdated
Comment thread odoo/addons/base/models/ir_model.py Outdated
We want to create a XMLID for every first exhibition of a field in a
model. That is, we just want one XMLID by field by model and not one
XMLID by field by class. Previous implementation was determining the
"first field exhibition" by making sure the field was created and used
as part of the same module.

This assumption is invalid when we consider mixins. A mixin is an
abstract model that define fields and methods to be included in other
models. As it is abstract, it does not exhibits the field by itself. The
field will only be exhibited when included in a concrete model via
inheritance. When it is included in another module, the XMLID creation
is discarded.

Take a module M1 that defines a model A, take another module M2 that
defines a mixin X with a field X1. In a third module M3, extend A to
inherit from X. While M3.A is the first model module to exhibit the
field X1, the XMLID creation was discarded because `"M2" != "M3"`.

See odoo#49354 (comment)

Task: 2235368
Closes odoo#49354
@Julien00859
Julien00859 force-pushed the master-2235368-field_without_xmlid-juc branch from bca326d to 4307e00 Compare June 17, 2020 12:21
@robodoo robodoo added CI 🤖 Robodoo has seen passing statuses and removed CI 🤖 Robodoo has seen passing statuses labels Jun 17, 2020
@Julien00859

Copy link
Copy Markdown
Member Author

Rebased in saas-13.4

@Julien00859
Julien00859 deleted the master-2235368-field_without_xmlid-juc branch June 19, 2020 12:21
@robodoo robodoo added closed 💔 and removed CI 🤖 Robodoo has seen passing statuses labels Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RD research & development, internal work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants