Skip to content

Commit

Permalink
[FIX] l10n_be_cooperator_national_number: Allow removal of national n…
Browse files Browse the repository at this point in the history
…umber

Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca committed Jun 13, 2024
1 parent 349408f commit fd7ff8e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
28 changes: 16 additions & 12 deletions l10n_be_cooperator_national_number/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,22 @@ def get_be_national_register_number(self):
def update_belgian_national_number(self, national_number):
self.ensure_one()
result = None
if national_number:
existing = self.get_be_national_register_number_id_number()
# Update
if existing:
existing = self.get_be_national_register_number_id_number()
# Update
if existing:
if not national_number:
# TODO: should we check against require_national_number before
# unlinking?
existing.unlink()

Check warning on line 44 in l10n_be_cooperator_national_number/models/res_partner.py

View check run for this annotation

Codecov / codecov/patch

l10n_be_cooperator_national_number/models/res_partner.py#L44

Added line #L44 was not covered by tests
else:
existing.name = national_number
result = existing
# Create new
else:
values = {
"name": national_number,
"category_id": self.get_be_national_register_number_id_category().id,
"partner_id": self.id,
}
result = self.env["res.partner.id_number"].create(values)
# Create new
elif national_number:
values = {
"name": national_number,
"category_id": self.get_be_national_register_number_id_category().id,
"partner_id": self.id,
}
result = self.env["res.partner.id_number"].create(values)
return result
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow removal of national number.

0 comments on commit fd7ff8e

Please sign in to comment.