Merged in pokoli/trytond-aeat_sii/credit_invoice_fix (pull request #33)
Use invoice object when crediting an invoice
This commit is contained in:
commit
984e061d68
|
@ -160,12 +160,12 @@ class Invoice:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _credit(self):
|
def _credit(self):
|
||||||
res = super(Invoice, self)._credit()
|
credit = super(Invoice, self)._credit()
|
||||||
for field in _SII_INVOICE_KEYS:
|
for field in _SII_INVOICE_KEYS:
|
||||||
res[field] = getattr(self, field)
|
setattr(credit, field, getattr(self, field))
|
||||||
|
|
||||||
res['sii_operation_key'] = 'R4'
|
credit.sii_operation_key = 'R4'
|
||||||
return res
|
return credit
|
||||||
|
|
||||||
def _set_sii_keys(self):
|
def _set_sii_keys(self):
|
||||||
tax = self.taxes and self.taxes[0]
|
tax = self.taxes and self.taxes[0]
|
||||||
|
|
|
@ -194,3 +194,16 @@ Create AEAT Report::
|
||||||
>>> report.click('load_invoices')
|
>>> report.click('load_invoices')
|
||||||
>>> len(report.lines)
|
>>> len(report.lines)
|
||||||
2
|
2
|
||||||
|
|
||||||
|
|
||||||
|
Credit invoice with refund::
|
||||||
|
|
||||||
|
>>> credit = Wizard('account.invoice.credit', [invoice])
|
||||||
|
>>> credit.form.with_refund = True
|
||||||
|
>>> credit.execute('credit')
|
||||||
|
>>> invoice.reload()
|
||||||
|
>>> invoice.state
|
||||||
|
'paid'
|
||||||
|
>>> credit, = Invoice.find([('total_amount', '<', 0)])
|
||||||
|
>>> credit.sii_operation_key
|
||||||
|
'R1'
|
||||||
|
|
Loading…
Reference in New Issue