Skip to content
Snippets Groups Projects
Commit ec226308 authored by Martin Trigaux's avatar Martin Trigaux
Browse files

[FIX] fields: inherited fields keep parent's modules

On a field created through a _inherits, the fields on the child model did not
benefit from the parent _modules information.

If two models are created in module base

class Partner(models.Model):
    _name = 'res.partner'

class User(models.Model):
    _inherits = {'res.partner': 'partner_id'}

   partner_id = fields.Many2one('res.partner')

and a second module auth_signup adds a field on the parent model

class ResPartner(models.Model):
    _inherit = 'res.partner'

    signup_token = fields.Char()

Both res.users and res.partner should have an ir.model.data create

base_setup.field_res_partner__signup_token was correctly created but
base_setup.field_res_users__signup_token was not created

The reason is was, in the call to _reflect_model, since 574f4c3d, the
creation of ir.model.data is based on the field._modules
However, the field res.partner.signup_token did not propagate its _modules value
to the related field res.users.signup_token

With this patch, both ir.model.data are created.

This allow a proper uninstallation of fields as well as translation.
parent 2b9f8452
No related branches found
No related tags found
No related merge requests found
......@@ -560,6 +560,9 @@ class Field(MetaField('DummyField', (object,), {})):
if self.inherited and field.required:
self.required = True
if self.inherited:
self._modules.update(field._modules)
def traverse_related(self, record):
""" Traverse the fields of the related field `self` except for the last
one, and return it as a pair `(last_record, last_field)`. """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment