-
-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD][12.0] New module to add ability to modify e-invoice vendor
- Loading branch information
1 parent
2d010bd
commit 9f8a1d1
Showing
22 changed files
with
2,099 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
=========================================== | ||
Compute invoice taxes with e-invoice values | ||
=========================================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Alpha | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github | ||
:target: https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_in_recompute | ||
: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-12-0/l10n-italy-12-0-l10n_it_fatturapa_in_recompute | ||
: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/12.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Con questo modulo è possibile utilizzare i valori della fattura elettronica importata con più decimali rispetto a quelli in uso ordinariamente senza perdita di dati, anche in caso di modifiche sulla fattura. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
Nulla da configurare. | ||
|
||
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_fatturapa_in_recompute%0Aversion:%2012.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 | ||
~~~~~~~ | ||
|
||
* Sergio Corato | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Sergio Corato <https://github.com/sergiocorato> | ||
|
||
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. | ||
|
||
.. |maintainer-sergiocorato| image:: https://github.com/sergiocorato.png?size=40px | ||
:target: https://github.com/sergiocorato | ||
:alt: sergiocorato | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-sergiocorato| | ||
|
||
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_in_recompute>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2022 Sergio Corato <https://github.com/sergiocorato> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Compute invoice taxes with e-invoice values", | ||
"summary": "This module enables recomputation of the invoice on e-invoices values " | ||
"as if imported with custom precisions, these values will not be " | ||
"mantained.", | ||
"version": "12.0.1.0.0", | ||
"development_status": "Alpha", | ||
"category": "Accounting & Finance", | ||
"website": "https://github.com/OCA/l10n-italy/tree/12.0/" | ||
"l10n_it_fatturapa_in_recompute", | ||
"author": "Sergio Corato, Odoo Community Association (OCA)", | ||
"maintainers": ["sergiocorato"], | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"l10n_it_fatturapa_in", | ||
], | ||
"data": [ | ||
"views/account_invoice_view.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * l10n_it_fatturapa_in_recompute | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2022-07-17 14:16+0000\n" | ||
"PO-Revision-Date: 2022-07-17 14:16+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: l10n_it_fatturapa_in_recompute | ||
#: model:ir.model.fields,field_description:l10n_it_fatturapa_in_recompute.field_account_invoice__compute_on_einvoice_values | ||
msgid "Compute On Einvoice Values" | ||
msgstr "Calcola Sui Valori della E-fattura" | ||
|
||
#. module: l10n_it_fatturapa_in_recompute | ||
#: model:ir.model,name:l10n_it_fatturapa_in_recompute.model_einvoice_line | ||
msgid "E-invoice line" | ||
msgstr "Riga e-fattura" | ||
|
||
#. module: l10n_it_fatturapa_in_recompute | ||
#: model:ir.model,name:l10n_it_fatturapa_in_recompute.model_wizard_import_fatturapa | ||
msgid "Import E-bill" | ||
msgstr "Importa e-fattura" | ||
|
||
#. module: l10n_it_fatturapa_in_recompute | ||
#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_in_recompute.view_invoice_form_fatturapa_in | ||
msgid "Import Precisions" | ||
msgstr "Precisione Importazione" | ||
|
||
#. module: l10n_it_fatturapa_in_recompute | ||
#: model:ir.model,name:l10n_it_fatturapa_in_recompute.model_account_invoice | ||
msgid "Invoice" | ||
msgstr "Fattura" | ||
|
||
#. module: l10n_it_fatturapa_in_recompute | ||
#: model:ir.model,name:l10n_it_fatturapa_in_recompute.model_account_invoice_line | ||
msgid "Invoice Line" | ||
msgstr "Riga fattura" | ||
|
||
#. module: l10n_it_fatturapa_in_recompute | ||
#: model:ir.model.fields,field_description:l10n_it_fatturapa_in_recompute.field_einvoice_line__qty | ||
msgid "Quantity" | ||
msgstr "Quantità" | ||
|
||
#. module: l10n_it_fatturapa_in_recompute | ||
#: model:ir.model.fields,field_description:l10n_it_fatturapa_in_recompute.field_account_invoice_line__e_invoice_line_id | ||
msgid "Related E-bill Line" | ||
msgstr "Riga e-fattura collegata" | ||
|
||
#. module: l10n_it_fatturapa_in_recompute | ||
#: model:ir.model.fields,field_description:l10n_it_fatturapa_in_recompute.field_einvoice_line__unit_price | ||
msgid "Unit Price" | ||
msgstr "Prezzo unitario" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import einvoice_line | ||
from . import account_invoice |
109 changes: 109 additions & 0 deletions
109
l10n_it_fatturapa_in_recompute/models/account_invoice.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Copyright 2022 Sergio Corato <https://github.com/sergiocorato> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import api, fields, models | ||
from odoo.tools.float_utils import float_round | ||
|
||
|
||
class AccountInvoiceLine(models.Model): | ||
_inherit = "account.invoice.line" | ||
|
||
e_invoice_line_id = fields.Many2one( | ||
'einvoice.line', 'Related E-bill Line', readonly=True) | ||
|
||
@api.one | ||
@api.depends('price_unit', 'discount', 'invoice_line_tax_ids', 'quantity', | ||
'product_id', 'invoice_id.partner_id', 'invoice_id.currency_id', | ||
'invoice_id.company_id', 'invoice_id.date_invoice', 'invoice_id.date') | ||
def _compute_price(self): | ||
super()._compute_price() | ||
# Reset price subtotal to e-invoice value | ||
if self._context.get('active_model', '') != 'fatturapa.attachment.in' \ | ||
and self.e_invoice_line_id \ | ||
and self.invoice_id.compute_on_einvoice_values: | ||
currency = self.invoice_id and self.invoice_id.currency_id or self.\ | ||
company_id.currency_id | ||
price = self.e_invoice_line_id.unit_price * ( | ||
1 - (self.discount or 0.0) / 100.0) | ||
subtotal_price = self.e_invoice_line_id.total_price | ||
taxes = False | ||
if self.invoice_line_tax_ids: | ||
taxes = self.invoice_line_tax_ids.compute_all( | ||
subtotal_price, currency, | ||
1, | ||
product=self.product_id, | ||
partner=self.invoice_id.partner_id) | ||
self.price_subtotal = price_subtotal_signed = taxes[ | ||
'total_excluded'] if taxes else self.e_invoice_line_id.qty * price | ||
price_total = taxes['total_included'] if taxes else self.price_subtotal | ||
taxes_amount = sum( | ||
[x['amount'] for x in taxes['taxes']]) if taxes else \ | ||
price_total - self.price_subtotal | ||
self.price_total = self.price_subtotal + taxes_amount | ||
if self.invoice_id.currency_id and self.invoice_id.currency_id \ | ||
!= self.invoice_id.company_id.currency_id: | ||
currency = self.invoice_id.currency_id | ||
date = self.invoice_id._get_currency_rate_date() | ||
price_subtotal_signed = currency._convert( | ||
price_subtotal_signed, | ||
self.invoice_id.company_id.currency_id, | ||
self.company_id or self.env.user.company_id, | ||
date or fields.Date.today()) | ||
sign = self.invoice_id.type in ['in_refund', 'out_refund'] and -1 or 1 | ||
self.price_subtotal_signed = price_subtotal_signed * sign | ||
|
||
|
||
class AccountInvoice(models.Model): | ||
_inherit = 'account.invoice' | ||
|
||
compute_on_einvoice_values = fields.Boolean() | ||
|
||
@api.multi | ||
def get_taxes_values(self): | ||
taxes_grouped = super().get_taxes_values() | ||
if self.compute_on_einvoice_values: | ||
tax_grouped = {} | ||
for line in self.invoice_line_ids: | ||
if not line.account_id or line.display_type: | ||
continue | ||
if len(line.invoice_line_tax_ids) != 1: | ||
continue | ||
if line.e_invoice_line_id: | ||
invoice_line_tax = line.invoice_line_tax_ids[0] | ||
if invoice_line_tax not in tax_grouped: | ||
tax_grouped.update({invoice_line_tax: { | ||
'base': line.e_invoice_line_id.total_price, | ||
'amount': 0}} | ||
) | ||
else: | ||
tax_grouped[invoice_line_tax]['base'] += \ | ||
line.e_invoice_line_id.total_price | ||
else: | ||
invoice_line_tax = line.invoice_line_tax_ids[0] | ||
if invoice_line_tax not in tax_grouped: | ||
tax_grouped.update({invoice_line_tax: { | ||
'base': line.price_subtotal, | ||
'amount': 0}} | ||
) | ||
else: | ||
tax_grouped[invoice_line_tax]['base'] += \ | ||
line.price_subtotal | ||
# compute taxes by group | ||
for key in taxes_grouped: | ||
for tax_group in tax_grouped: | ||
if taxes_grouped[key]['tax_id'] == tax_group.id: | ||
taxes_recomputed = tax_group.compute_all( | ||
tax_grouped[tax_group]['base']) | ||
if any(t.get('price_include', False) for t | ||
in taxes_recomputed['taxes']): | ||
# no need to do this check for price included taxes | ||
continue | ||
amount_recomputed = sum( | ||
[float_round(x['amount'], | ||
precision_rounding=self.currency_id.rounding | ||
) for x in taxes_recomputed['taxes']]) | ||
taxes_grouped[key]['amount'] = amount_recomputed | ||
taxes_grouped[key]['base'] = sum( | ||
[float_round(x['base'], | ||
precision_rounding=self.currency_id.rounding | ||
) for x in taxes_recomputed['taxes']]) | ||
return taxes_grouped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2022 Sergio Corato <https://github.com/sergiocorato> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
|
||
|
||
class EInvoiceLine(models.Model): | ||
_inherit = 'einvoice.line' | ||
|
||
# set unlimited digits | ||
unit_price = fields.Float( | ||
digits=(19, 8) | ||
) | ||
qty = fields.Float( | ||
digits=(20, 8) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Nulla da configurare. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Sergio Corato <https://github.com/sergiocorato> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Con questo modulo è possibile utilizzare i valori della fattura elettronica importata con più decimali rispetto a quelli in uso ordinariamente senza perdita di dati, anche in caso di modifiche sulla fattura. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.