Avoid override invoices variable when search other invoices

The invoices list should not be modified because it is saved at the end of the method.

issue8724
review286051003
This commit is contained in:
Cédric Krier committed 2019-10-24 19:06:04 +02:00
1 parent b03f7ee36d
commit 175ec95a49
1 file changed
+3 -3
+3 -3
View File
@@ -1012,7 +1012,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
date = accounting_date(invoice)
# Do not need to lock the table
# because sequence.get_id is sequential
invoices = cls.search([
after_invoices = cls.search([
('sequence', '=', invoice.sequence.id),
['OR',
('accounting_date', '>', date),
@@ -1022,8 +1022,8 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
],
],
], limit=1)
if invoices:
after_invoice, = invoices
if after_invoices:
after_invoice, = after_invoices
raise InvoiceNumberError(
gettext('account_invoice.msg_invoice_number_after',
invoice=invoice.rec_name,