diff options
| author | Xavier Morel <xmo@odoo.com> | 2020-06-18 13:22:23 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2020-07-27 06:32:59 +0000 |
| commit | ef709fd92b7b22a58e60715c9ff7ab4476a83ca5 (patch) | |
| tree | 6216bc42fe21c6b37c2ebf5cc0d66b4ccade2fc1 /odoo/addons/test_impex/models.py | |
| parent | dfda8b010ba8f20ea4fbc730eebd9c23d163c85a (diff) | |
[IMP] core, base: avoid multiple xids when importing records w/ inherits
Before this change, we create an xid for every parent of a record
being imported, regardless of whether it already has an xid, or if
it's being created implicitly through the child.
This generates unnecessary extra xids on pre-existing objects
e.g. update 5 product variants -> the product gets 5 new xids despite
already having one.
We should *only* set a xid on parent records which are being
implicitly created by the creation of a child with a specified
xid. That is, we should never set a xid on the parent if it exists
before the child is created.
Update _process_end to try and see if "non-loaded" xids correspond to
an automatically generated "parent" xid: we're still setting a xid on
implicitly created records (if the child is created with a xid) so
they're properly removed if e.g. the module is uninstalled, but
because we're only doing so at creation these xids will not be visited
during update and _process_end will try to delete them.
A special case can be added to check that "unknown" parent xids don't
have children which _inherit them, in which case we want to protect them.
Task 2251039
closes odoo/odoo#53283
Related: odoo/enterprise#12023
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'odoo/addons/test_impex/models.py')
| -rw-r--r-- | odoo/addons/test_impex/models.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/odoo/addons/test_impex/models.py b/odoo/addons/test_impex/models.py index f5890aec480..ad75f7d43f4 100644 --- a/odoo/addons/test_impex/models.py +++ b/odoo/addons/test_impex/models.py @@ -164,3 +164,15 @@ class OnlyOne(models.Model): ('value_unique', 'unique (value)', "The value must be unique"), ('pair_unique', 'unique (value2, value3)', "The values must be unique"), ] + +class InheritsParent(models.Model): + _name = _description = 'export.inherits.parent' + + value_parent = fields.Integer() + +class InheritsChild(models.Model): + _name = _description = 'export.inherits.child' + _inherits = {'export.inherits.parent': 'parent_id'} + + parent_id = fields.Many2one('export.inherits.parent', required=True, ondelete='cascade') + value = fields.Integer() |
