Skip to content

Commit

Permalink
ADD TD20 doc type (OCA#725)
Browse files Browse the repository at this point in the history
IMP l10n_it_fiscal_document_type to be sure that doc type is always set
FIX l10n_it_fatturapa_out to use the fiscal doc type
  • Loading branch information
eLBati authored and TheMule71 committed Nov 2, 2022
1 parent 4b9f9f1 commit a7b0701
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion l10n_it_fiscal_document_type/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
'name': 'Italian Localization - '
'Tipi di documento fiscale per dichiarativi',
'version': '12.0.1.0.0',
'version': '12.0.1.1.0',
'category': 'Localisation/Italy',
'author': "Link It srl, Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/l10n-italy/tree/12.0/'
Expand Down
1 change: 1 addition & 0 deletions l10n_it_fiscal_document_type/data/fiscal.document.type.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ id,code,name,out_invoice,in_invoice,out_refund,in_refund,priority
6,TD10,fattura di acquisto intracomunitario beni,False,True,False,False,3
7,TD11,fattura di acquisto intracomunitario servizi,False,True,False,False,3
8,TD12,documento riepilogativo,False,True,False,False,3
13,TD20,autofattura,True,False,False,False,3
11 changes: 11 additions & 0 deletions l10n_it_fiscal_document_type/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ def _set_document_fiscal_type(self):
if dt:
self.fiscal_document_type_id = dt[0]

@api.model
def create(self, vals):
invoice = super(AccountInvoice, self).create(vals)
if not invoice.fiscal_document_type_id:
dt = self._get_document_fiscal_type(
invoice.type, invoice.partner_id, invoice.fiscal_position_id,
invoice.journal_id)
if dt:
invoice.fiscal_document_type_id = dt[0]
return invoice

def _get_document_fiscal_type(self, type=None, partner=None,
fiscal_position=None, journal=None):
dt = []
Expand Down
5 changes: 5 additions & 0 deletions l10n_it_fiscal_document_type/tests/test_doc_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ def test_doc_type(self):
})
invoice._set_document_fiscal_type()
self.assertEqual(invoice.fiscal_document_type_id.id, self.TD01.id)

invoice2 = self.inv_model.create({
'partner_id': self.partner3.id
})
self.assertEqual(invoice2.fiscal_document_type_id.id, self.TD01.id)

0 comments on commit a7b0701

Please sign in to comment.