[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:
parent
0084646475
commit
6e0c73d2ad
|
@ -903,6 +903,9 @@ class Integer(Field):
|
||||||
type = 'integer'
|
type = 'integer'
|
||||||
|
|
||||||
def convert_to_cache(self, value, record, validate=True):
|
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)
|
return int(value or 0)
|
||||||
|
|
||||||
def convert_to_read(self, value, use_name_get=True):
|
def convert_to_read(self, value, use_name_get=True):
|
||||||
|
|
Loading…
Reference in New Issue