Skip to content

Commit

Permalink
Rename to l10n_it_invoices_data_communication
Browse files Browse the repository at this point in the history
Improve meta data
ADD setup dir

IMP l10n_it_invoices_data_communication using english and making terms translatable
Increase version
REF some methods
FIX Detraibile amount in case of supplier invoices
  • Loading branch information
eLBati authored and OCA-git-bot committed Jun 21, 2019
1 parent 1bc6b23 commit a45b073
Show file tree
Hide file tree
Showing 24 changed files with 3,776 additions and 0 deletions.
108 changes: 108 additions & 0 deletions l10n_it_invoices_data_communication/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
=================================================
Italian Localization - Comunicazione dati fatture
=================================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-italy/tree/10.0/l10n_it_invoices_data_communication
:alt: OCA/l10n-italy
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-italy-10-0/l10n-italy-10-0-l10n_it_invoices_data_communication
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/122/10.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

**Italiano**

Gestione Comunicazione dati fatture ed export file XML conforme alle specifiche dell'Agenzia delle Entrate.

Riferimento: https://bit.ly/2N2Rhv8

**English**

Invoices data comunication and XML file export, compliant to specifications of Revenue Agency.

Reference: https://bit.ly/2N2Rhv8

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

Qualora questo modulo venisse installato in un DB dove ``l10n_it_comunicazione_dati_iva`` è già installato, è necessario eseguire la sequente procedura:

1. Installare ``openupgradelib``
#. Lanciare odoo con il paramentro ``shell``
#. Eseguire i seguenti comandi

>>> from openupgradelib import openupgrade
>>> openupgrade.update_module_names(env.cr, [('l10n_it_comunicazione_dati_iva', 'l10n_it_invoices_data_communication'),], merge_modules=False,)
>>> env.cr.commit()

4. Riavviare odoo
#. Aggiornare ``l10n_it_invoices_data_communication``

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_invoices_data_communication%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Openforce di Camilli Alessandro

Contributors
~~~~~~~~~~~~

* Alessandro Camilli
* Lorenzo Battistini
* Francesco Apruzzese

Other credits
~~~~~~~~~~~~~

The development of this module has been financially supported by:

* Odoo Italia Network

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/10.0/l10n_it_invoices_data_communication>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions l10n_it_invoices_data_communication/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-

from . import models
from . import wizard
31 changes: 31 additions & 0 deletions l10n_it_invoices_data_communication/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Alessandro Camilli - Openforce
# Copyright 2017-2019 Lorenzo Battistini
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

{
'name': 'Italian Localization - Comunicazione dati fatture',
'summary': 'Comunicazione dati fatture (c.d. "nuovo spesometro" o '
'"esterometro")',
'version': '10.0.1.1.0',
'category': 'Account',
'author': "Openforce di Camilli Alessandro, "
"Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/l10n-italy/',
'license': 'LGPL-3',
'depends': [
'account', 'l10n_it_fiscal_document_type', 'l10n_it_codici_carica',
'l10n_it_fiscalcode', 'l10n_it_esigibilita_iva',
'l10n_it_account_tax_kind', 'report_intrastat'
],
'data': [
'security/ir.model.access.csv',
'wizard/compute_fiscal_document_type_view.xml',
'views/comunicazione.xml',
'views/account.xml',
'views/account_invoice_view.xml',
'wizard/export_file_view.xml',
'security/security.xml',
],
'installable': True,
}
3 changes: 3 additions & 0 deletions l10n_it_invoices_data_communication/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import communication, account_invoice, account
11 changes: 11 additions & 0 deletions l10n_it_invoices_data_communication/models/account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-


from odoo import models, fields


class AccountJournal(models.Model):
_inherit = "account.journal"

comunicazione_dati_iva_escludi = fields.Boolean(
string='Exclude from invoices communication')
98 changes: 98 additions & 0 deletions l10n_it_invoices_data_communication/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# -*- coding: utf-8 -*-


from odoo import fields, models, _
from odoo.exceptions import ValidationError


class AccountInvoice(models.Model):
_inherit = "account.invoice"

comunicazione_dati_iva_escludi = fields.Boolean(
string='Exclude from invoices communication')

def _compute_taxes_in_company_currency(self, vals):
try:
exchange_rate = (
self.amount_total_signed /
self.amount_total_company_signed)
except ZeroDivisionError:
exchange_rate = 1
vals['ImponibileImporto'] = vals['ImponibileImporto'] / exchange_rate
vals['Imposta'] = vals['Imposta'] / exchange_rate

def _get_tax_comunicazione_dati_iva(self):
self.ensure_one()
fattura = self
tax_model = self.env['account.tax']

tax_lines = []
tax_grouped = {}
for tax_line in fattura.tax_line_ids:
tax = tax_line.tax_id
aliquota = tax.amount
parent = tax_model.search([('children_tax_ids', 'in', [tax.id])])
if parent:
main_tax = parent
aliquota = parent.amount
else:
main_tax = tax
kind_id = main_tax.kind_id.id
payability = main_tax.payability
imposta = tax_line.amount
base = tax_line.base
if main_tax.id not in tax_grouped:
tax_grouped[main_tax.id] = {
'ImponibileImporto': 0,
'Imposta': imposta,
'Aliquota': aliquota,
'Natura_id': kind_id,
'EsigibilitaIVA': payability,
'Detraibile': 0.0,
}
if fattura.type in ('in_invoice', 'in_refund'):
tax_grouped[main_tax.id]['Detraibile'] = 100.0
else:
tax_grouped[main_tax.id]['Imposta'] += imposta
if tax.account_id:
# account_id è valorizzato per la parte detraibile dell'imposta
# In questa tax_line è presente il totale dell'imponibile
# per l'imposta corrente
tax_grouped[main_tax.id]['ImponibileImporto'] += base

for tax_id in tax_grouped:
tax = tax_model.browse(tax_id)
vals = tax_grouped[tax_id]
if tax.children_tax_ids:
parte_detraibile = 0.0
for child_tax in tax.children_tax_ids:
if child_tax.account_id:
parte_detraibile = child_tax.amount
break
if vals['Aliquota'] and parte_detraibile:
vals['Detraibile'] = (
100 / (vals['Aliquota'] / parte_detraibile)
)
else:
vals['Detraibile'] = 0.0
vals = self._check_tax_comunicazione_dati_iva(tax, vals)
fattura._compute_taxes_in_company_currency(vals)
tax_lines.append((0, 0, vals))

return tax_lines

def _check_tax_comunicazione_dati_iva(self, tax, val=None):
self.ensure_one()
if not val:
val = {}
if val['Aliquota'] == 0 and not val['Natura_id']:
raise ValidationError(
_(
"Please specify exemption kind for tax: {} - Invoice {}"
).format(tax.name, self.number or False))
if not val['EsigibilitaIVA']:
raise ValidationError(
_(
"Please specify VAT payability for tax: {} - Invoice {}"
).format(tax.name, self.number or False))
return val
Loading

0 comments on commit a45b073

Please sign in to comment.