[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.
This commit is contained in:
parent
7c5bf67a5f
commit
eb775fc2ea
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue