[FIX] fields: make convert_to_cache() more robust with inverse one2many

When a one2many field uses an integer field as inverse, the onchange method on
the second model may receive a dictionary for the value of the integer field.
This is because the client expects that field to be a many2one.
This commit is contained in:
Raphael Collet 2014-09-17 14:16:25 +02:00
parent 0084646475
commit 6e0c73d2ad
1 changed files with 3 additions and 0 deletions

View File

@ -903,6 +903,9 @@ class Integer(Field):
type = 'integer'
def convert_to_cache(self, value, record, validate=True):
if isinstance(value, dict):
# special case, when an integer field is used as inverse for a one2many
return value.get('id', False)
return int(value or 0)
def convert_to_read(self, value, use_name_get=True):