-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] l10n_be_cooperator_portal_national_number
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
- Loading branch information
1 parent
a05eb10
commit ff523dc
Showing
13 changed files
with
668 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
========================================== | ||
Belgium: Cooperator Portal National Number | ||
========================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:edd0ec10bd9936397267e9ce09d6d46850863b5f8a89c63ac389fd0239fd0b22 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcooperative-lightgray.png?logo=github | ||
:target: https://github.com/OCA/cooperative/tree/16.0/l10n_be_cooperator_portal_national_number | ||
:alt: OCA/cooperative | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/cooperative-16-0/cooperative-16-0-l10n_be_cooperator_portal_national_number | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/cooperative&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Add the ability to change national number on the account portal. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/cooperative/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/cooperative/issues/new?body=module:%20l10n_be_cooperator_portal_national_number%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Coop IT Easy SC | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Coop IT Easy SC <https://github.com/OCA/cooperative>`_: | ||
|
||
* Carmen Bianca BAKKER | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
.. |maintainer-carmenbianca| image:: https://github.com/carmenbianca.png?size=40px | ||
:target: https://github.com/carmenbianca | ||
:alt: carmenbianca | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-carmenbianca| | ||
|
||
This module is part of the `OCA/cooperative <https://github.com/OCA/cooperative/tree/16.0/l10n_be_cooperator_portal_national_number>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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,6 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from . import controllers | ||
from . import models |
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,22 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
{ | ||
"name": "Belgium: Cooperator Portal National Number", | ||
"summary": """ | ||
Add the ability to change national number on the account portal.""", | ||
"version": "16.0.1.0.0", | ||
"category": "Cooperative management", | ||
"website": "https://github.com/OCA/cooperative", | ||
"author": "Coop IT Easy SC, Odoo Community Association (OCA)", | ||
"maintainers": ["carmenbianca"], | ||
"license": "AGPL-3", | ||
"application": False, | ||
"depends": [ | ||
"cooperator_portal", | ||
"l10n_be_cooperator_national_number", | ||
], | ||
"auto_install": True, | ||
"data": ["views/portal_templates.xml"], | ||
} |
5 changes: 5 additions & 0 deletions
5
l10n_be_cooperator_portal_national_number/controllers/__init__.py
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,5 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from . import portal |
59 changes: 59 additions & 0 deletions
59
l10n_be_cooperator_portal_national_number/controllers/portal.py
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,59 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
|
||
from odoo import _ | ||
from odoo.http import request, route | ||
|
||
from odoo.addons.account.controllers.portal import PortalAccount | ||
|
||
|
||
class CooperatorPortal(PortalAccount): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
# See cooportal_portal/controllers/portal.py for why this code is the | ||
# way it is. | ||
if "OPTIONAL_BILLING_FIELDS" not in vars(self): | ||
self.OPTIONAL_BILLING_FIELDS = PortalAccount.OPTIONAL_BILLING_FIELDS.copy() | ||
self.OPTIONAL_BILLING_FIELDS.extend(["national_number"]) | ||
|
||
def _prepare_portal_layout_values(self): | ||
values = super()._prepare_portal_layout_values() | ||
values[ | ||
"display_national_number" | ||
] = request.env.company.get_display_national_number( | ||
request.env.user.partner_id.is_company | ||
) | ||
national_number = request.env.user.partner_id.get_be_national_register_number() | ||
values["national_number"] = national_number | ||
return values | ||
|
||
def details_form_validate(self, data): | ||
error, error_message = super().details_form_validate(data) | ||
national_number = data.get("national_number") | ||
if national_number: | ||
failed = request.env["res.partner"].check_be_national_register_number( | ||
national_number | ||
) | ||
if failed: | ||
error["national_number"] = "error" | ||
error_message.append(_("The national number is not valid.")) | ||
# Normally this should be in MANDATORY_BILLING_FIELDS, but national | ||
# number is conditionally required, which is tricky. | ||
if not national_number and request.env.company.get_require_national_number( | ||
request.env.user.partner_id.is_company | ||
): | ||
error["national_number"] = "error" | ||
error_message.append(_("The national number is required.")) | ||
return error, error_message | ||
|
||
@route(["/my/account"], type="http", auth="user", website=True) | ||
def account(self, redirect=None, **post): | ||
res = super().account(redirect, **post) | ||
if not res.qcontext.get("error"): | ||
national_number = post.get("national_number") | ||
request.env.user.partner_id.update_be_national_register_number( | ||
national_number | ||
) | ||
return res | ||
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,5 @@ | ||
# SPDX-FileCopyrightText: 2022 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from . import res_partner |
15 changes: 15 additions & 0 deletions
15
l10n_be_cooperator_portal_national_number/models/res_partner.py
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,15 @@ | ||
# SPDX-FileCopyrightText: 2022 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
def write(self, vals): | ||
# For an explanation, see res_partner of cooperator_portal. | ||
if "national_number" in vals: | ||
del vals["national_number"] | ||
return super().write(vals) | ||
3 changes: 3 additions & 0 deletions
3
l10n_be_cooperator_portal_national_number/readme/CONTRIBUTORS.rst
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,3 @@ | ||
* `Coop IT Easy SC <https://github.com/OCA/cooperative>`_: | ||
|
||
* Carmen Bianca BAKKER |
1 change: 1 addition & 0 deletions
1
l10n_be_cooperator_portal_national_number/readme/DESCRIPTION.rst
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 @@ | ||
Add the ability to change national number on the account portal. |
Oops, something went wrong.