Skip to content

Commit

Permalink
[14.0][MIG] Migration to 14.0 l10n_it_fatturapa_out_fd
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocorato committed Oct 24, 2024
1 parent ec94f19 commit 9fafba4
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 42 deletions.
10 changes: 5 additions & 5 deletions l10n_it_fatturapa_out_fd/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ ITA - Fattura elettronica - Emissione - Sconto fisso
: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_out_fd
:target: https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_fatturapa_out_fd
: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_out_fd
:target: https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_fatturapa_out_fd
: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=12.0
: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|
Expand All @@ -47,7 +47,7 @@ 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_fd%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_fatturapa_out_fd%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.

Expand Down Expand Up @@ -79,6 +79,6 @@ 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/12.0/l10n_it_fatturapa_out_fd>`_ project on GitHub.
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_fatturapa_out_fd>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 2 additions & 3 deletions l10n_it_fatturapa_out_fd/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "ITA - Fattura elettronica - Emissione - Sconto fisso",
"version": "12.0.1.0.0",
"version": "14.0.1.0.0",
"category": "Localization/Italy",
"summary": "Emissione di fattura elettronica con sconto fisso",
"author": "TAKOBI, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-italy"
"/tree/12.0/l10n_it_fatturapa_out_fd",
"website": "https://github.com/OCA/l10n-italy",
"license": "AGPL-3",
"depends": [
"l10n_it_fatturapa_out",
Expand Down
6 changes: 3 additions & 3 deletions l10n_it_fatturapa_out_fd/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ <h1 class="title">ITA - Fattura elettronica - Emissione - Sconto fisso</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7fec8e7baf6822cef32b57f070a3692bc15eaebb8df93ab1f7b212799c0bd350
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_out_fd"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-italy-12-0/l10n-italy-12-0-l10n_it_fatturapa_out_fd"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&amp;target_branch=12.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_fatturapa_out_fd"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_fatturapa_out_fd"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><strong>Italiano</strong></p>
<p>Modulo tecnico di integrazione tra account_invoice_fixed_discount e l10n_it_fatturapa_out.</p>
<p><strong>English</strong></p>
Expand All @@ -390,7 +390,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/l10n-italy/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_fatturapa_out_fd%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_fatturapa_out_fd%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -417,7 +417,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_out_fd">OCA/l10n-italy</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_fatturapa_out_fd">OCA/l10n-italy</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
7 changes: 5 additions & 2 deletions l10n_it_fatturapa_out_fd/tests/data/IT06363391001_00001.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<ns1:FatturaElettronica xmlns:ns1="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" versione="FPR12">
<ns1:FatturaElettronica
xmlns:ns1="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2"
versione="FPR12"
>
<FatturaElettronicaHeader>
<DatiTrasmissione>
<IdTrasmittente>
Expand Down Expand Up @@ -63,7 +66,7 @@
<TipoDocumento>TD01</TipoDocumento>
<Divisa>EUR</Divisa>
<Data>2020-01-01</Data>
<Numero>INV/2020/0001</Numero>
<Numero>INV/2020/01/0001</Numero>
<ImportoTotaleDocumento>1195.60</ImportoTotaleDocumento>
<Art73>SI</Art73>
</DatiGeneraliDocumento>
Expand Down
57 changes: 44 additions & 13 deletions l10n_it_fatturapa_out_fd/tests/test_xml_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,79 @@

import base64

from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import (FatturaPACommon)
from odoo.tests import Form
from odoo.tests import Form, tagged

from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import FatturaPACommon

class TestXMLGeneration (FatturaPACommon):

@tagged("post_install", "-at_install")
class TestXMLGeneration(FatturaPACommon):
def setUp(self):
super().setUp()
# XXX - a company named "YourCompany" alread exists
# we move it out of the way but we should do better here
self.env.company.sudo().search([("name", "=", "YourCompany")]).write(
{"name": "YourCompany_"}
)
self.env.company.name = "YourCompany"
self.env.company.vat = "IT06363391001"
self.env.company.fatturapa_art73 = True
self.env.company.partner_id.street = "Via Milano, 1"
self.env.company.partner_id.city = "Roma"
self.env.company.partner_id.state_id = self.env.ref("base.state_us_2").id
self.env.company.partner_id.zip = "00100"
self.env.company.partner_id.phone = "06543534343"
self.env.company.email = "[email protected]"
self.env.company.partner_id.country_id = self.env.ref("base.it").id
self.env.company.fatturapa_fiscal_position_id = self.env.ref(
"l10n_it_fatturapa.fatturapa_RF01"
).id
self.env["decimal.precision"].search(
[("name", "=", "Product Unit of Measure")]
).digits = 3
self.env["uom.uom"].search([("name", "=", "Units")]).name = "Unit(s)"

def test_fixed_discount(self):
"""Generate an e-invoice for an invoice having a fixed discount.
Check that the ScontoMaggiorazione is present in the generated e-invoice.
"""
# Setup for fixing date and sequence of new invoices
date_invoice = '2020-01-01'
date_invoice = "2020-01-01"
self.set_sequences(1, date_invoice)

# Arrange: Create an invoice with one line costing 100
# and fixed discount of 20
invoice_form = Form(self.env['account.invoice'])
invoice_form = Form(
self.env["account.move"].with_context(default_move_type="out_invoice")
)
invoice_form.name = "INV/2020/01/0001"
invoice_form.partner_id = self.res_partner_fatturapa_2
invoice_form.date_invoice = date_invoice
invoice_form.invoice_date = date_invoice
with invoice_form.invoice_line_ids.new() as line:
line.name = "Test fixed discount"
line.price_unit = 1000
line.quantity = 1
line.discount_fixed = 20
line.invoice_line_tax_ids.clear()
line.invoice_line_tax_ids.add(self.tax_22)
line.account_id = self.a_sale
line.tax_ids.clear()
line.tax_ids.add(self.tax_22)
invoice = invoice_form.save()
invoice.action_invoice_open()
invoice._post()
# pre-condition: Check invoice totals
self.assertEqual(invoice.amount_untaxed, 980)
self.assertEqual(invoice.amount_tax, 215.6)
self.assertEqual(invoice.amount_total, 1195.6)
self.assertAlmostEqual(invoice.amount_total, 1195.6, 2)

# Act: Generate the e-invoice
action = self.run_wizard(invoice.id)
e_invoice = self.env[action['res_model']].browse(action['res_id'])
e_invoice = self.env[action["res_model"]].browse(action["res_id"])

# Assert: The E-invoice matches the XML in tests data
file_name = 'IT06363391001_00001.xml'
file_name = "IT06363391001_00001.xml"
self.set_e_invoice_file_id(e_invoice, file_name)
xml_content = base64.decodebytes(e_invoice.datas)
self.check_content(
xml_content,
file_name,
module_name='l10n_it_fatturapa_out_fd',
module_name="l10n_it_fatturapa_out_fd",
)
32 changes: 16 additions & 16 deletions l10n_it_fatturapa_out_fd/wizards/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Copyright 2023 Simone Rubino - TAKOBI
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models
from odoo.addons.l10n_it_fatturapa.bindings.fatturapa import (
ScontoMaggiorazioneType,
TipoScontoMaggiorazioneType,
)
from odoo.tools import float_round
from odoo import api, models


class WizardExportFatturapa (models.TransientModel):
class WizardExportFatturapa(models.TransientModel):
_inherit = "wizard.export.fatturapa"

def setScontoMaggiorazione(self, line):
res = super().setScontoMaggiorazione(line)
@staticmethod
def get_importo(line):
discount_fixed = line.discount_fixed
if discount_fixed:
res.append(
ScontoMaggiorazioneType(
Tipo=TipoScontoMaggiorazioneType.SC,
Importo='%.2f' % float_round(discount_fixed, 8),
)
)
return res
return discount_fixed
str_number = str(line.discount)
number = str_number[::-1].find(".")
if number <= 2:
return False
return line.price_unit * line.discount / 100

Check warning on line 19 in l10n_it_fatturapa_out_fd/wizards/wizard_export_fatturapa.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_out_fd/wizards/wizard_export_fatturapa.py#L19

Added line #L19 was not covered by tests

@api.model
def getTemplateValues(self, template_values):
template_values = super().getTemplateValues(template_values)
template_values.update({"get_importo": self.get_importo})
return template_values
6 changes: 6 additions & 0 deletions setup/l10n_it_fatturapa_out_fd/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 9fafba4

Please sign in to comment.