[IMP] fields: set the default value to the closest field.default or _defaults
authorRaphael Collet <rco@openerp.com>
Thu, 2 Oct 2014 15:01:03 +0000 (17:01 +0200)
committerRaphael Collet <rco@openerp.com>
Thu, 9 Oct 2014 07:18:02 +0000 (09:18 +0200)
commit36174fcc6e49fe11ed16325b229690bb48736e62
tree95af78839d0f2acf9e1153ba0752e421f6fddacc
parent3f31081bc2351e352d8e6d8052f27a59b60adb1b
[IMP] fields: set the default value to the closest field.default or _defaults

This solves a subtle issue: in the following case, the class Bar should
override the default value set by Foo.  But in practice it was not working,
because _defaults is looked up before field.default.

    class Foo(models.Model):
        _name = 'foo'
        _columns = {
            'foo': fields.char('Foo'),
        }
        _defaults = {
            'foo': "Foo",
        }

    class Bar(models.Model):
        _inherit = 'foo'
        foo = fields.Char(default="Bar")

The change makes field.default and the model's _defaults consistent with each
other.
openerp/addons/test_inherit/models.py
openerp/addons/test_inherit/tests/test_inherit.py
openerp/fields.py
openerp/models.py