Skip to content
Permalink
Browse files

[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 #38168

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
  • Loading branch information...
ysh-odoo authored and seb-odoo committed Oct 8, 2019
1 parent 42db9ca commit 380fc10291efaa8bd371509a4b541cc4e23af14d
Showing with 2 additions and 2 deletions.
  1. +1 −1 addons/base_sparse_field/models/models.py
  2. +1 −1 addons/mail/models/ir_model.py
@@ -58,7 +58,7 @@ def _reflect_model(self, 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
@@ -111,6 +111,6 @@ def _reflect_field_params(self, field):

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

0 comments on commit 380fc10

Please sign in to comment.
You can’t perform that action at this time.