[IMP] account: remove invoice communication automatic sanitization option

This commit is contained in:
Olivier Colson
2018-09-13 15:17:08 +02:00
committed by De Paoli Quentin
parent d32d2394c2
commit 7da25a9239
5 changed files with 1 additions and 38 deletions
-3
View File
@@ -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()
-21
View File
@@ -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
-1
View File
@@ -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')
+1 -2
View File
@@ -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
@@ -537,17 +537,6 @@
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="account_sanitize_invoice_ref"/>
</div>
<div class="o_setting_right_pane">
<label for="account_sanitize_invoice_ref"/>
<div class="text-muted">
Make sure invoice communications only contain authorized characters.
</div>
</div>
</div>
</div>
<h2 groups="account.group_account_user">Automated Entries</h2>
<div class="row mt16 o_settings_container" id="recommended_apps" groups="account.group_account_user">