-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] l10n_be_cooperator_national_number: Fix the tests
- Loading branch information
1 parent
10afd2e
commit 69057a4
Showing
4 changed files
with
50 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import subscription_request | ||
from . import company | ||
from . import subscription_request | ||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
def update_belgian_national_number(self, national_number): | ||
self.ensure_one() | ||
result = None | ||
if national_number: | ||
belgian_cat = self.env.ref( | ||
"l10n_be_national_number.l10n_be_national_number_category" | ||
) | ||
existing = self.env["res.partner.id_number"].search( | ||
[ | ||
("partner_id", "=", self.id), | ||
("category_id", "=", belgian_cat.id), | ||
] | ||
) | ||
# Update | ||
if existing: | ||
existing.name = national_number | ||
result = existing | ||
# Create new | ||
else: | ||
values = { | ||
"name": national_number, | ||
"category_id": belgian_cat.id, | ||
"partner_id": self.id, | ||
} | ||
result = self.env["res.partner.id_number"].create(values) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters