diff --git a/invoice.py b/invoice.py index b723642ff8..3a14a598ca 100644 --- a/invoice.py +++ b/invoice.py @@ -989,6 +989,10 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): Date = pool.get('ir.date') for invoice in invoices: + # Posted and paid invoices are tested by check_modify so we can + # not modify tax_identifier nor number + if invoice.state in {'posted', 'paid'}: + continue if not invoice.tax_identifier: invoice.tax_identifier = invoice.get_tax_identifier() diff --git a/tests/scenario_invoice.rst b/tests/scenario_invoice.rst index db8b1370f4..d332fa5c09 100644 --- a/tests/scenario_invoice.rst +++ b/tests/scenario_invoice.rst @@ -310,3 +310,36 @@ Create some complex invoice and test its taxes base rounding:: >>> found_invoice, = Invoice.find([('total_amount', '=', Decimal(0))]) >>> found_invoice.id == invoice.id True + +Clear company tax_identifier:: + + >>> tax_identifier, = company.party.identifiers + >>> tax_identifier.type = None + >>> tax_identifier.save() + +Create a paid invoice:: + + >>> invoice = Invoice() + >>> invoice.party = party + >>> invoice.payment_term = payment_term + >>> line = invoice.lines.new() + >>> line.product = product + >>> line.quantity = 5 + >>> line.unit_price = Decimal('40') + >>> invoice.click('post') + >>> pay = Wizard('account.invoice.pay', [invoice]) + >>> pay.form.journal = journal_cash + >>> pay.execute('choice') + >>> pay.state + 'end' + >>> invoice.tax_identifier + >>> invoice.state + u'paid' + +The invoice is posted when the reconciliation is deleted:: + + >>> invoice.payment_lines[0].reconciliation.delete() + >>> invoice.reload() + >>> invoice.state + u'posted' + >>> invoice.tax_identifier