From be16348156a18981c19350fc6d8144b038651848 Mon Sep 17 00:00:00 2001 From: sonhd91 Date: Mon, 8 Apr 2024 10:07:56 +0700 Subject: [PATCH] [ADD] add module l10n_ch_partner_address_street3 --- l10n_ch_partner_address_street3/README.rst | 78 ++++ l10n_ch_partner_address_street3/__init__.py | 3 + .../__manifest__.py | 18 + .../models/__init__.py | 3 + .../models/res_bank.py | 57 +++ .../readme/CONTRIBUTORS.rst | 3 + .../readme/DESCRIPTION.rst | 1 + .../report/swissqr_report.xml | 20 + .../static/description/index.html | 427 ++++++++++++++++++ .../addons/l10n_ch_partner_address_street3 | 1 + .../l10n_ch_partner_address_street3/setup.py | 6 + 11 files changed, 617 insertions(+) create mode 100644 l10n_ch_partner_address_street3/README.rst create mode 100644 l10n_ch_partner_address_street3/__init__.py create mode 100644 l10n_ch_partner_address_street3/__manifest__.py create mode 100644 l10n_ch_partner_address_street3/models/__init__.py create mode 100644 l10n_ch_partner_address_street3/models/res_bank.py create mode 100644 l10n_ch_partner_address_street3/readme/CONTRIBUTORS.rst create mode 100644 l10n_ch_partner_address_street3/readme/DESCRIPTION.rst create mode 100644 l10n_ch_partner_address_street3/report/swissqr_report.xml create mode 100644 l10n_ch_partner_address_street3/static/description/index.html create mode 120000 setup/l10n_ch_partner_address_street3/odoo/addons/l10n_ch_partner_address_street3 create mode 100644 setup/l10n_ch_partner_address_street3/setup.py diff --git a/l10n_ch_partner_address_street3/README.rst b/l10n_ch_partner_address_street3/README.rst new file mode 100644 index 000000000..30bd257b3 --- /dev/null +++ b/l10n_ch_partner_address_street3/README.rst @@ -0,0 +1,78 @@ +=================================================== +Switzerland - Take into account street3 in QR-bills +=================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c9192cad47edc9342ff217b4b9078f0279b4a5fa497ca707001a57663fd0fcf9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fl10n--switzerland-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-switzerland/tree/16.0/l10n_ch_partner_address_street3 + :alt: OCA/l10n-switzerland +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-switzerland-16-0/l10n-switzerland-16-0-l10n_ch_partner_address_street3 + :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/l10n-switzerland&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module takes into account `street3` from `partner-contact/partner_address_street3` in QR-bills. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* `Trobz `_: + + * Son Ho + +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. + +This module is part of the `OCA/l10n-switzerland `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_ch_partner_address_street3/__init__.py b/l10n_ch_partner_address_street3/__init__.py new file mode 100644 index 000000000..cc5694a77 --- /dev/null +++ b/l10n_ch_partner_address_street3/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +from . import models diff --git a/l10n_ch_partner_address_street3/__manifest__.py b/l10n_ch_partner_address_street3/__manifest__.py new file mode 100644 index 000000000..d1e8b5d60 --- /dev/null +++ b/l10n_ch_partner_address_street3/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Switzerland - Take into account street3 in QR-bills", + "summary": "Take into account street3 in QR-bills", + "version": "16.0.1.0.0", + "author": "Camptocamp,Odoo Community Association (OCA)", + "category": "Localization", + "website": "https://github.com/OCA/l10n-switzerland", + "license": "AGPL-3", + "depends": [ + "l10n_ch", + "partner_address_street3", + ], + "data": ["report/swissqr_report.xml"], + "auto_install": True, +} diff --git a/l10n_ch_partner_address_street3/models/__init__.py b/l10n_ch_partner_address_street3/models/__init__.py new file mode 100644 index 000000000..6a71f9f05 --- /dev/null +++ b/l10n_ch_partner_address_street3/models/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +from . import res_bank diff --git a/l10n_ch_partner_address_street3/models/res_bank.py b/l10n_ch_partner_address_street3/models/res_bank.py new file mode 100644 index 000000000..4df852fb2 --- /dev/null +++ b/l10n_ch_partner_address_street3/models/res_bank.py @@ -0,0 +1,57 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +from odoo import _, models + +from odoo.addons.l10n_ch.models.res_bank import ResPartnerBank + + +class CustomResPartnerBank(models.Model): + _inherit = "res.partner.bank" + + def _check_for_qr_code_errors( + self, + qr_method, + amount, + currency, + debtor_partner, + free_communication, + structured_communication, + ): + + # Override original method in case partner only has street3 defined + def _partner_fields_set(partner): + return ( + partner.zip + and partner.city + and partner.country_id.code + and (partner.street or partner.street2 or partner.street3) + ) + + if qr_method == "ch_qr": + if not _partner_fields_set(self.partner_id): + return _( + # flake8: noqa + "The partner set on the bank account meant to receive the payment (%s) must have a complete postal address (street, zip, city and country).", + self.acc_number, + ) + + if debtor_partner and not _partner_fields_set(debtor_partner): + return _( + "The partner must have a complete postal address (street, zip, city and country)." + ) + + if self.l10n_ch_qr_iban and not self._is_qr_reference( + structured_communication + ): + return _( + "When using a QR-IBAN as the destination account of a QR-code, the payment reference must be a QR-reference." + ) + # We bypass the original ResPartnerBank._check_for_qr_code_errors + return super(ResPartnerBank, self)._check_for_qr_code_errors( + qr_method, + amount, + currency, + debtor_partner, + free_communication, + structured_communication, + ) diff --git a/l10n_ch_partner_address_street3/readme/CONTRIBUTORS.rst b/l10n_ch_partner_address_street3/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..a65ff950d --- /dev/null +++ b/l10n_ch_partner_address_street3/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Trobz `_: + + * Son Ho diff --git a/l10n_ch_partner_address_street3/readme/DESCRIPTION.rst b/l10n_ch_partner_address_street3/readme/DESCRIPTION.rst new file mode 100644 index 000000000..b7f2eb10b --- /dev/null +++ b/l10n_ch_partner_address_street3/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module takes into account `street3` from `partner-contact/partner_address_street3` in QR-bills. \ No newline at end of file diff --git a/l10n_ch_partner_address_street3/report/swissqr_report.xml b/l10n_ch_partner_address_street3/report/swissqr_report.xml new file mode 100644 index 000000000..1b6ec7938 --- /dev/null +++ b/l10n_ch_partner_address_street3/report/swissqr_report.xml @@ -0,0 +1,20 @@ + + + + diff --git a/l10n_ch_partner_address_street3/static/description/index.html b/l10n_ch_partner_address_street3/static/description/index.html new file mode 100644 index 000000000..4da14e0b8 --- /dev/null +++ b/l10n_ch_partner_address_street3/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Switzerland - Take into account street3 in QR-bills + + + +
+

Switzerland - Take into account street3 in QR-bills

+ + +

Beta License: AGPL-3 OCA/l10n-switzerland Translate me on Weblate Try me on Runboat

+

This module takes into account street3 from partner-contact/partner_address_street3 in QR-bills.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/l10n-switzerland project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/setup/l10n_ch_partner_address_street3/odoo/addons/l10n_ch_partner_address_street3 b/setup/l10n_ch_partner_address_street3/odoo/addons/l10n_ch_partner_address_street3 new file mode 120000 index 000000000..246f3a785 --- /dev/null +++ b/setup/l10n_ch_partner_address_street3/odoo/addons/l10n_ch_partner_address_street3 @@ -0,0 +1 @@ +../../../../l10n_ch_partner_address_street3 \ No newline at end of file diff --git a/setup/l10n_ch_partner_address_street3/setup.py b/setup/l10n_ch_partner_address_street3/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/l10n_ch_partner_address_street3/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)