Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] l10n_ch_qr_no_amount #742

Open
wants to merge 7 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions l10n_ch_qr_no_amount/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
===============================
Switzerland - No Amount QR-bill
===============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e790e1b2f6aeeeb045f9405a93cd90d9602df5da116a09a9bed3a4b571224472
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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_no_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_no_amount
: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 adds a new report that allows to print QR bills without
any amount,
| so that the customer can define himself the amount to pay.

Not setting the amount allows to use the same QR code for multiple
payments referencing the same invoice.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Usage
=====

Add the report to the print action and use it as you wish.

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_qr_no_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
------------

- Akim Juillerat <[email protected]>
- Son Ho <[email protected]>
- 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.

.. |maintainer-grindtildeath| image:: https://github.com/grindtildeath.png?size=40px
:target: https://github.com/grindtildeath
:alt: grindtildeath

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-grindtildeath|

This module is part of the `OCA/l10n-switzerland <https://github.com/OCA/l10n-switzerland/tree/16.0/l10n_ch_qr_no_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_no_amount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import report
21 changes: 21 additions & 0 deletions l10n_ch_qr_no_amount/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "Switzerland - No Amount QR-bill",
"summary": "Allow to print QR bill without amount",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"category": "Localization",
"website": "https://github.com/OCA/l10n-switzerland",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["grindtildeath"],
"license": "AGPL-3",
"installable": True,
"depends": ["l10n_ch"],
"data": ["report/swissqr_no_amount_report.xml"],
"assets": {
"web.report_assets_common": [
"l10n_ch_qr_no_amount/static/src/scss/report_swissqr_no_amount.scss",
],
},
}
30 changes: 30 additions & 0 deletions l10n_ch_qr_no_amount/i18n/l10n_ch_qr_no_amount.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_ch_qr_no_amount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \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_no_amount
#: model:ir.actions.report,print_report_name:l10n_ch_qr_no_amount.l10n_ch_qr_no_amount_report
msgid "'QR-bill-%s' % object.name"
msgstr ""

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

#. module: l10n_ch_qr_no_amount
#: model:ir.actions.report,name:l10n_ch_qr_no_amount.l10n_ch_qr_no_amount_report
#: model:ir.model,name:l10n_ch_qr_no_amount.model_report_l10n_ch_qr_no_amount_qr_no_amount_report_main
msgid "QR-No-Amount-bill"
msgstr ""
1 change: 1 addition & 0 deletions l10n_ch_qr_no_amount/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_partner_bank
31 changes: 31 additions & 0 deletions l10n_ch_qr_no_amount/models/res_partner_bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import models


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

def _l10n_ch_get_qr_vals(
self,
amount,
currency_name,
debtor_partner,
free_communication,
structured_communication,
):
res = super()._l10n_ch_get_qr_vals(
amount,
currency_name,
debtor_partner,
free_communication,
structured_communication,
)
if self.env.context.get("_no_amount_qr_code", False):
res = self._remove_swiss_code_amount(res)

Check warning on line 25 in l10n_ch_qr_no_amount/models/res_partner_bank.py

View check run for this annotation

Codecov / codecov/patch

l10n_ch_qr_no_amount/models/res_partner_bank.py#L25

Added line #L25 was not covered by tests
return res

def _remove_swiss_code_amount(self, values_list):
# 18 is the position of amount in returned list
values_list[18] = ""
return values_list

Check warning on line 31 in l10n_ch_qr_no_amount/models/res_partner_bank.py

View check run for this annotation

Codecov / codecov/patch

l10n_ch_qr_no_amount/models/res_partner_bank.py#L30-L31

Added lines #L30 - L31 were not covered by tests
3 changes: 3 additions & 0 deletions l10n_ch_qr_no_amount/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions l10n_ch_qr_no_amount/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Akim Juillerat \<<[email protected]>\>
- Son Ho \<<[email protected]>\>
- Telmo Santos \<<[email protected]>\>
5 changes: 5 additions & 0 deletions l10n_ch_qr_no_amount/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module adds a new report that allows to print QR bills without any amount,
so that the customer can define himself the amount to pay.

Not setting the amount allows to use the same QR code for multiple
payments referencing the same invoice.
1 change: 1 addition & 0 deletions l10n_ch_qr_no_amount/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add the report to the print action and use it as you wish.
1 change: 1 addition & 0 deletions l10n_ch_qr_no_amount/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import swissqr_no_amount_report
13 changes: 13 additions & 0 deletions l10n_ch_qr_no_amount/report/swissqr_no_amount_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from odoo import api, models


class ReportSwissNoAmountQR(models.AbstractModel):
_name = "report.l10n_ch_qr_no_amount.qr_no_amount_report_main"
_inherit = "report.l10n_ch.qr_report_main"
_description = "QR-No-Amount-bill"

@api.model
def _get_report_values(self, docids, data=None):
if self._name == "report.l10n_ch_qr_no_amount.qr_no_amount_report_main":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition will always evaluate to True as it's the _name of the class where the override is done.
You can cherry-pick from #745 to solve the amount encoded in QR issue that was introduced in the migration to 17.0

self = self.with_context(_no_amount_qr_code=True)
return super(ReportSwissNoAmountQR, self)._get_report_values(docids, data)

Check warning on line 13 in l10n_ch_qr_no_amount/report/swissqr_no_amount_report.py

View check run for this annotation

Codecov / codecov/patch

l10n_ch_qr_no_amount/report/swissqr_no_amount_report.py#L12-L13

Added lines #L12 - L13 were not covered by tests
74 changes: 74 additions & 0 deletions l10n_ch_qr_no_amount/report/swissqr_no_amount_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="l10n_ch_qr_no_amount_report" model="ir.actions.report">
<field name="name">QR-No-Amount-bill</field>
<field name="model">account.move</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">l10n_ch_qr_no_amount.qr_no_amount_report_main</field>
<field name="report_file">l10n_ch_qr_no_amount.qr_report_main</field>
<field name="attachment">'QR-bill-' + object.name + '.pdf'</field>
<field name="print_report_name">'QR-bill-%s' % object.name</field>
<field name="binding_model_id" ref="account.model_account_move" />
<field name="paperformat_id" ref="l10n_ch.paperformat_euro_no_margin" />
</record>

<template
id="l10n_ch_swissqr_no_amount_template"
inherit_id="l10n_ch.l10n_ch_swissqr_template"
primary="True"
>

<xpath expr="//t[@t-set='o']" position="attributes">
<attribute
name="t-value"
>o.with_context(**{'lang': lang, '_no_amount_qr_code': True})</attribute>
</xpath>
<!-- Replace amount with blank fields with black corners -->
<xpath expr="//t[@t-set='formated_amount']" position="attributes">
<attribute name="t-value">str()</attribute>
</xpath>
<xpath
expr="//div[@id='receipt_amount_zone']//span[@t-esc='formated_amount']"
position="attributes"
>
<attribute name="t-if">False</attribute>
</xpath>
<xpath
expr="//div[@id='receipt_amount_zone']//span[@t-esc='formated_amount']"
position="after"
>
<img
class="receipt_amount_edges"
src="/l10n_ch_qr_no_amount/static/src/img/Betragsfeld_Eckmarke.png"
/>
</xpath>
<xpath
expr="//div[@id='amount_zone']//span[@t-esc='formated_amount']"
position="attributes"
>
<attribute name="t-if">False</attribute>
</xpath>
<xpath
expr="//div[@id='amount_zone']//span[@t-esc='formated_amount']"
position="after"
>
<div><img
class="payment_amount_edges"
src="/l10n_ch_qr_no_amount/static/src/img/Feld_Betrag_40x15mm.png"
/></div>
</xpath>
</template>

<template id="l10n_ch_qr_no_amount.qr_no_amount_report_main">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-set="lang" t-value="o.partner_id.lang" />
<t
t-call="l10n_ch_qr_no_amount.l10n_ch_swissqr_no_amount_template"
t-lang="lang"
/>
</t>
</t>
</template>
</odoo>
Binary file added l10n_ch_qr_no_amount/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading