diff --git a/partner_changeset/models/res_partner_changeset.py b/partner_changeset/models/res_partner_changeset.py index 8b74005b0..ef84c167d 100644 --- a/partner_changeset/models/res_partner_changeset.py +++ b/partner_changeset/models/res_partner_changeset.py @@ -421,7 +421,10 @@ class ResPartnerChangesetChange(models.Model): @api.model def _has_field_changed(self, record, field, value): field_def = record._fields[field] - return field_def.convert_to_write(record[field]) != value + current_value = field_def.convert_to_write(record[field]) + if not (current_value or value): + return False + return current_value != value @api.multi def _convert_value_for_write(self, value): diff --git a/partner_changeset/tests/test_changeset_field_type.py b/partner_changeset/tests/test_changeset_field_type.py index 89cb7c4f2..9354e881e 100644 --- a/partner_changeset/tests/test_changeset_field_type.py +++ b/partner_changeset/tests/test_changeset_field_type.py @@ -177,7 +177,7 @@ class TestChangesetFieldType(ChangesetMixin, common.TransactionCase): """ Add a new changeset on a Binary field is not supported """ with self.assertRaises(NotImplementedError): self.partner.write({ - self.field_binary.name: '', + self.field_binary.name: 'xyz', }) def test_apply_char(self): diff --git a/partner_changeset/tests/test_changeset_flow.py b/partner_changeset/tests/test_changeset_flow.py index f11d28896..a78b7b8e2 100644 --- a/partner_changeset/tests/test_changeset_flow.py +++ b/partner_changeset/tests/test_changeset_flow.py @@ -87,6 +87,18 @@ class TestChangesetFlow(ChangesetMixin, common.TransactionCase): [(self.field_street, 'street X', False, 'draft')] ) + def test_no_changeset_empty_value_both_sides(self): + """ No changeset created when both sides have an empty value """ + # we have to ensure that even if we write '' to a False field, we won't + # write a changeset + self.partner.with_context(__no_changeset=True).write({ + 'street': False, + }) + self.partner.write({ + 'street': '', + }) + self.assertFalse(self.partner.changeset_ids) + def test_apply_change(self): """ Apply a changeset change on a partner """ changes = [