Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][MIG] l10n_it_fatturapa_out_triple_discount #3681

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3cade46
[ADD] l10n_it_fatturapa_out_triple_discount
SimoRubi Jan 22, 2019
fe85f2e
[UPD] Update l10n_it_fatturapa_out_triple_discount.pot
oca-travis Feb 1, 2019
9d1be02
FIX l10n_it_fatturapa_out_triple_discount adapt to new set_sequences …
eLBati Mar 7, 2019
6606e0f
[ADD] icon.png
OCA-git-bot Apr 3, 2019
92f8eb7
l10n_it_fatturapa: xml doctor for fatturapa
sherpya May 3, 2019
818bbc7
[UPD] README.rst
OCA-git-bot Jul 29, 2019
2b178bd
[MIG] 10n_it_fatturapa_out_triple_discount: Migration to 12.0
tafaRU Dec 17, 2019
009e56c
[UPD] Update l10n_it_fatturapa_out_triple_discount.pot
oca-travis Jan 3, 2020
56fe5dc
[UPD] README.rst
OCA-git-bot Jan 3, 2020
68db54c
Use float_round from odoo because in python 3 "Exact halfway cases ar…
eLBati Jan 14, 2020
c1b458f
l10n_it_fatturapa_out_triple_discount 12.0.1.0.1
OCA-git-bot Jan 15, 2020
50a99d6
l10n_it_fatturapa_out_triple_discount: disable tests because unstable
eLBati Jan 21, 2020
8f1fdb9
l10n_it_fatturapa_out_triple_discount 12.0.1.0.2
OCA-git-bot Jan 22, 2020
99d3e3b
merge PR 1264 1717 1728 1737 1739
May 13, 2020
c07d867
FIX license LGPL-3 conflicts
eLBati Sep 24, 2020
64d51d5
l10n_it_fatturapa_out_triple_discount 12.0.1.0.4
OCA-git-bot Sep 24, 2020
ac80434
[12.0][IMP] l10n_it_fatturapa_out and l10n_it_fatturapa_out_triple_di…
tafaRU Sep 11, 2020
c251aa9
l10n_it_fatturapa_out_triple_discount 12.0.2.0.0
OCA-git-bot Oct 2, 2020
ec71d58
[FIX][l10n_it_fatturapa_out_triple_discount] change rounding to avoid…
Apr 12, 2021
2606fec
l10n_it_fatturapa_out_triple_discount 12.0.2.0.1
OCA-git-bot Apr 15, 2021
1908593
Manually fix manifest website key
SirTakobi Aug 5, 2022
958d820
Added translation using Weblate (Italian)
mymage Apr 26, 2023
360a60b
Translated using Weblate (Italian)
mymage Apr 26, 2023
81f0da8
[UPD] README.rst
OCA-git-bot Sep 3, 2023
42b71eb
Update translation files
weblate Sep 21, 2023
384ed28
[MIG][14.0] l10n_it_fatturapa_out_triple_discount
LorenzoC0 Oct 26, 2023
d85268d
[IMP] : black, isort, prettier
eLBati Oct 26, 2023
8dd0e03
FIX tests based on account_invoice_triple_discount
eLBati Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion l10n_it_fatturapa_in/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ def set_einvoice_data(self, fattura):

def process_negative_lines(self):
self.ensure_one()
if not self.invoice_line_ids:
return
for line in self.invoice_line_ids:
if line.price_unit >= 0:
return
Expand All @@ -329,7 +331,7 @@ def process_negative_lines(self):
{"price_unit": -line.price_unit}
)
self.with_context(check_move_validity=False)._recompute_dynamic_lines(
recompute_all_taxes=True
recompute_all_taxes=True, recompute_tax_base_amount=True
)


Expand Down
14 changes: 7 additions & 7 deletions l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_00_xml_import(self):
welfare_found = False
for line in invoice.invoice_line_ids:
if line.product_id.id == self.service.id:
self.assertEqual(line.price_unit, 3)
self.assertAlmostEqual(line.price_unit, 3)
welfare_found = True
self.assertTrue(welfare_found)
self.assertTrue(len(invoice.e_invoice_line_ids) == 1)
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_04_xml_import(self):
self.assertEqual(invoice.invoice_line_ids[1].tax_ids[0].name, "22% e-bill")
self.assertEqual(invoice.invoice_line_ids[0].tax_ids[0].amount, 22)
self.assertEqual(invoice.invoice_line_ids[1].tax_ids[0].amount, 22)
self.assertEqual(invoice.invoice_line_ids[1].price_unit, 2)
self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, 2)
self.assertTrue(len(invoice.e_invoice_line_ids) == 2)
for e_line in invoice.e_invoice_line_ids:
self.assertTrue(e_line.line_number in (1, 2))
Expand Down Expand Up @@ -648,10 +648,10 @@ def test_32_xml_import(self):
invoice = self.invoice_model.browse(invoice_id)
self.assertEqual(invoice.move_type, "in_refund")
self.assertEqual(invoice.amount_total, 18.3)
self.assertEqual(invoice.invoice_line_ids[0].price_unit, 2.0)
self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 2.0)
self.assertEqual(invoice.invoice_line_ids[0].quantity, 10.0)
self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 20.0)
self.assertEqual(invoice.invoice_line_ids[1].price_unit, -1.0)
self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, -1.0)
self.assertEqual(invoice.invoice_line_ids[1].quantity, 5.0)
self.assertEqual(invoice.invoice_line_ids[1].price_subtotal, -5.0)

Expand All @@ -662,7 +662,7 @@ def test_33_xml_import(self):
invoice = self.invoice_model.browse(invoice_id)
self.assertEqual(invoice.move_type, "in_refund")
self.assertEqual(round(invoice.amount_total, 2), 24.4)
self.assertEqual(invoice.invoice_line_ids[0].price_unit, 2.0)
self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 2.0)
self.assertEqual(invoice.invoice_line_ids[0].quantity, 10.0)
self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 20.0)
self.assertEqual(invoice.e_invoice_amount_untaxed, -20.0)
Expand Down Expand Up @@ -815,7 +815,7 @@ def test_46_xml_many_zeros(self):
invoice_id = res.get("domain")[0][2][0]
invoice = self.invoice_model.browse(invoice_id)
self.assertEqual(invoice.amount_total, 18.07)
self.assertEqual(invoice.invoice_line_ids[0].price_unit, 18.07)
self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 18.07)
self.assertEqual(invoice.invoice_line_ids[0].quantity, 1.0)
self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 18.07)
self.assertEqual(invoice.invoice_line_ids[1].price_unit, 16.60)
Expand Down Expand Up @@ -1074,7 +1074,7 @@ def test_xml_import_summary_tax_rate(self):

self.assertEqual(invoice.invoice_line_ids[0].price_unit, 164.46)
self.assertEqual(invoice.invoice_line_ids[0].quantity, 1.0)
self.assertEqual(invoice.invoice_line_ids[1].price_unit, 3.52)
self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, 3.52)
self.assertEqual(invoice.invoice_line_ids[1].quantity, 1.0)

def test_e_invoice_field_compute(self):
Expand Down
13 changes: 10 additions & 3 deletions l10n_it_fatturapa_out/wizard/efattura.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In questo commit ci sono anche modifiche a un altro modulo, è possibile avere commit che modificano un solo modulo? Vedi https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#commit-message, in particolare:

Avoid commits which simultaneously impact lots of modules. Try to split into different commits where impacted modules are different. This is helpful if we need to revert changes on a module separately.

Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,19 @@ def get_all_taxes(record):
wiz = self.env["wizard.export.fatturapa"]
return wiz.getAllTaxes(record)

def get_importo(line):
str_number = str(line.discount)
def get_importo(line, discount_field="discount"):
str_number = str(line[discount_field])
number = str_number[::-1].find(".")
if number <= 2:
return False
return line.price_unit * line.discount / 100
if discount_field == "discount2":
price_unit = line.price_unit * (1 - line.discount / 100)
return price_unit * line[discount_field] / 100
elif discount_field == "discount3":
price_unit = line.price_unit * (1 - line.discount / 100)
price_unit = price_unit * (1 - line.discount2 / 100)
return price_unit * line[discount_field] / 100
return line.price_unit * line[discount_field] / 100
Comment on lines +182 to +189
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questo codice serve solo nel caso in cui sia installato account_invoice_triple_discount che non è una dipendenza del modulo l10n_it_fatturapa_out, si può spostare in l10n_it_fatturapa_out_triple_discount?


def get_importo_totale(invoice):
# wrapper to a method in wizard (for better overriding)
Expand Down
83 changes: 83 additions & 0 deletions l10n_it_fatturapa_out_triple_discount/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
======================================================
ITA - Fattura elettronica - Integrazione sconto triplo
======================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3652bd491ec5c99bbb9371877cd7903143ccbfc4a86053fd8f157a9f7fadca9c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-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/14.0/l10n_it_fatturapa_out_triple_discount
: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-14-0/l10n-italy-14-0-l10n_it_fatturapa_out_triple_discount
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=14.0
:alt: Try me on Runboat

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

**Italiano**

Questo modulo consente di generare correttamente la fattura elettronica (XML) quando il modulo account_invoice_triple_discount è installato.

**English**

The module allows to use correctly generate the Electronic Invoice (XML) when the module account_invoice_triple_discount is installed.

**Table of contents**

.. contents::
:local:

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_fatturapa_out_triple_discount%0Aversion:%2014.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
~~~~~~~

* Agile Business Group

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

* Simone Rubino
* Alex Comba <[email protected]>

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/14.0/l10n_it_fatturapa_out_triple_discount>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Empty file.
22 changes: 22 additions & 0 deletions l10n_it_fatturapa_out_triple_discount/__manifest__.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

È possibile ripristinare i test automatici del modulo?
Sono stati disattivati per un vecchio problema e non è detto che sia ancora valido

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2019 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "ITA - Fattura elettronica - Integrazione sconto triplo",
"summary": "Modulo ponte tra emissione fatture elettroniche e sconto triplo",
"version": "14.0.1.0.0",
"development_status": "Beta",
"category": "Hidden",
"website": "https://github.com/OCA/l10n-italy"
"/tree/12.0/l10n_it_fatturapa_out_triple_discount",
"author": "Agile Business Group, Odoo Community Association (OCA)",
"license": "AGPL-3",
"auto_install": True,
"depends": [
"l10n_it_fatturapa_out",
"account_invoice_triple_discount",
],
"data": [
"data/invoice_it_template.xml",
],
}
43 changes: 43 additions & 0 deletions l10n_it_fatturapa_out_triple_discount/data/invoice_it_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<odoo>
<template
id="account_invoice_line_it_triple_discount"
inherit_id="l10n_it_fatturapa_out.account_invoice_line_it_sconto_maggiorazione"
>
<xpath expr="//ScontoMaggiorazione" position="after">
<t
t-set="importo2"
t-value="get_importo(line, discount_field='discount2')"
/>
<t
t-set="importo3"
t-value="get_importo(line, discount_field='discount3')"
/>
<ScontoMaggiorazione t-if="line.discount2 != 0 or importo2 != 0">
<!-- [2.2.1.10] -->
<t t-if="importo">
<Tipo t-if="importo2 &gt; 0">SC</Tipo>
<Tipo t-if="importo2 &lt;= 0">MG</Tipo>
<Importo t-esc="format_numbers(abs(importo2))" />
</t>
<t t-else="">
<Tipo t-if="line.discount2 &gt; 0">SC</Tipo>
<Tipo t-if="line.discount2 &lt;= 0">MG</Tipo>
<Percentuale t-esc="format_numbers_two(abs(line.discount2))" />
Comment on lines +20 to +25
Copy link
Contributor

@SirAionTech SirAionTech Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il modulo nella 12.0 aggiungeva solo il nodo Percentuale, è possibile mantenere il vecchio comportamento nella migrazione?
La modifica al comportamento esistente andrebbe almeno in un commit diverso, o meglio ancora in una PR diversa, e secondo https://github.com/OCA/l10n-italy/wiki/Team-di-sviluppo#apertura-issue ci vorrebbe anche una issue dedicata.

Anche perché lo sconto triplo potrebbe portare un importo scontato diverso a seconda di come vengono applicati gli sconti, ad esempio additivo o moltiplicativo o chissà cos'altro ci si può inventare con gli override di https://github.com/OCA/account-invoicing/blob/bab944e76aa71c3f300695fc90a4656a9055da4e/account_invoice_triple_discount/models/account_move_line.py#L97

</t>
</ScontoMaggiorazione>
<ScontoMaggiorazione t-if="line.discount3 != 0 or importo3 != 0">
<!-- [2.2.1.10] -->
<t t-if="importo">
<Tipo t-if="importo3 &gt; 0">SC</Tipo>
<Tipo t-if="importo3 &lt;= 0">MG</Tipo>
<Importo t-esc="format_numbers(abs(importo3))" />
</t>
<t t-else="">
<Tipo t-if="line.discount3 &gt; 0">SC</Tipo>
<Tipo t-if="line.discount3 &lt;= 0">MG</Tipo>
<Percentuale t-esc="format_numbers_two(abs(line.discount3))" />
</t>
</ScontoMaggiorazione>
Comment on lines +15 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

È possibile evitare di ripetere lo stesso markup più volte?
Penso sia anche meglio spostare la logica più possibile lato Python perché credo sia più facile da modificare con override e simili

</xpath>
</template>
</odoo>
22 changes: 22 additions & 0 deletions l10n_it_fatturapa_out_triple_discount/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_it_fatturapa_out_triple_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-04-26 16:05+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.14.1\n"

#. module: l10n_it_fatturapa_out_triple_discount
#: model:ir.model,name:l10n_it_fatturapa_out_triple_discount.model_wizard_export_fatturapa
msgid "Export E-invoice"
msgstr "Esporta e-fattura"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_it_fatturapa_out_triple_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \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_out_triple_discount
#: model:ir.model,name:l10n_it_fatturapa_out_triple_discount.model_wizard_export_fatturapa
msgid "Export E-invoice"
msgstr ""

2 changes: 2 additions & 0 deletions l10n_it_fatturapa_out_triple_discount/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Simone Rubino
* Alex Comba <[email protected]>
7 changes: 7 additions & 0 deletions l10n_it_fatturapa_out_triple_discount/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**Italiano**

Questo modulo consente di generare correttamente la fattura elettronica (XML) quando il modulo account_invoice_triple_discount è installato.

**English**

The module allows to use correctly generate the Electronic Invoice (XML) when the module account_invoice_triple_discount is installed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading