Skip to content

Commit

Permalink
[ADD] l10n_ch_qr_bill_without_amount
Browse files Browse the repository at this point in the history
  • Loading branch information
santostelmo committed Nov 12, 2024
1 parent b7e35fd commit a883784
Show file tree
Hide file tree
Showing 20 changed files with 816 additions and 0 deletions.
73 changes: 73 additions & 0 deletions l10n_ch_qr_bill_without_amount/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
=========================================
L10n Switzerland - QR Bill without Amount
=========================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_qr_bill_without_amount
: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_qr_bill_without_amount
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/l10n-switzerland&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Allows you to print QR invoices without a predefined amount. The QR invoice without an amount is based on the payment mode field `Qr Bill Without Amount`

**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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-switzerland/issues/new?body=module:%20l10n_ch_qr_bill_without_amount%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
~~~~~~~~~~~~

* Telmo Santos <[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_qr_bill_without_amount>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions l10n_ch_qr_bill_without_amount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import report
22 changes: 22 additions & 0 deletions l10n_ch_qr_bill_without_amount/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "L10n Switzerland - QR Bill without Amount",
"version": "16.0.1.0.0",
"category": "Localization",
"summary": "Print QR Bill without amount",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-switzerland",
"license": "AGPL-3",
"depends": [
"l10n_ch",
"account_payment_partner",
],
"data": [
"views/payment_mode.xml",
"report/swissqr_report.xml",
],
"installable": True,
"auto_install": False,
}
48 changes: 48 additions & 0 deletions l10n_ch_qr_bill_without_amount/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_ch_qr_bill_without_amount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-12 10:40+0000\n"
"PO-Revision-Date: 2024-11-12 10:40+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: l10n_ch_qr_bill_without_amount
#: model:ir.model,name:l10n_ch_qr_bill_without_amount.model_res_partner_bank
msgid "Bank Accounts"
msgstr ""

#. module: l10n_ch_qr_bill_without_amount
#: model:ir.model,name:l10n_ch_qr_bill_without_amount.model_account_move
msgid "Journal Entry"
msgstr ""

#. module: l10n_ch_qr_bill_without_amount
#: model:ir.model,name:l10n_ch_qr_bill_without_amount.model_account_payment_mode
msgid "Payment Modes"
msgstr ""

#. module: l10n_ch_qr_bill_without_amount
#: model:ir.model.fields,field_description:l10n_ch_qr_bill_without_amount.field_account_bank_statement_line__qr_bill_amount
#: model:ir.model.fields,field_description:l10n_ch_qr_bill_without_amount.field_account_move__qr_bill_amount
#: model:ir.model.fields,field_description:l10n_ch_qr_bill_without_amount.field_account_payment__qr_bill_amount
msgid "Qr Bill Amount"
msgstr ""

#. module: l10n_ch_qr_bill_without_amount
#: model:ir.model.fields,field_description:l10n_ch_qr_bill_without_amount.field_account_payment_mode__qr_bill_without_amount
msgid "Qr Bill Without Amount"
msgstr ""

#. module: l10n_ch_qr_bill_without_amount
#: model:ir.model,name:l10n_ch_qr_bill_without_amount.model_report_l10n_ch_qr_report_main
msgid "Swiss QR-bill report"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_ch_qr_bill_without_amount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-12 10:40+0000\n"
"PO-Revision-Date: 2024-11-12 10:40+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: l10n_ch_qr_bill_without_amount
#: model:ir.model.fields,field_description:l10n_ch_qr_bill_without_amount.field_account_bank_statement_line__qr_bill_amount
#: model:ir.model.fields,field_description:l10n_ch_qr_bill_without_amount.field_account_move__qr_bill_amount
#: model:ir.model.fields,field_description:l10n_ch_qr_bill_without_amount.field_account_payment__qr_bill_amount
msgid "Qr Bill Amount"
msgstr "Montant de la facture Qr"

#. module: l10n_ch_qr_bill_without_amount
#: model:ir.model.fields,field_description:l10n_ch_qr_bill_without_amount.field_account_payment_mode__qr_bill_without_amount
msgid "Qr Bill Without Amount"
msgstr "Facture Qr sans montant"
3 changes: 3 additions & 0 deletions l10n_ch_qr_bill_without_amount/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import res_partner_bank
from . import payment_mode
from . import account_move
22 changes: 22 additions & 0 deletions l10n_ch_qr_bill_without_amount/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class AccountMove(models.Model):
_inherit = "account.move"

qr_bill_amount = fields.Char(
compute="_compute_qr_bill_amount",
)

@api.depends("amount_residual")
def _compute_qr_bill_amount(self):
for move in self:
if move.payment_mode_id.qr_bill_without_amount:
move.qr_bill_amount = ""

Check warning on line 18 in l10n_ch_qr_bill_without_amount/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_ch_qr_bill_without_amount/models/account_move.py#L18

Added line #L18 was not covered by tests
else:
move.qr_bill_amount = "{:,.2f}".format(move.amount_residual).replace(
",", "\xa0"
)
10 changes: 10 additions & 0 deletions l10n_ch_qr_bill_without_amount/models/payment_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class AccountPaymentMode(models.Model):
_inherit = "account.payment.mode"

qr_bill_without_amount = fields.Boolean()
28 changes: 28 additions & 0 deletions l10n_ch_qr_bill_without_amount/models/res_partner_bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models


class ResPartnerBank(models.Model):
_inherit = "res.partner.bank"

def _l10n_ch_get_qr_vals(
self,
amount,
currency,
debtor_partner,
free_communication,
structured_communication,
):
res = super()._l10n_ch_get_qr_vals(
amount,
currency,
debtor_partner,
free_communication,
structured_communication,
)
if self.env.context.get("qr_bill_without_amount", {}).get(free_communication):
# Amount position
res[18] = ""
return res
1 change: 1 addition & 0 deletions l10n_ch_qr_bill_without_amount/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Telmo Santos <[email protected]>
1 change: 1 addition & 0 deletions l10n_ch_qr_bill_without_amount/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allows you to print QR invoices without a predefined amount. The QR invoice without an amount is based on the payment mode field `Qr Bill Without Amount`
1 change: 1 addition & 0 deletions l10n_ch_qr_bill_without_amount/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import swissqr_report
19 changes: 19 additions & 0 deletions l10n_ch_qr_bill_without_amount/report/swissqr_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from odoo import api, models


class ReportSwissQR(models.AbstractModel):
_inherit = "report.l10n_ch.qr_report_main"

@api.model
def _get_report_values(self, docids, data=None):
docs = self.env["account.move"].browse(docids)
qr_bill_without_amount = {}
for invoice in docs:
if invoice.payment_mode_id.qr_bill_without_amount:
# We sent invoice ref or name in context to be able to retrieve
# it in res.partner.bank._l10n_ch_get_qr_vals
qr_bill_without_amount[

Check warning on line 15 in l10n_ch_qr_bill_without_amount/report/swissqr_report.py

View check run for this annotation

Codecov / codecov/patch

l10n_ch_qr_bill_without_amount/report/swissqr_report.py#L15

Added line #L15 was not covered by tests
invoice.ref or invoice.name
] = invoice.payment_mode_id.qr_bill_without_amount
self = self.with_context(qr_bill_without_amount=qr_bill_without_amount)
return super(ReportSwissQR, self)._get_report_values(docids, data)
11 changes: 11 additions & 0 deletions l10n_ch_qr_bill_without_amount/report/swissqr_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="l10n_ch_swissqr_template"
inherit_id="l10n_ch.l10n_ch_swissqr_template"
>
<xpath expr="//t[@t-set='formated_amount']" position="attributes">
<attribute name="t-value">o.qr_bill_amount</attribute>
</xpath>
</template>
</odoo>
Loading

0 comments on commit a883784

Please sign in to comment.