From cc0295ec9044bac1495c3a9781c18cf8074a5fe5 Mon Sep 17 00:00:00 2001 From: Samir GUESMI Date: Mon, 5 Aug 2024 12:03:45 +0200 Subject: [PATCH] [MIG] account_invoice_qr_code_sepa_payconiq: Migration to 16.0 --- .../README.rst | 23 ++++---- .../__manifest__.py | 2 +- .../models/res_partner_bank.py | 20 +++++-- .../static/description/index.html | 58 ++++++++++--------- .../tests/test_payconiq_qr.py | 52 ++++++++++++----- .../account_invoice_qr_code_sepa_payconiq | 1 + .../setup.py | 6 ++ 7 files changed, 106 insertions(+), 56 deletions(-) create mode 120000 setup/account_invoice_qr_code_sepa_payconiq/odoo/addons/account_invoice_qr_code_sepa_payconiq create mode 100644 setup/account_invoice_qr_code_sepa_payconiq/setup.py diff --git a/account_invoice_qr_code_sepa_payconiq/README.rst b/account_invoice_qr_code_sepa_payconiq/README.rst index accf01e043b..449d0c01474 100644 --- a/account_invoice_qr_code_sepa_payconiq/README.rst +++ b/account_invoice_qr_code_sepa_payconiq/README.rst @@ -2,10 +2,13 @@ Account Invoice Qr Code Sepa Payconiq ===================================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0211e221ca8675a6785589d60584e334602617ea0c90110a42c4812af441b20e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -14,16 +17,16 @@ Account Invoice Qr Code Sepa Payconiq :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github - :target: https://github.com/OCA/account-invoicing/tree/14.0/account_invoice_qr_code_sepa_payconiq + :target: https://github.com/OCA/account-invoicing/tree/16.0/account_invoice_qr_code_sepa_payconiq :alt: OCA/account-invoicing .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/account-invoicing-14-0/account-invoicing-14-0-account_invoice_qr_code_sepa_payconiq + :target: https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-account_invoice_qr_code_sepa_payconiq :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/95/14.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=16.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module allows to generate a QR code to be displayed on invoices. @@ -59,8 +62,8 @@ 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 smashing it by providing a detailed and welcomed -`feedback `_. +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. @@ -90,6 +93,6 @@ 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/account-invoicing `_ project on GitHub. +This module is part of the `OCA/account-invoicing `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_invoice_qr_code_sepa_payconiq/__manifest__.py b/account_invoice_qr_code_sepa_payconiq/__manifest__.py index 5ae595f6bc0..9b85daae903 100644 --- a/account_invoice_qr_code_sepa_payconiq/__manifest__.py +++ b/account_invoice_qr_code_sepa_payconiq/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Invoice Qr Code Sepa Payconiq", "summary": """ Allows to generate a qr code for Payconiq provider containing the url""", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV,Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-invoicing", diff --git a/account_invoice_qr_code_sepa_payconiq/models/res_partner_bank.py b/account_invoice_qr_code_sepa_payconiq/models/res_partner_bank.py index 3b1950babbd..601684e5498 100644 --- a/account_invoice_qr_code_sepa_payconiq/models/res_partner_bank.py +++ b/account_invoice_qr_code_sepa_payconiq/models/res_partner_bank.py @@ -92,14 +92,18 @@ def _get_qr_code_url( structured_communication, ) - def _eligible_for_qr_code(self, qr_method, debtor_partner, currency): + def _eligible_for_qr_code( + self, qr_method, debtor_partner, currency, raises_error=True + ): if qr_method == "payconiq_qr": return ( currency.name == "EUR" and self.acc_type == "iban" and self.sanitized_acc_number[:2] in ["LU"] ) - return super()._eligible_for_qr_code(qr_method, debtor_partner, currency) + return super()._eligible_for_qr_code( + qr_method, debtor_partner, currency, raises_error=raises_error + ) def _get_qr_code_base64( self, @@ -126,7 +130,9 @@ def _get_qr_code_base64( structured_communication, ) if params and params.pop("payconiq_qr", False): - profile_id = self.env.company.payconiq_qr_profile_id + # Use the company on the record if available, or fall back to env.company + company = self.company_id or self.env.company + profile_id = company.payconiq_qr_profile_id # Build url that would be contained in QR code c_url = PAYCONIQ_URL + profile_id + "?" new_params = { @@ -134,7 +140,9 @@ def _get_qr_code_base64( "s": "S", "c": c_url + urllib.parse.urlencode(params), } - response = requests.get(PAYCONIQ_QR_URL, params=new_params, stream=True) + response = requests.get( + PAYCONIQ_QR_URL, params=new_params, stream=True, timeout=60 + ) raw_image = response.raw img = Image.open(raw_image) @@ -162,7 +170,9 @@ def _check_for_qr_code_errors( structured_communication, ): if qr_method == "payconiq_qr": - if not self.env.company.payconiq_qr_profile_id: + # Use the company on the record if available, or fall back to env.company + company = self.company_id or self.env.company + if not company.payconiq_qr_profile_id: return _( "You should provide a Payconiq Profile Id (Accounting > Settings > " "Customer Payments > QR Codes" diff --git a/account_invoice_qr_code_sepa_payconiq/static/description/index.html b/account_invoice_qr_code_sepa_payconiq/static/description/index.html index 167588d86b7..116e90ecd75 100644 --- a/account_invoice_qr_code_sepa_payconiq/static/description/index.html +++ b/account_invoice_qr_code_sepa_payconiq/static/description/index.html @@ -1,20 +1,20 @@ - - + Account Invoice Qr Code Sepa Payconiq