[FIX] models: make field inheritance work when source field is defined in old api
This commit is contained in:
parent
acdb43b6cb
commit
f2299749fe
|
@ -1,11 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from openerp import models, fields, api
|
||||
from openerp import models, fields, api, osv
|
||||
|
||||
# We just create a new model
|
||||
class mother(models.Model):
|
||||
_name = 'test.inherit.mother'
|
||||
|
||||
name = fields.Char('Name', required=True)
|
||||
_columns = {
|
||||
# check interoperability of field inheritance with old-style fields
|
||||
'name': osv.fields.char('Name', required=True),
|
||||
}
|
||||
|
||||
surname = fields.Char(compute='_compute_surname')
|
||||
state = fields.Selection([('a', 'A'), ('b', 'B')])
|
||||
|
||||
|
|
|
@ -237,6 +237,11 @@ class MetaModel(api.Meta):
|
|||
if not self._custom:
|
||||
self.module_to_models.setdefault(self._module, []).append(self)
|
||||
|
||||
# transform columns into new-style fields (enables field inheritance)
|
||||
for name, column in self._columns.iteritems():
|
||||
if not hasattr(self, name):
|
||||
setattr(self, name, column.to_field())
|
||||
|
||||
|
||||
class NewId(object):
|
||||
""" Pseudo-ids for new records. """
|
||||
|
|
Loading…
Reference in New Issue