From 7da25a9239a2e0c7f8ca704ce3e9d53414702db3 Mon Sep 17 00:00:00 2001 From: Olivier Colson Date: Thu, 13 Sep 2018 13:10:13 +0200 Subject: [PATCH] [IMP] account: remove invoice communication automatic sanitization option --- addons/account/models/account_invoice.py | 3 --- addons/account/models/account_payment.py | 21 ------------------- addons/account/models/company.py | 1 - addons/account/models/res_config_settings.py | 3 +-- .../views/res_config_settings_views.xml | 11 ---------- 5 files changed, 1 insertion(+), 38 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 4c2f73b3396..70ef1efe226 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -893,9 +893,6 @@ class AccountInvoice(models.Model): raise UserError(_("You cannot validate an invoice with a negative total amount. You should create a credit note instead.")) if to_open_invoices.filtered(lambda inv: not inv.account_id): raise UserError(_('No account was found to create the invoice, be sure you have installed a chart of account.')) - for record in to_open_invoices: - if record.company_id.account_sanitize_invoice_ref and record.reference: - record.reference = self.env['account.payment']._sanitize_communication(record.reference) to_open_invoices.action_date_assign() to_open_invoices.action_move_create() return to_open_invoices.invoice_validate() diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 1a967e7eea6..4d0830b1737 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -5,7 +5,6 @@ from odoo.exceptions import UserError, ValidationError from odoo.tools import float_compare from itertools import groupby -import re MAP_INVOICE_TYPE_PARTNER_TYPE = { @@ -806,23 +805,3 @@ class account_payment(models.Model): }) return vals - - @api.model - def _sanitize_communication(self, communication): - """ Returns a sanitized version of the communication given in parameter, - so that: - - it contains only latin characters - - it does not contain any // - - it does not start or end with / - - it is maximum 140 characters long - (these are the SEPA compliance criteria) - """ - communication = communication[:140] - while '//' in communication: - communication = communication.replace('//', '/') - if communication.startswith('/'): - communication = communication[1:] - if communication.endswith('/'): - communication = communication[:-1] - communication = re.sub('[^-A-Za-z0-9/?:().,\'+ ]', '', communication) - return communication diff --git a/addons/account/models/company.py b/addons/account/models/company.py index a01e6916060..48e4fb9dd90 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -65,7 +65,6 @@ Best Regards,''')) 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='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') qr_code_payment_journal_id = fields.Many2one('account.journal', string='SEPA QR Code Bank Journal account') diff --git a/addons/account/models/res_config_settings.py b/addons/account/models/res_config_settings.py index 438393ca020..07b1f3dc92f 100644 --- a/addons/account/models/res_config_settings.py +++ b/addons/account/models/res_config_settings.py @@ -81,12 +81,11 @@ class ResConfigSettings(models.TransientModel): help="""The bank reconciliation widget won't ask to reconcile payments older than this date. This is useful if you install accounting after having used invoicing for some time and don't want to reconcile all the past payments with bank statements.""") - account_sanitize_invoice_ref = fields.Boolean(string="Sanitize Invoice References", related='company_id.account_sanitize_invoice_ref', help="If checked, customer invoices' and vendor bills' referneces will automatically correct their reference so that they are maximum 140 characters long, consist only of latin characters, contain no '//' sequence, and have no leading or trailing /.") qr_code = fields.Boolean(string='Display SEPA QR code', related='company_id.qr_code') qr_code_payment_journal_id = fields.Many2one('account.journal', related='company_id.qr_code_payment_journal_id', string="Payment Journal", domain="['&',('type', '=', 'bank'), ('currency_id.name','=','EUR')]") qr_code_valid = fields.Boolean(string='Has all required arguments', related="qr_code_payment_journal_id.bank_account_id.qr_code_valid") - invoice_is_print = fields.Boolean(string='Print', related='company_id.invoice_is_print') + invoice_is_print = fields.Boolean(string='Print', related='company_id.invoice_is_print') invoice_is_email = fields.Boolean(string='Send Email', related='company_id.invoice_is_email') @api.multi diff --git a/addons/account/views/res_config_settings_views.xml b/addons/account/views/res_config_settings_views.xml index f39eb4c3a82..d3107e75de4 100644 --- a/addons/account/views/res_config_settings_views.xml +++ b/addons/account/views/res_config_settings_views.xml @@ -537,17 +537,6 @@ -
-
- -
-
-
-

Automated Entries