Skip to content

Commit

Permalink
ADD TD20 doc type (#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 Dec 13, 2018
1 parent bb7c407 commit 4057bfa
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion l10n_it_fatturapa_out/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
'name': 'Italian Localization - Fattura elettronica - Emissione',
'version': '12.0.1.0.0',
'version': '12.0.1.0.1',
'development_status': 'Beta',
'category': 'Localization/Italy',
'summary': 'Emissione fatture elettroniche',
Expand Down
4 changes: 1 addition & 3 deletions l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,7 @@ def setDatiGeneraliDocumento(self, invoice, body):
raise UserError(
_('Invoice does not have a number.'))

TipoDocumento = 'TD01'
if invoice.type == 'out_refund':
TipoDocumento = 'TD04'
TipoDocumento = invoice.fiscal_document_type_id.code
ImportoTotaleDocumento = invoice.amount_total
if invoice.split_payment:
ImportoTotaleDocumento += invoice.amount_sp
Expand Down
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 4057bfa

Please sign in to comment.