From 6d8898ada1e2e2ba026209e150b3fb61b6a71406 Mon Sep 17 00:00:00 2001 From: "Abdelouahab (abla)" Date: Tue, 8 Nov 2022 09:51:11 +0000 Subject: [PATCH] [FIX] account : remove QR code generation for credit note MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To Reproduce ============ - enable QR code on Accounting settings - with a customer who has a bank account create a credit note for him/her - in other info tab, make sure that the qr code method is empty - send or print the credit note The Problem =========== the qr code method field will be filled with SEPA, and a QR code will be added to the PDF Solution ======== Generating a QR code for a credit note doesn't make any sense, so the qr code method field must be hidden and no QR code should be generated. opw-3010649 closes odoo/odoo#105385 X-original-commit: 4b0c37833547ff45d2240e51272372a572a920d5 Signed-off-by: William André (wan) --- addons/account/models/account_move.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 499bd3632f5..f8932204a15 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -335,7 +335,7 @@ class AccountMove(models.Model): ) display_qr_code = fields.Boolean( string="Display QR-code", - related='company_id.qr_code', + compute='_compute_display_qr_code', ) qr_code_method = fields.Selection( string="Payment QR-code", copy=False, @@ -1467,6 +1467,14 @@ class AccountMove(models.Model): for res in self.env.cr.dictfetchall() } + @api.depends('company_id') + def _compute_display_qr_code(self): + for record in self: + record.display_qr_code = ( + record.move_type in ('out_invoice', 'out_receipt') + and record.company_id.qr_code + ) + # ------------------------------------------------------------------------- # INVERSE METHODS # ------------------------------------------------------------------------- @@ -3788,8 +3796,8 @@ class AccountMove(models.Model): """ self.ensure_one() - if not self.is_invoice(): - raise UserError(_("QR-codes can only be generated for invoice entries.")) + if not self.display_qr_code: + return None qr_code_method = self.qr_code_method if qr_code_method: