From ef42e03b69307a90d67b46ce9858065fd2c1ce1a Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Tue, 14 Aug 2018 14:44:11 +0200 Subject: [PATCH] [IMP] sale: add reference on SO + improve usability Like invoices, a reference is now computed on sales orders. The configuration of such reference is done through the Wire Transfer acquirer. The usability of the communication feature (on invoices/SO) has been a bit improved to be more clear. Was task: 1870121 Was PR #26152 --- addons/account/models/account_invoice.py | 6 ++-- addons/account/models/company.py | 4 +-- .../views/res_config_settings_views.xml | 4 +-- .../views/account_portal_templates.xml | 4 +++ addons/payment/models/payment_acquirer.py | 4 +-- .../views/payment_portal_templates.xml | 9 +++++ addons/sale/models/payment.py | 36 +++++++++++++++---- addons/sale/models/sale.py | 5 +++ addons/sale/views/payment_views.xml | 11 ++++++ addons/sale/views/sale_views.xml | 1 + addons/website_sale/views/templates.xml | 3 ++ 11 files changed, 72 insertions(+), 15 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index a64d0c906a2..9f2d770db36 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -248,8 +248,8 @@ class AccountInvoice(models.Model): move_name = fields.Char(string='Journal Entry Name', readonly=False, default=False, copy=False, help="Technical field holding the number given to the invoice, automatically set when the invoice is validated then stored to set the same number again if the invoice is cancelled, set to draft and re-validated.") - reference = fields.Char(string='Payment Ref.', copy=False, - help="The partner reference of this invoice.", readonly=True, states={'draft': [('readonly', False)]}) + reference = fields.Char(string='Payment Ref.', copy=False, readonly=True, states={'draft': [('readonly', False)]}, + help='The payment communication that will be automatically populated once the invoice validation. You can also write a free communication.') comment = fields.Text('Additional Information', readonly=True, states={'draft': [('readonly', False)]}) state = fields.Selection([ @@ -1270,7 +1270,7 @@ class AccountInvoice(models.Model): invoice.message_subscribe([invoice.partner_id.id]) # Auto-compute reference, if not already existing and if configured on company - if not invoice.reference and invoice.company_id.invoice_reference_type != 'none' and invoice.type == 'out_invoice': + if not invoice.reference and invoice.type == 'out_invoice': invoice.reference = invoice._get_computed_reference() self._check_duplicate_supplier_reference() diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 34cdf0738ec..19994b2335a 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -16,7 +16,7 @@ class ResCompany(models.Model): _inherit = "res.company" def _get_invoice_reference_types(self): - return [('invoice_number', _('Based on Invoice Number')), ('partner', _('Based on Partner')), ('none', _('Free Communication'))] + return [('invoice_number', _('Based on Invoice Number')), ('partner', _('Based on Customer'))] #TODO check all the options/fields are in the views (settings + company form view) fiscalyear_last_day = fields.Integer(default=31, required=True) @@ -64,7 +64,7 @@ Best Regards,''')) incoterm_id = fields.Many2one('account.incoterms', string='Default incoterm', help='International Commercial Terms are a series of predefined commercial terms used in international transactions.') invoice_reference_type = fields.Selection(string='Default Communication Type', selection='_get_invoice_reference_types', - default='none', help='You can set here the default communication that will appear on customer invoices, once validated, to help the customer to refer to that particular invoice when making the payment.') + default='invoice_number', help='You can set here the default communication that will appear on customer invoices, once validated, to help the customer to refer to that particular invoice when making the payment.') account_sanitize_invoice_ref = fields.Boolean(string="Sanitize Invoice References", default=True, help="Whether or not customer invoices and vendor bills should automatically correct their reference they are maximum 140 characters long, consist only of latin characters, contain no '//' sequence, and have no leading or trailing /. (these are the SEPA criteria for payment communications)") qr_code = fields.Boolean(string='Display SEPA QR code') diff --git a/addons/account/views/res_config_settings_views.xml b/addons/account/views/res_config_settings_views.xml index 6158e088d3f..f1386783400 100644 --- a/addons/account/views/res_config_settings_views.xml +++ b/addons/account/views/res_config_settings_views.xml @@ -261,10 +261,10 @@