[IMP] a_i_c_chronology: better check for previously validated invoices
This commit is contained in:
parent
cda5bc8b9c
commit
d6efba2b6e
@ -9,10 +9,9 @@ from odoo.exceptions import UserError
|
|||||||
class account_invoice(models.Model):
|
class account_invoice(models.Model):
|
||||||
_inherit = "account.invoice"
|
_inherit = "account.invoice"
|
||||||
|
|
||||||
already_validated = fields.Boolean(readonly=True, copy=False)
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_move_create(self):
|
def action_move_create(self):
|
||||||
|
previously_validated = self.filtered(lambda inv: inv.move_name)
|
||||||
res = super(account_invoice, self).action_move_create()
|
res = super(account_invoice, self).action_move_create()
|
||||||
for inv in self:
|
for inv in self:
|
||||||
if inv.journal_id.check_chronology:
|
if inv.journal_id.check_chronology:
|
||||||
@ -33,7 +32,7 @@ class account_invoice(models.Model):
|
|||||||
"Please confirm older draft "
|
"Please confirm older draft "
|
||||||
"invoices before %s and try again.")
|
"invoices before %s and try again.")
|
||||||
% date_invoice_tz)
|
% date_invoice_tz)
|
||||||
if not inv.already_validated:
|
if inv not in previously_validated:
|
||||||
invoices = self.search([('state', 'in', ['open', 'paid']),
|
invoices = self.search([('state', 'in', ['open', 'paid']),
|
||||||
('date_invoice', '>',
|
('date_invoice', '>',
|
||||||
inv.date_invoice),
|
inv.date_invoice),
|
||||||
@ -50,6 +49,4 @@ class account_invoice(models.Model):
|
|||||||
"There exist at least one invoice "
|
"There exist at least one invoice "
|
||||||
"with a date posterior to %s.") %
|
"with a date posterior to %s.") %
|
||||||
date_invoice_tz)
|
date_invoice_tz)
|
||||||
if not inv.already_validated:
|
|
||||||
inv.already_validated = True
|
|
||||||
return res
|
return res
|
||||||
|
Loading…
Reference in New Issue
Block a user