Set sii_operation_key when reset SII keys

This commit is contained in:
Raimon Esteve 2017-07-17 10:22:08 +02:00
parent 80a8adc2e9
commit 9b5795a64a
2 changed files with 48 additions and 2 deletions

View File

@ -187,6 +187,8 @@ class Invoice:
to_write = []
for record in records:
record._set_sii_keys()
record.sii_operation_key = ('R1' if record.type in [
'in_credit_note', 'out_credit_note'] else 'F1')
to_write.extend(([record], record._save_values))
if to_write:

View File

@ -21,7 +21,7 @@ Create database::
>>> config = config.set_trytond()
>>> config.pool.test = True
Install account_invoice::
Install account_sii::
>>> Module = Model.get('ir.module')
>>> account_invoice_module, = Module.find(
@ -141,6 +141,50 @@ Create invoice::
>>> invoice.sii_book_key == 'E'
True
>>> invoice.sii_operation_key == 'F1'
True
>>> invoice.click('post')
>>> invoice.state
u'posted'
Create Credit invoice::
>>> invoice = Invoice()
>>> invoice.type = 'out_credit_note'
>>> invoice.party = party
>>> invoice.payment_term = payment_term
>>> line = InvoiceLine()
>>> invoice.lines.append(line)
>>> line.product = product
>>> line.quantity = 5
>>> line.unit_price = Decimal('40')
>>> line = InvoiceLine()
>>> invoice.lines.append(line)
>>> line.account = revenue
>>> line.description = 'Test'
>>> line.quantity = 1
>>> line.unit_price = Decimal(20)
>>> invoice.sii_operation_key = 'R1'
>>> invoice.save()
>>> invoice.sii_book_key
u'E'
>>> invoice.sii_operation_key
u'R1'
>>> invoice.sii_issued_key
u'01'
>>> invoice.sii_book_key = 'I'
>>> invoice.sii_operation_key = 'F2'
>>> invoice.sii_issued_key = '02'
>>> invoice.save()
>>> invoice.reload()
>>> invoice.click('reset_sii_keys')
>>> invoice.reload()
>>> invoice.sii_book_key == 'E'
True
>>> invoice.sii_operation_key == 'R1'
True
>>> invoice.click('post')
>>> invoice.state
u'posted'
@ -158,4 +202,4 @@ Create AEAT Report::
u'draft'
>>> report.click('load_invoices')
>>> len(report.lines)
1
2