From eb775fc2ead0133f735d94af8b0fa275827d4bbe Mon Sep 17 00:00:00 2001 From: dhr-odoo Date: Wed, 9 Jul 2014 12:53:36 +0530 Subject: [PATCH] [FIX] orm: set default before removing magic fields When a record is created, the magic fields (id, create_date,...) are first removed from the vals as the user should not set a value for these. However if a value for this is given in default value (e.g. defined in an ir.value), the creation would crash (sql error : column specified more than once) as the magic column would be added again. --- openerp/osv/orm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 0a38ccf03d4..f0c8337ea6d 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -4394,6 +4394,8 @@ class BaseModel(object): self._transient_vacuum(cr, user) self.check_access_rights(cr, user, 'create') + + vals = self._add_missing_default_values(cr, user, vals, context) if self._log_access: for f in LOG_ACCESS_COLUMNS: @@ -4401,7 +4403,6 @@ class BaseModel(object): _logger.warning( 'Field `%s` is not allowed when creating the model `%s`.', f, self._name) - vals = self._add_missing_default_values(cr, user, vals, context) tocreate = {} for v in self._inherits: