Skip to content

Commit

Permalink
Merge pull request #721 from sonhd91/17.0-mig-l10n_ch_qr_no_amount
Browse files Browse the repository at this point in the history
[MIG][17.0] l10n_ch_qr_no_amount: Migration to 17.0
  • Loading branch information
TDu authored Jun 28, 2024
2 parents 2faba6e + 8d7a606 commit d1447ea
Show file tree
Hide file tree
Showing 19 changed files with 745 additions and 0 deletions.
106 changes: 106 additions & 0 deletions l10n_ch_qr_no_amount/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
===============================
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/17.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-17-0/l10n-switzerland-17-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=17.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:%2017.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]>

Other credits
-------------

The migration of this module from 13.0 to 17.0 was financially supported
by Camptocamp

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/17.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": "17.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",
],
},
}
29 changes: 29 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,29 @@
# 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 13.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
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)
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
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"
2 changes: 2 additions & 0 deletions l10n_ch_qr_no_amount/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Akim Juillerat \<<[email protected]>\>
- Son Ho \<<[email protected]>\>
2 changes: 2 additions & 0 deletions l10n_ch_qr_no_amount/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The migration of this module from 13.0 to 17.0 was financially supported
by Camptocamp
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
7 changes: 7 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,7 @@
from odoo import 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"
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-out='formated_amount']"
position="attributes"
>
<attribute name="t-if">False</attribute>
</xpath>
<xpath
expr="//div[@id='receipt_amount_zone']//span[@t-out='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-out='formated_amount']"
position="attributes"
>
<attribute name="t-if">False</attribute>
</xpath>
<xpath
expr="//div[@id='amount_zone']//span[@t-out='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

0 comments on commit d1447ea

Please sign in to comment.