From 83f1d94de13a0897fbf7e0896855a6959a2cabb5 Mon Sep 17 00:00:00 2001 From: Parthiv Patel Date: Tue, 8 Nov 2022 08:35:07 +0000 Subject: [PATCH] [PATCH] Upstream patch - 08112022 --- addons/account/models/account_move.py | 14 ++++++-- addons/account/views/account_move_views.xml | 2 +- .../wizard/account_payment_register.py | 4 +-- addons/base_vat/models/res_partner.py | 1 + addons/calendar/models/calendar_event.py | 1 + addons/calendar_sms/data/sms_data.xml | 2 +- .../l10n_it_edi/data/invoice_it_template.xml | 2 +- addons/l10n_it_edi/views/l10n_it_view.xml | 2 +- .../expected_xmls/reverse_charge_bill.xml | 2 +- addons/mrp/models/stock_move.py | 2 +- addons/mrp/tests/test_order.py | 24 +++++++++++++ addons/sale_coupon/models/sale_order.py | 4 +++ .../sale_coupon/tests/test_sale_invoicing.py | 35 +++++++++++++++++++ addons/snailmail/models/snailmail_letter.py | 9 +++-- addons/stock_account/models/stock_move.py | 4 +-- addons/web/static/src/js/core/ajax.js | 21 ++++++++--- .../static/src/js/fields/relational_fields.js | 7 ++-- .../web/static/src/scss/daterangepicker.scss | 2 ++ .../web/static/tests/helpers/mock_server.js | 6 ++-- 19 files changed, 119 insertions(+), 25 deletions(-) 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'))]}"/> - +