From adba1b622dac9d82d191953414331ee2e6642aca Mon Sep 17 00:00:00 2001
From: eLBati
Date: Sat, 17 Nov 2018 12:23:54 +0100
Subject: [PATCH] porting l10n_it_fatturapa_in to 12
---
l10n_it_fatturapa_in/README.rst | 10 ++---
l10n_it_fatturapa_in/__manifest__.py | 2 +-
l10n_it_fatturapa_in/models/account.py | 2 +
l10n_it_fatturapa_in/models/company.py | 9 +++--
.../static/description/index.html | 6 +--
.../tests/test_import_fatturapa_xml.py | 13 +++---
l10n_it_fatturapa_in/views/account_view.xml | 9 ++++-
l10n_it_fatturapa_in/views/company_view.xml | 40 +++++++++++++------
.../wizard/wizard_import_fatturapa.py | 9 ++---
9 files changed, 63 insertions(+), 37 deletions(-)
diff --git a/l10n_it_fatturapa_in/README.rst b/l10n_it_fatturapa_in/README.rst
index f1945d2ae101..ee5d6aa72d65 100644
--- a/l10n_it_fatturapa_in/README.rst
+++ b/l10n_it_fatturapa_in/README.rst
@@ -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|
@@ -79,7 +79,7 @@ Bug Tracker
Bugs are tracked on `GitHub 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -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 `_ project on GitHub.
+This module is part of the `OCA/l10n-italy `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/l10n_it_fatturapa_in/__manifest__.py b/l10n_it_fatturapa_in/__manifest__.py
index 9076714ff2fb..4e2d0ea59064 100644
--- a/l10n_it_fatturapa_in/__manifest__.py
+++ b/l10n_it_fatturapa_in/__manifest__.py
@@ -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',
diff --git a/l10n_it_fatturapa_in/models/account.py b/l10n_it_fatturapa_in/models/account.py
index 360eeeb6e351..3d80c7352a89 100644
--- a/l10n_it_fatturapa_in/models/account.py
+++ b/l10n_it_fatturapa_in/models/account.py
@@ -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)
@@ -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
diff --git a/l10n_it_fatturapa_in/models/company.py b/l10n_it_fatturapa_in/models/company.py
index 0fdeb8871fcb..065ddf77aaa9 100644
--- a/l10n_it_fatturapa_in/models/company.py
+++ b/l10n_it_fatturapa_in/models/company.py
@@ -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')
diff --git a/l10n_it_fatturapa_in/static/description/index.html b/l10n_it_fatturapa_in/static/description/index.html
index 84b58142da16..364f67320ce0 100644
--- a/l10n_it_fatturapa_in/static/description/index.html
+++ b/l10n_it_fatturapa_in/static/description/index.html
@@ -367,7 +367,7 @@ Italian Localization - Fattura Elettronica reception
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This module allows to import XML files of electronic invoices, version 1.2
http://www.fatturapa.gov.it/export/fatturazione/it/normativa/f-2.htm
received through the exchange system (SDI)
@@ -424,7 +424,7 @@
Bugs are tracked on GitHub 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 .
+feedback .
Do not contact contributors directly about support or help with technical issues.
@@ -451,7 +451,7 @@
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 project on GitHub.
+
This module is part of the OCA/l10n-italy project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute .
diff --git a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
index a6c992d36198..b34521b5b14c 100644
--- a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
+++ b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
@@ -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
@@ -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)
@@ -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(
@@ -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
@@ -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].
@@ -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')
diff --git a/l10n_it_fatturapa_in/views/account_view.xml b/l10n_it_fatturapa_in/views/account_view.xml
index c5798f3e632e..d2cd2f9d5414 100644
--- a/l10n_it_fatturapa_in/views/account_view.xml
+++ b/l10n_it_fatturapa_in/views/account_view.xml
@@ -9,7 +9,13 @@
-
+
+
+
+
+
+
@@ -20,7 +26,6 @@
-
res.config.settings
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
Supplier Invoices
+
+
+ Default products used in electronic supplier invoices
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py b/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py
index 102d0c2b4c1c..3dc54faa2daf 100644
--- a/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py
+++ b/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py
@@ -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
@@ -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:
@@ -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,
@@ -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 '',