From 5513035b91f62ad72dea3e4d5b2cff07045189be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 26 Sep 2017 01:23:42 +0200 Subject: [PATCH] Add party tax identifier on invoice When setting the number, if no tax identifier is defined, the default one is filled. issue6733 review40601002 --- CHANGELOG | 2 ++ doc/index.rst | 1 + invoice.fodt | 22 +++++++++++----------- invoice.py | 11 +++++++++++ view/invoice_form.xml | 3 ++- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a908678d34..b463934bd3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Add party tax identifier on invoice + Version 4.4.0 - 2017-05-01 * Bug fixes (see mercurial logs for details) * Use Match pattern for invoice sequences diff --git a/doc/index.rst b/doc/index.rst index 12d2148a2f..d8a4ec55bc 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -18,6 +18,7 @@ There are 4 types of invoice: *Invoice*, *Supplier Invoice*, *Credit Note* and - Reference: The optional external reference of the invoice. - Party: The party for which or from which the invoice is issued. - Invoice Address: The address of the party. +- Party Tax Identifier: The tax identifier of the party. - Description: An optional description of the invoice. - Comment: A text fields to add custom comments. - Invoice Date: The date of the invoice. It is set on posting the invoice if not. diff --git a/invoice.fodt b/invoice.fodt index bac7e5dd25..21b03e8928 100644 --- a/invoice.fodt +++ b/invoice.fodt @@ -4,9 +4,9 @@ LibreOffice/5.2.7.2$Linux_X86_64 LibreOffice_project/20m0$Build-22012-11-15T15:00:351P0D - 0 + 1880 0 - 48623 + 48622 23834 true false @@ -14,11 +14,11 @@ view2 26797 - 5313 + 11642 0 - 0 - 48622 - 23832 + 1880 + 48620 + 25712 0 1 false @@ -69,7 +69,7 @@ false false true - 2153615 + 2254801 false true false @@ -541,7 +541,7 @@ - + @@ -592,13 +592,13 @@ - <replace text:p="set_lang(invoice.party.lang and invoice.party.lang.code or 'en')"> + <replace text:p="set_lang(invoice.party.lang and invoice.party.lang.code or 'en')"> <replace text:p="invoice.set_lang(invoice.party.lang and invoice.party.lang.code or 'en')"> <for each="line in invoice.invoice_address.full_address.split('\n')"> <line> </for> - <if test="invoice.party.tax_identifier"> - <invoice.party.tax_identifier.type_string>: <invoice.party.tax_identifier.code> + <if test="invoice.party_tax_identifier"> + <invoice.party_tax_identifier.type_string>: <invoice.party_tax_identifier.code> </if> <if test="invoice.type == 'in'"> Supplier Invoice N°:<invoice.number and ' ' + invoice.number or ''> diff --git a/invoice.py b/invoice.py index ce3edc09c4..57b531d2b3 100644 --- a/invoice.py +++ b/invoice.py @@ -111,6 +111,13 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): depends=_DEPENDS) party = fields.Many2One('party.party', 'Party', required=True, states=_STATES, depends=_DEPENDS) + party_tax_identifier = fields.Many2One( + 'party.identifier', "Party Tax Identifier", + states=_STATES, + domain=[ + ('party', '=', Eval('party', -1)), + ], + depends=_DEPENDS + ['party']) party_lang = fields.Function(fields.Char('Party Language'), 'on_change_with_party_lang') invoice_address = fields.Many2One('party.address', 'Invoice Address', @@ -461,6 +468,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): if self.party: self.invoice_address = self.party.address_get(type='invoice') + self.party_tax_identifier = self.party.tax_identifier @fields.depends('currency') def on_change_with_currency_digits(self, name=None): @@ -996,6 +1004,9 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): continue if not invoice.tax_identifier: invoice.tax_identifier = invoice.get_tax_identifier() + # Generated invoice may not fill the party tax identifier + if not invoice.party_tax_identifier: + invoice.party_tax_identifier = invoice.party.tax_identifier if invoice.number: continue diff --git a/view/invoice_form.xml b/view/invoice_form.xml index 346759f9ee..be4f4b76a6 100644 --- a/view/invoice_form.xml +++ b/view/invoice_form.xml @@ -12,7 +12,8 @@ this repository contains the full copyright notices and license terms. -->