Test invoice sequence before accessing id
issue3199
This commit is contained in:
1 parent
7e5850998a
commit
e65e63990c
1 file changed
+3
-3
+3
-3
@@ -909,15 +909,15 @@ class Invoice(Workflow, ModelSQL, ModelView):
|
|||||||
period_id = Period.find(self.company.id,
|
period_id = Period.find(self.company.id,
|
||||||
date=accounting_date, test_state=test_state)
|
date=accounting_date, test_state=test_state)
|
||||||
period = Period(period_id)
|
period = Period(period_id)
|
||||||
sequence_id = period.get_invoice_sequence(self.type).id
|
sequence = period.get_invoice_sequence(self.type)
|
||||||
if not sequence_id:
|
if not sequence:
|
||||||
self.raise_user_error('no_invoice_sequence', {
|
self.raise_user_error('no_invoice_sequence', {
|
||||||
'invoice': self.rec_name,
|
'invoice': self.rec_name,
|
||||||
'period': period.rec_name,
|
'period': period.rec_name,
|
||||||
})
|
})
|
||||||
with Transaction().set_context(
|
with Transaction().set_context(
|
||||||
date=self.invoice_date or Date.today()):
|
date=self.invoice_date or Date.today()):
|
||||||
number = Sequence.get_id(sequence_id)
|
number = Sequence.get_id(sequence.id)
|
||||||
vals = {'number': number}
|
vals = {'number': number}
|
||||||
if (not self.invoice_date
|
if (not self.invoice_date
|
||||||
and self.type in ('out_invoice', 'out_credit_note')):
|
and self.type in ('out_invoice', 'out_credit_note')):
|
||||||
|
|||||||
Reference in new issue
Block a user