Control when cancel invoices if the cancel order came from credit function. In this case permit cancel invoice instead it has a number
This commit is contained in:
parent
4c6ddc6cc8
commit
8ae1189204
18
invoice.py
18
invoice.py
|
@ -63,14 +63,20 @@ class Invoice(metaclass=PoolMeta):
|
|||
with Transaction().set_context(draft_invoices=True):
|
||||
return super(Invoice, cls).draft(invoices)
|
||||
|
||||
@classmethod
|
||||
def credit(cls, invoices, refund=False):
|
||||
with Transaction().set_context(cancel_from_credit=True):
|
||||
return super().credit(invoices, refund)
|
||||
|
||||
@classmethod
|
||||
def cancel(cls, invoices):
|
||||
for invoice in invoices:
|
||||
if invoice.type == 'out' and invoice.number:
|
||||
raise UserError(
|
||||
gettext('account_invoice_posted2draft.'
|
||||
'msg_cancel_invoice_with_number',
|
||||
invoice=invoice.rec_name))
|
||||
if not Transaction().context.get('cancel_from_credit', False):
|
||||
for invoice in invoices:
|
||||
if invoice.type == 'out' and invoice.number:
|
||||
raise UserError(
|
||||
gettext('account_invoice_posted2draft.'
|
||||
'msg_cancel_invoice_with_number',
|
||||
invoice=invoice.rec_name))
|
||||
return super(Invoice, cls).cancel(invoices)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue