Skip to content

Commit

Permalink
Merge PR #720 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by gurneyalex
  • Loading branch information
OCA-git-bot committed Apr 25, 2024
2 parents 1600fc0 + be16348 commit 8f47fba
Show file tree
Hide file tree
Showing 11 changed files with 617 additions and 0 deletions.
78 changes: 78 additions & 0 deletions l10n_ch_partner_address_street3/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/l10n-switzerland/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/l10n-switzerland/issues/new?body=module:%20l10n_ch_partner_address_street3%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
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* `Trobz <https://trobz.com>`_:

* Son Ho <[email protected]>

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 <https://github.com/OCA/l10n-switzerland/tree/16.0/l10n_ch_partner_address_street3>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions l10n_ch_partner_address_street3/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from . import models
18 changes: 18 additions & 0 deletions l10n_ch_partner_address_street3/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
3 changes: 3 additions & 0 deletions l10n_ch_partner_address_street3/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from . import res_bank
57 changes: 57 additions & 0 deletions l10n_ch_partner_address_street3/models/res_bank.py
Original file line number Diff line number Diff line change
@@ -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,
)
3 changes: 3 additions & 0 deletions l10n_ch_partner_address_street3/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Trobz <https://trobz.com>`_:

* Son Ho <[email protected]>
1 change: 1 addition & 0 deletions l10n_ch_partner_address_street3/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module takes into account `street3` from `partner-contact/partner_address_street3` in QR-bills.
20 changes: 20 additions & 0 deletions l10n_ch_partner_address_street3/report/swissqr_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="l10n_ch_swissqr_template"
inherit_id="l10n_ch.l10n_ch_swissqr_template"
>
<xpath
expr="//div[@id='receipt_indication_zone']//span[@t-field='o.partner_id.street2']"
position="after"
>
<span t-field="o.partner_id.street3" />
</xpath>
<xpath
expr="//div[@id='indications_zone']//span[@t-field='o.partner_id.street2']"
position="after"
>
<span t-field="o.partner_id.street3" />
</xpath>
</template>
</odoo>
Loading

0 comments on commit 8f47fba

Please sign in to comment.