From 0a101226f9e1f32c2f1491ab24714ddbc30c3cd9 Mon Sep 17 00:00:00 2001 From: "Abdelouahab (abla)" Date: Thu, 28 Jul 2022 14:10:46 +0000 Subject: [PATCH] [FIX] account : remove QR code method for credit note To reproduce ============ Enable "Qr Codes" under Accounting Settinsgs > Create Invoice > set "Payment QR-code" method (tab "More Info") > issue Credit Note > try to "Send and Print" credit note > Error: ` The chosen QR-code type is not eligible for this invoice. ` Specification ============= Generating QR code on Credit Note doesn't make sense, so the field `qr_code_method` is set to `False` when creating a Credit Note. opw-2900112 closes odoo/odoo#97889 X-original-commit: cdc564d8b31d7691bb1a6faaef940bc5fd3eb8f0 Signed-off-by: Josse Colpaert Signed-off-by: abla001 --- addons/account/models/account_move.py | 2 +- .../account_qr_code_sepa/tests/test_sepa_qr.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 45fab7a6bb4..e2baf6ee0b4 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -340,7 +340,7 @@ class AccountMove(models.Model): related='company_id.qr_code', ) qr_code_method = fields.Selection( - string="Payment QR-code", + string="Payment QR-code", copy=False, selection=lambda self: self.env['res.partner.bank'].get_available_qr_methods_in_sequence(), help="Type of QR-code to be generated for the payment of this invoice, " "when printing it. If left blank, the first available and usable method " diff --git a/addons/account_qr_code_sepa/tests/test_sepa_qr.py b/addons/account_qr_code_sepa/tests/test_sepa_qr.py index 025b6a5e42a..785361500c1 100644 --- a/addons/account_qr_code_sepa/tests/test_sepa_qr.py +++ b/addons/account_qr_code_sepa/tests/test_sepa_qr.py @@ -3,7 +3,7 @@ from odoo.exceptions import UserError from odoo.addons.account.tests.common import AccountTestInvoicingCommon from odoo.tests import tagged - +from odoo import fields @tagged('post_install', '-at_install') class TestSEPAQRCode(AccountTestInvoicingCommon): @@ -62,3 +62,17 @@ class TestSEPAQRCode(AccountTestInvoicingCommon): """ self.sepa_qr_invoice._generate_qr_code() self.assertEqual(self.sepa_qr_invoice.qr_code_method, 'sct_qr', "SEPA QR-code generator should have been chosen for this invoice.") + + def test_out_invoice_create_refund_qr_code(self): + self.sepa_qr_invoice._generate_qr_code() + self.sepa_qr_invoice.action_post() + move_reversal = self.env['account.move.reversal'].with_context(active_model="account.move", active_ids=self.sepa_qr_invoice.ids).create({ + 'date': fields.Date.from_string('2019-02-01'), + 'reason': 'no reason', + 'refund_method': 'refund', + 'journal_id': self.sepa_qr_invoice.journal_id.id, + }) + reversal = move_reversal.reverse_moves() + reverse_move = self.env['account.move'].browse(reversal['res_id']) + + self.assertFalse(reverse_move.qr_code_method, "qr_code_method for credit note should be None")