私は最後に発生した請求書を削除できるようにaccount.invoiceからunlinkメソッドをオーバーライドしています。Odoo 10 - unlinkメソッドのオーバーライド
これは私のコードです:
class AccountInvoice(models.Model):
_inherit = "account.invoice"
@api.multi
def unlink(self):
for invoice in self:
if invoice.state not in ('draft', 'cancel'):
raise UserError(('You cannot delete an invoice which is not draft or cancelled. You should refund it instead.'))
elif invoice.move_name:
if invoice.journal_id.sequence_id:
sequence_id = invoice.journal_id.sequence_id
last_assigned_number = sequence_id.next_number_do_not_increase() - 1
last_assigned_number_text = sequence_id.get_next_char(last_assigned_number)
if last_assigned_number_text == invoice.move_name:
invoice.journal_id.sequence_id.write({'number_next': last_assigned_number})
else:
raise UserError(('You cannot delete an invoice after it has been validated (and received a number). You can set it back to "Draft" state and modify its content, then re-confirm it.'))
return super(AccountInvoice, self).unlink()
これまでのところは、
私の具体的な質問が最後の行に良いですが、私はこのコードを実行したときにはそう何UserErrorsはこのルーチンで提起されていない行く流れ、しかし、それはスーパー(AccountInvoice、自己).unlink()が実行され、それは、古いコード形式のaccount_invoice.py reexcutes:エラーが発生します
@api.multi
def unlink(self):
for invoice in self:
if invoice.state not in ('draft', 'cancel'):
raise UserError(_('You cannot delete an invoice which is not draft or cancelled. You should refund it instead.'))
elif invoice.move_name:
raise UserError(_('You cannot delete an invoice after it has been validated (and received a number). You can set it back to "Draft" state and modify its content, then re-confirm it.'))
return super(AccountInvoice, self).unlink()
、私はこれが私のリンクを解除書き換えるべきかをこれは起こらないのですか?
'elif invoice.move_id: – Zety
あなたの質問に間違いを付けることができますか? –