diff --git a/l10n_it_fiscal_document_type/__manifest__.py b/l10n_it_fiscal_document_type/__manifest__.py index 02cfbd88332b..da7221a8d2fe 100644 --- a/l10n_it_fiscal_document_type/__manifest__.py +++ b/l10n_it_fiscal_document_type/__manifest__.py @@ -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/' diff --git a/l10n_it_fiscal_document_type/data/fiscal.document.type.csv b/l10n_it_fiscal_document_type/data/fiscal.document.type.csv index e4b74452cce1..cfed78e41f7f 100755 --- a/l10n_it_fiscal_document_type/data/fiscal.document.type.csv +++ b/l10n_it_fiscal_document_type/data/fiscal.document.type.csv @@ -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 diff --git a/l10n_it_fiscal_document_type/models/account_invoice.py b/l10n_it_fiscal_document_type/models/account_invoice.py index b4079f054b73..2b84d0f4566d 100755 --- a/l10n_it_fiscal_document_type/models/account_invoice.py +++ b/l10n_it_fiscal_document_type/models/account_invoice.py @@ -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 = [] diff --git a/l10n_it_fiscal_document_type/tests/test_doc_type.py b/l10n_it_fiscal_document_type/tests/test_doc_type.py index 8e9fb03ae84d..c9d808c45e69 100644 --- a/l10n_it_fiscal_document_type/tests/test_doc_type.py +++ b/l10n_it_fiscal_document_type/tests/test_doc_type.py @@ -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)