Skip to content

Commit

Permalink
[FIX] base_sparse_field,mail: handle None _instanciate_attrs override
Browse files Browse the repository at this point in the history
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 380fc10
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addons/base_sparse_field/models/models.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion addons/mail/models/ir_model.py
Expand Up @@ -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.