diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 3e25df9127..6a61c52c39 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -293,7 +293,7 @@ class AccountMove(models.Model): invoice_incoterm_id = fields.Many2one('account.incoterms', string='Incoterm', default=_get_default_invoice_incoterm, help='International Commercial Terms are a series of predefined commercial terms used in international transactions.') - display_qr_code = fields.Boolean(string="Display QR-code", related='company_id.qr_code') + display_qr_code = fields.Boolean(string="Display QR-code", compute='_compute_display_qr_code') qr_code_method = fields.Selection(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 will be used.") @@ -2999,6 +2999,14 @@ class AccountMove(models.Model): for move in self: move.has_reconciled_entries = len(move.line_ids._reconciled_lines()) > 1 + @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 + ) + def action_view_reverse_entry(self): self.ensure_one() @@ -3074,8 +3082,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: diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index 1b4725c6bb..80f9903bf0 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -996,7 +996,7 @@ sum="Total Credit" attrs="{'invisible': [('display_type', 'in', ('line_section', 'line_note'))]}"/> - +