Add tax identifier on invoice
Some companies have more than one tax identifier, so this provides a way to define which one to print on the invoice. issue5998 review28961002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Add tax identifier on invoice
|
||||
* Rename Invoice.create_move to get_move
|
||||
* Rename InvoiceLine and InvoiceTax get_move_line to get_move_lines
|
||||
* Change Invoice.set_number into classmethod
|
||||
|
||||
@@ -11,6 +11,8 @@ There are 4 types of invoice: *Invoice*, *Supplier Invoice*, *Credit Note* and
|
||||
*Paid* or *Canceled*.
|
||||
|
||||
- Company: The company for which the invoice is created.
|
||||
- Tax Identifier: The tax identifier that will be printed on the invoice
|
||||
(By default the first tax identifier of the company).
|
||||
- Number: The invoice number set on validation for supplier invoices and on
|
||||
posting for others using the sequence defined on the period or fiscal year.
|
||||
- Reference: The internal reference of the invoice.
|
||||
|
||||
BIN
Binary file not shown.
+33
@@ -75,6 +75,16 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
depends=_DEPENDS)
|
||||
company_party = fields.Function(
|
||||
fields.Many2One('party.party', "Company Party"),
|
||||
'on_change_with_company_party')
|
||||
tax_identifier = fields.Many2One(
|
||||
'party.identifier', "Tax Identifier",
|
||||
states=_STATES,
|
||||
domain=[
|
||||
('party', '=', Eval('company_party', -1)),
|
||||
],
|
||||
depends=_DEPENDS + ['company_party'])
|
||||
type = fields.Selection(_TYPE, 'Type', select=True,
|
||||
required=True, states={
|
||||
'readonly': ((Eval('state') != 'draft')
|
||||
@@ -192,6 +202,10 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
('number', 'DESC'),
|
||||
('id', 'DESC'),
|
||||
]
|
||||
cls.tax_identifier.domain = [
|
||||
cls.tax_identifier.domain,
|
||||
('type', 'in', cls._tax_identifier_types()),
|
||||
]
|
||||
cls._error_messages.update({
|
||||
'missing_tax_line': ('Invoice "%s" has taxes defined but not '
|
||||
'on invoice lines.\nRe-compute the invoice.'),
|
||||
@@ -399,6 +413,11 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
||||
@fields.depends('company')
|
||||
def on_change_with_company_party(self, name=None):
|
||||
if self.company:
|
||||
return self.company.party.id
|
||||
|
||||
@classmethod
|
||||
def default_payment_term(cls):
|
||||
PaymentTerm = Pool().get('account.invoice.payment_term')
|
||||
@@ -970,6 +989,9 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
Date = pool.get('ir.date')
|
||||
|
||||
for invoice in invoices:
|
||||
if not invoice.tax_identifier:
|
||||
invoice.tax_identifier = invoice.get_tax_identifier()
|
||||
|
||||
if invoice.number:
|
||||
continue
|
||||
|
||||
@@ -1000,6 +1022,17 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
invoice.invoice_date = Transaction().context['date']
|
||||
cls.save(invoices)
|
||||
|
||||
@classmethod
|
||||
def _tax_identifier_types(cls):
|
||||
return ['eu_vat']
|
||||
|
||||
def get_tax_identifier(self):
|
||||
"Return the default computed tax identifier"
|
||||
types = self._tax_identifier_types()
|
||||
for identifier in self.company.party.identifiers:
|
||||
if identifier.type in types:
|
||||
return identifier.id
|
||||
|
||||
@classmethod
|
||||
def check_modify(cls, invoices):
|
||||
'''
|
||||
|
||||
@@ -25,6 +25,10 @@ Create company::
|
||||
|
||||
>>> _ = create_company()
|
||||
>>> company = get_company()
|
||||
>>> tax_identifier = company.party.identifiers.new()
|
||||
>>> tax_identifier.type = 'eu_vat'
|
||||
>>> tax_identifier.code = 'BE0897290877'
|
||||
>>> company.party.save()
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
@@ -144,6 +148,8 @@ Post invoice::
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
u'posted'
|
||||
>>> invoice.tax_identifier.code
|
||||
u'BE0897290877'
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('220.00')
|
||||
>>> invoice.tax_amount
|
||||
|
||||
@@ -64,7 +64,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<page string="Other Info" id="info">
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<newline/>
|
||||
<label name="tax_identifier"/>
|
||||
<field name="tax_identifier"/>
|
||||
<label name="account"/>
|
||||
<field name="account"/>
|
||||
<label name="accounting_date"/>
|
||||
|
||||
Reference in New Issue
Block a user