Skip to content

Commit

Permalink
porting l10n_it_fatturapa_in to 12
Browse files Browse the repository at this point in the history
  • Loading branch information
eLBati authored and TheMule71 committed Jun 9, 2021
1 parent a81822e commit adba1b6
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 37 deletions.
10 changes: 5 additions & 5 deletions l10n_it_fatturapa_in/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Italian Localization - Fattura Elettronica reception
: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/11.0/l10n_it_fatturapa_in
:target: https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_in
: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-11-0/l10n-italy-11-0-l10n_it_fatturapa_in
:target: https://translation.odoo-community.org/projects/l10n-italy-12-0/l10n-italy-12-0-l10n_it_fatturapa_in
: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/11.0
:target: https://runbot.odoo-community.org/runbot/122/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -79,7 +79,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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_fatturapa_in%0Aversion:%2011.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_in%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.

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion l10n_it_fatturapa_in/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
'name': 'Italian Localization - Fattura Elettronica reception',
'version': '11.0.1.0.0',
'version': '12.0.1.0.0',
"development_status": "Beta",
'category': 'Localization/Italy',
'summary': 'Electronic invoices reception',
Expand Down
2 changes: 2 additions & 0 deletions l10n_it_fatturapa_in/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class DiscountRisePrice(models.Model):

class EInvoiceLine(models.Model):
_name = 'einvoice.line'
_description = 'E-invoice line'
invoice_id = fields.Many2one(
"account.invoice", "Invoice", readonly=True)
line_number = fields.Integer('Numero Linea', readonly=True)
Expand Down Expand Up @@ -109,6 +110,7 @@ class EInvoiceLine(models.Model):

class EInvoiceLineOtherData(models.Model):
_name = 'einvoice.line.other.data'
_description = 'E-invoice line other data'

e_invoice_line_id = fields.Many2one(
'einvoice.line', 'Related E-Invoice line', readonly=True
Expand Down
9 changes: 6 additions & 3 deletions l10n_it_fatturapa_in/models/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@ class AccountConfigSettings(models.TransientModel):
related='company_id.dati_bollo_product_id',
string="Product for Dati Bollo",
help='Prodotto da utilizzare nelle fatture passive quando nell\'XML '
'viene valorizzato l\'elemento DatiBollo'
'viene valorizzato l\'elemento DatiBollo',
readonly=False
)
cassa_previdenziale_product_id = fields.Many2one(
related='company_id.cassa_previdenziale_product_id',
string="Product for Dati Cassa Previdenziale",
help='Prodotto da utilizzare nelle fatture passive quando nell\'XML '
'viene valorizzato l\'elemento DatiCassaPrevidenziale'
'viene valorizzato l\'elemento DatiCassaPrevidenziale',
readonly=False
)
sconto_maggiorazione_product_id = fields.Many2one(
related='company_id.sconto_maggiorazione_product_id',
string="Product for Sconto Maggiorazione",
help='Prodotto da utilizzare nelle fatture passive quando nell\'XML '
'viene valorizzato l\'elemento ScontoMaggiorazione'
'viene valorizzato l\'elemento ScontoMaggiorazione',
readonly=False
)

@api.onchange('company_id')
Expand Down
6 changes: 3 additions & 3 deletions l10n_it_fatturapa_in/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Italian Localization - Fattura Elettronica reception</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/l10n-italy/tree/11.0/l10n_it_fatturapa_in"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/l10n-italy-11-0/l10n-italy-11-0-l10n_it_fatturapa_in"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/122/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" 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" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_in"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/l10n-italy-12-0/l10n-italy-12-0-l10n_it_fatturapa_in"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/122/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows to import XML files of electronic invoices, version 1.2</p>
<p><a class="reference external" href="http://www.fatturapa.gov.it/export/fatturazione/it/normativa/f-2.htm">http://www.fatturapa.gov.it/export/fatturazione/it/normativa/f-2.htm</a></p>
<p>received through the exchange system (SDI)</p>
Expand Down Expand Up @@ -424,7 +424,7 @@ <h1><a class="toc-backref" href="#id4">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 smashing 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_in%0Aversion:%2011.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_in%0Aversion:%2012.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 @@ -451,7 +451,7 @@ <h2><a class="toc-backref" href="#id8">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/11.0/l10n_it_fatturapa_in">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/12.0/l10n_it_fatturapa_in">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
13 changes: 7 additions & 6 deletions l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import base64
import tempfile
from datetime import date
from odoo.tests.common import SingleTransactionCase
from odoo.modules import get_module_resource
from odoo.exceptions import UserError
Expand All @@ -11,7 +12,7 @@ class TestFatturaPAXMLValidation(SingleTransactionCase):
def getFile(self, filename):
path = get_module_resource(
'l10n_it_fatturapa_in', 'tests', 'data', filename)
with open(path) as test_data:
with open(path, 'rb') as test_data:
with tempfile.TemporaryFile() as out:
base64.encode(test_data, out)
out.seek(0)
Expand Down Expand Up @@ -43,7 +44,7 @@ def setUp(self):
'product.product_product_7_product_template')
self.imac = self.env.ref(
'product.product_product_8_product_template')
self.service = self.env.ref('product.service_delivery')
self.service = self.env.ref('product.product_product_1')

def run_wizard(self, name, file_name):
attach_id = self.attach_model.create(
Expand Down Expand Up @@ -210,7 +211,7 @@ def test_05_xml_import(self):
invoice = self.invoice_model.browse(invoice_id)
self.assertEqual(invoice.reference, 'FT/2015/0008')
self.assertEqual(invoice.sender, 'TZ')
self.assertEqual(invoice.intermediary.name, 'ROSSI MARIO')
self.assertEqual(invoice.intermediary.name, 'MARIO ROSSI')
self.assertEqual(invoice.intermediary.firstname, 'MARIO')
self.assertEqual(invoice.intermediary.lastname, 'ROSSI')
bollo_found = False
Expand Down Expand Up @@ -281,10 +282,10 @@ def test_10_xml_import(self):
invoice = self.invoice_model.browse(invoice_id)
self.assertEqual(invoice.reference, 'FT/2015/0009')
self.assertEqual(
invoice.date_invoice, '2015-03-16')
invoice.date_invoice, date(2015, 3, 16))
self.assertEqual(
invoice.fatturapa_payments[0].payment_methods[0].payment_due_date,
'2015-06-03'
date(2015, 6, 3)
)
self.assertEqual(
invoice.fatturapa_payments[0].payment_methods[0].
Expand Down Expand Up @@ -313,7 +314,7 @@ def test_12_xml_import(self):
invoice = self.invoice_model.browse(invoice_id)
self.assertEqual(invoice.reference, 'FT/2015/0012')
self.assertEqual(invoice.sender, 'TZ')
self.assertEqual(invoice.intermediary.name, 'ROSSI MARIO')
self.assertEqual(invoice.intermediary.name, 'MARIO ROSSI')
self.assertEqual(invoice.intermediary.firstname, 'MARIO')
self.assertEqual(invoice.intermediary.lastname, 'ROSSI')

Expand Down
9 changes: 7 additions & 2 deletions l10n_it_fatturapa_in/views/account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
<div>
<group>
<group>
<field filename="datas_fname" name="datas"></field>
<field name='id' invisible="1"/>
<label for="datas"/>
<div>
<field name="datas" filename="datas_fname"/>
<field name="ftpa_preview_link" widget="url" text="Show preview"
attrs="{'invisible': [('id', '=', False)]}"/>
</div>
<field name="datas_fname" invisible="1"></field>
<field name="name"></field>
</group>
Expand All @@ -20,7 +26,6 @@
<field name="invoices_total"/>
</group>
</group>
<field name="ftpa_preview_link" widget="url" text="Show preview" class="btn btn-default"/>
<notebook>
<page string="Invoices">
<field name="in_invoice_ids"
Expand Down
40 changes: 28 additions & 12 deletions l10n_it_fatturapa_in/views/company_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,34 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="l10n_it_fatturapa.view_account_config_settings"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='fatturapa_settings']" position="inside">
<div>
<label for="dati_bollo_product_id"/>
<field name="dati_bollo_product_id" class="oe_inline"/>
</div>
<div>
<label for="cassa_previdenziale_product_id"/>
<field name="cassa_previdenziale_product_id" class="oe_inline"/>
</div>
<div>
<label for="sconto_maggiorazione_product_id"/>
<field name="sconto_maggiorazione_product_id" class="oe_inline"/>
<xpath expr="//div[@id='fatturapa_settings']" position="after">
<div class="row mt16 o_settings_container" id="supplier_fatturapa_settings">
<div class="col-12 col-lg-12 o_setting_box">
<div class="o_setting_left_pane"/>
<div class="o_setting_right_pane">
<span class="o_form_label">Supplier Invoices</span>
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific."
aria-label="Values set here are company-specific."
groups="base.group_multi_company" role="img"/>
<div class="text-muted">
Default products used in electronic supplier invoices
</div>
<div class="content-group">
<div class="row mt16">
<label for="dati_bollo_product_id" class="col-lg-6 o_light_label"/>
<field name="dati_bollo_product_id" class="col-lg-6"/>
</div>
<div class="row">
<label for="cassa_previdenziale_product_id" class="col-lg-6 o_light_label"/>
<field name="cassa_previdenziale_product_id" class="col-lg-6"/>
</div>
<div class="row">
<label for="sconto_maggiorazione_product_id" class="col-lg-6 o_light_label"/>
<field name="sconto_maggiorazione_product_id" class="col-lg-6"/>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
Expand Down
9 changes: 4 additions & 5 deletions l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ def getCedPrest(self, cedPrest):
if cedPrest.Contatti:
vals['phone'] = cedPrest.Contatti.Telefono
vals['email'] = cedPrest.Contatti.Email
vals['fax'] = cedPrest.Contatti.Fax
partner_model.browse(partner_id).write(vals)
return partner_id

Expand All @@ -258,10 +257,10 @@ def _prepare_generic_line_data(self, line):
retLine = {}
account_tax_model = self.env['account.tax']
# check if a default tax exists and generate def_purchase_tax object
ir_values = self.env['ir.values']
ir_values = self.env['ir.default']
company_id = self.env['res.company']._company_default_get(
'account.invoice.line').id
supplier_taxes_ids = ir_values.get_default(
supplier_taxes_ids = ir_values.get(
'product.product', 'supplier_taxes_id', company_id=company_id)
def_purchase_tax = False
if supplier_taxes_ids:
Expand Down Expand Up @@ -861,7 +860,7 @@ def invoiceCreate(
invoice_data = {
'fiscal_document_type_id': docType_id,
'date_invoice':
FatturaBody.DatiGenerali.DatiGeneraliDocumento.Data,
FatturaBody.DatiGenerali.DatiGeneraliDocumento.Data.date(),
'reference':
FatturaBody.DatiGenerali.DatiGeneraliDocumento.Numero,
'sender': fatt.FatturaElettronicaHeader.SoggettoEmittente or False,
Expand Down Expand Up @@ -1163,7 +1162,7 @@ def invoiceCreate(
content = attach.Attachment
_attach_dict = {
'name': name,
'datas': base64.b64encode(str(content)),
'datas': base64.b64encode(content),
'datas_fname': name,
'description': attach.DescrizioneAttachment or '',
'compression': attach.AlgoritmoCompressione or '',
Expand Down

0 comments on commit adba1b6

Please sign in to comment.