[FIX] base_sparse_field,mail: handle None _instanciate_attrs override

The parent was expected to return a dict, but it can also return None in some
cases. When that happens, the overrides were crashing because it is impossible
to assign a key/val to None.

Note that using `if` conditions like this also prevents from writing on the dict
if it is existing but empty, but due to the definition of the parent, if there
is a dict, it will not be empty.

closes odoo/odoo#38316

X-original-commit: 3525fad3b1729286d139b19a4a92f1821d94ad88
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
fw-bot
2019-10-10 06:27:09 +00:00
parent b0fc1cd455
commit 91e4b00b8b
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ class IrModelFields(models.Model):
def _instanciate_attrs(self, field_data):
attrs = super(IrModelFields, self)._instanciate_attrs(field_data)
if field_data.get('serialization_field_id'):
if attrs and field_data.get('serialization_field_id'):
serialization_record = self.browse(field_data['serialization_field_id'])
attrs['sparse'] = serialization_record.name
return attrs
+1 -1
View File
@@ -27,7 +27,7 @@ class IrModelField(models.Model):
def _instanciate_attrs(self, field_data):
attrs = super(IrModelField, self)._instanciate_attrs(field_data)
if field_data.get('tracking'):
if attrs and field_data.get('tracking'):
attrs['tracking'] = field_data['tracking']
return attrs