Skip to content

Commit

Permalink
Merge PR #133 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by carmenbianca
  • Loading branch information
OCA-git-bot committed Jun 11, 2024
2 parents ddedfab + 83c1f15 commit 6a1feb4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion l10n_be_cooperator_national_number/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from . import company
from . import subscription_request
from . import res_company
from . import res_partner
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ def _check_national_number(self):
)
)

def get_display_national_number(self, is_company):
self.ensure_one()
if is_company:
return False
return self.display_national_number

def get_require_national_number(self, is_company):
self.ensure_one()
if is_company:
return False
return self.require_national_number

@api.onchange("display_national_number")
def _onchange_display_national_number(self):
if not self.display_national_number:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ class SubscriptionRequest(models.Model):

@api.depends("is_company", "company_id", "company_id.display_national_number")
def _compute_display_national_number(self):
self.display_national_number = (
self.company_id.display_national_number and not self.is_company
)
for request in self:
request.display_national_number = (
request.company_id.get_display_national_number(request.is_company)
)

@api.depends("is_company", "company_id", "company_id.require_national_number")
def _compute_require_national_number(self):
self.require_national_number = (
self.company_id.require_national_number and not self.is_company
)
for request in self:
request.require_national_number = (
request.company_id.get_require_national_number(request.is_company)
)

@api.model
def _get_be_national_register_number_id_category(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added ``get_display_national_number`` and ``get_require_national_number``
convenience methods to ``res.company``.
24 changes: 7 additions & 17 deletions l10n_be_cooperator_website_national_number/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,14 @@ def get_values_from_user(self, values, is_company):
values["national_number"] = national_number
return values

def _get_display_national_number(self, is_company):
if is_company:
return False
return request.env.company.display_national_number

def _get_require_national_number(self, is_company):
if is_company:
return False
return request.env.company.require_national_number

def fill_values(self, values, is_company, logged, load_from_user=False):
values = super().fill_values(values, is_company, logged, load_from_user)
values["display_national_number"] = self._get_display_national_number(
is_company
)
values["national_number_required"] = self._get_require_national_number(
is_company
)
values[
"display_national_number"
] = request.env.company.get_display_national_number(is_company)
values[
"national_number_required"
] = request.env.company.get_require_national_number(is_company)
return values

def _additional_validate(self, kwargs, logged, values, post_file):
Expand All @@ -57,7 +47,7 @@ def _additional_validate(self, kwargs, logged, values, post_file):
values["error_msg"] = str(ve)
else:
is_company = kwargs.get("is_company") == "on"
if not self._get_require_national_number(is_company):
if not request.env.company.get_require_national_number(is_company):
return True
values["error_msg"] = _("Some mandatory fields have not been filled.")
values["error"] = {"national_number"}
Expand Down

0 comments on commit 6a1feb4

Please sign in to comment.