Friday, June 19, 2020
2 changes · master
Resolved issues and error corrections
Odoo now correctly creates the needed internal identifiers when shared fields from mixins are first used by a real model. This prevents missing field references in module setups that reuse shared model definitions across modules.
Original PR description
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…
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 https://github.com/odoo/odoo/issues/49354#issuecomment-614093767 Task: 2235368 Closes #49354
This update fixes cases where Odoo methods could behave incorrectly when processing several records at once. It reduces the risk of errors or inconsistent results in affected workflows, even though most standard usage was unlikely to trigger the issue.
Original PR description
Some methods in Odoo codebase look like they work fine even if self is a recordset of len > 1, when in fact it isn't the case (due to the use of `self.field` when looping on `self`). _NB:_ The majority of those methods are not called with a recordset of len > 1, thus not expected to create real bugs (if you only have basic Odoo modules). -- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr