Skip to content

Commit

Permalink
[REF] l10n_be_cooperator_national_number: Improve method name
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca committed Jun 14, 2024
1 parent 069348b commit 15f2d84
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
11 changes: 5 additions & 6 deletions l10n_be_cooperator_national_number/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ def get_be_national_register_number(self):
return None

@api.model
def check_be_national_register_number(self, national_number, error=False):
"""Verify whether the national number is valid. Returns True if invalid,
which is consistent with validate_l10n_be_national_registry_number.
def validate_be_national_register_number(self, national_number, error=False):
"""Verify whether the national number is valid. Returns True if valid.
If error is True, a ValidationError is raised instead.
"""
Expand All @@ -52,10 +51,10 @@ def check_be_national_register_number(self, national_number, error=False):
except ValidationError:
if error:
raise
return True
return False
return False

Check warning on line 54 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#L54

Added line #L54 was not covered by tests
return True

def update_belgian_national_number(self, national_number):
def update_be_national_register_number(self, national_number):
self.ensure_one()
result = None
if national_number:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ def validate_subscription_request(self):
if self.require_national_number and not self.national_number:
raise UserError(_("National Number is required."))
if self.national_number:
self.env["res.partner"].check_be_national_register_number(
self.env["res.partner"].validate_be_national_register_number(
self.national_number, error=True
)
invoice = super().validate_subscription_request()
if not self.is_company:
partner = invoice.partner_id
partner.update_belgian_national_number(self.national_number)
partner.update_be_national_register_number(self.national_number)
return invoice

def set_person_info(self, partner):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
``check_be_national_register_number`` moved from ``subscription.request`` to
``res.partner``. Added ``error`` kwarg, and it is no longer necessary to call
this method with ``sudo()``.
``res.partner`` and renamed to ``validate_be_national_register_number``. Added
``error`` kwarg, and it is no longer necessary to call this method with
``sudo()``.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``update_belgian_national_number`` renamed to
``update_be_national_register_number``.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def _additional_validate(self, kwargs, logged, values, post_file):
return result
national_number = values.get("national_number")
if national_number:
failed = request.env["res.partner"].check_be_national_register_number(
valid = request.env["res.partner"].validate_be_national_register_number(

Check warning on line 39 in l10n_be_cooperator_website_national_number/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_be_cooperator_website_national_number/controllers/main.py#L39

Added line #L39 was not covered by tests
values["national_number"]
)
if failed:
if not valid:
values["error_msg"] = (

Check warning on line 43 in l10n_be_cooperator_website_national_number/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_be_cooperator_website_national_number/controllers/main.py#L43

Added line #L43 was not covered by tests
_("%s is not a valid Belgian national registration number")
% values["national_number"]
Expand Down

0 comments on commit 15f2d84

Please sign in to comment.