Skip to content

Commit

Permalink
[MIG] l10n_it_fatturapa_pec: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso committed Jul 6, 2023
1 parent 35e914b commit cf6fbfa
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 78 deletions.
15 changes: 8 additions & 7 deletions l10n_it_fatturapa_pec/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ ITA - Fattura elettronica - Supporto PEC
: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_pec
:target: https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_fatturapa_pec
: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_pec
:target: https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_fatturapa_pec
: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/14.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/l10n-italy&target_branch=16.0
:alt: Try me on Runboat

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

Expand Down Expand Up @@ -128,7 +128,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_pec%0Aversion:%2014.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_pec%0Aversion:%2016.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 All @@ -155,6 +155,7 @@ Contributors
* `Ooops <https://www.ooops404.com>`_:

* Giovanni Serra <[email protected]>
* Giuseppe Borruso <[email protected]>

Maintainers
~~~~~~~~~~~
Expand All @@ -169,6 +170,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/14.0/l10n_it_fatturapa_pec>`_ project on GitHub.
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_fatturapa_pec>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions l10n_it_fatturapa_pec/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

{
"name": "ITA - Fattura elettronica - Supporto PEC",
"version": "14.0.1.1.0",
"version": "16.0.1.0.0",
"category": "Localization/Italy",
"summary": "Invio fatture elettroniche tramite PEC",
"author": "Openforce Srls Unipersonale, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-italy",
"license": "AGPL-3",
"depends": [
"fetchmail",
"mail",
"l10n_it_fatturapa_out",
"l10n_it_fatturapa_in",
"l10n_it_sdi_channel",
Expand Down
14 changes: 7 additions & 7 deletions l10n_it_fatturapa_pec/data/config_parameter.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<record id="sdi_pec_first_address" model="ir.config_parameter">
<field name="key">sdi.pec.first.address</field>
<field name="value">[email protected]</field>
</record>
</data>
<odoo noupdate="1">

<record id="sdi_pec_first_address" model="ir.config_parameter">
<field name="key">sdi.pec.first.address</field>
<field name="value">[email protected]</field>
</record>

</odoo>
14 changes: 7 additions & 7 deletions l10n_it_fatturapa_pec/data/fetchmail_data.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<record id="fetchmail_pec_max_retry" model="ir.config_parameter">
<field name="key">fetchmail.pec.max.retry</field>
<field name="value">5</field>
</record>
</data>
<odoo noupdate="1">

<record id="fetchmail_pec_max_retry" model="ir.config_parameter">
<field name="key">fetchmail.pec.max.retry</field>
<field name="value">5</field>
</record>

</odoo>
18 changes: 0 additions & 18 deletions l10n_it_fatturapa_pec/migrations/14.0.1.0.4/pre-migration.py

This file was deleted.

2 changes: 1 addition & 1 deletion l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FatturaPAAttachmentOut(models.Model):
default="No response yet",
readonly=True,
)
sending_user = fields.Many2one("res.users", "Sending User", readonly=True)
sending_user = fields.Many2one("res.users", readonly=True)

@api.model
def _check_fetchmail(self):
Expand Down
6 changes: 4 additions & 2 deletions l10n_it_fatturapa_pec/models/fetchmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ def manage_pec_failure(self, exception, error_messages):
def notify_about_server_reset(self):
self.ensure_one()
self.notify_or_log(
_("PEC server %s has been reset. Last error message is '%s'")
% (self.name, self.last_pec_error_message)
_(
"PEC server %(name)s has been reset. Last error message is '%(error_message)s'"
)
% {"name": self.name, "error_message": self.last_pec_error_message}
)

def notify_or_log(self, message):
Expand Down
19 changes: 10 additions & 9 deletions l10n_it_fatturapa_pec/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,19 @@ def message_route(
return self.manage_pec_sdi_response(att, message_dict)
raise UserError(
_(
'PEC message "%s" has been read '
'PEC message "%(subject)s" has been read '
"but not processed, as not related to an "
"e-invoice.\n"
"Please check PEC mailbox %s, at server %s,"
" with user %s."
)
% (
message_dict["subject"],
fetchmail_server.name,
fetchmail_server.server,
fetchmail_server.user,
"Please check PEC mailbox %(fetchmail_name)s, "
"at server %(fetchmail_server)s,"
" with user %(fetchmail_user)s."
)
% {
"subject": message_dict["subject"],
"fetchmail_name": fetchmail_server.name,
"fetchmail_server": fetchmail_server.server,
"fetchmail_user": fetchmail_server.user,
}
)
return super(MailThread, self).message_route(
message,
Expand Down
18 changes: 14 additions & 4 deletions l10n_it_fatturapa_pec/models/sdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ def check_fetch_pec_server_id(self):
elements = self.search(domain)
if len(elements) > 1:
raise exceptions.ValidationError(
_("The channel %s with pec server %s already exists")
% (channel.name, channel.fetch_pec_server_id.name)
_(
"The channel %(name)s with pec server %(server_name)s already exists"
)
% {
"name": channel.name,
"server_name": channel.fetch_pec_server_id.name,
}
)

@api.constrains("pec_server_id")
Expand All @@ -60,8 +65,13 @@ def check_pec_server_id(self):
elements = self.search(domain)
if len(elements) > 1:
raise exceptions.ValidationError(
_("The channel %s with pec server %s already exists")
% (channel.name, channel.pec_server_id.name)
_(
"The channel %(name)s with pec server %(server_name)s already exists"
)
% {
"name": channel.name,
"server_name": channel.pec_server_id.name,
}
)

@api.constrains("email_exchange_system")
Expand Down
1 change: 1 addition & 0 deletions l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
* `Ooops <https://www.ooops404.com>`_:

* Giovanni Serra <[email protected]>
* Giuseppe Borruso <[email protected]>
9 changes: 5 additions & 4 deletions l10n_it_fatturapa_pec/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>ITA - Fattura elettronica - Supporto PEC</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">ITA - Fattura elettronica - Supporto PEC</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/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" href="https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_fatturapa_pec"><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-14-0/l10n-italy-14-0-l10n_it_fatturapa_pec"><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/14.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/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" href="https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_fatturapa_pec"><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-16-0/l10n-italy-16-0-l10n_it_fatturapa_pec"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/webui/builds.html?repo=OCA/l10n-italy&amp;target_branch=16.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>Questo modulo consente di inviare e ricevere i file XML della fattura elettronica versione 1.2</p>
<p><a class="reference external" href="http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm">http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm</a></p>
Expand Down Expand Up @@ -441,7 +441,7 @@ <h1><a class="toc-backref" href="#id3">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_pec%0Aversion:%2014.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_pec%0Aversion:%2016.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 @@ -467,6 +467,7 @@ <h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<li>Giovanni Serra &lt;<a class="reference external" href="mailto:giovanni&#64;gslab.it">giovanni&#64;gslab.it</a>&gt;</li>
</ul>
</li>
<li>Giuseppe Borruso &lt;<a class="reference external" href="mailto:gborruso&#64;dinamicheaziendali.it">gborruso&#64;dinamicheaziendali.it</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -476,7 +477,7 @@ <h2><a class="toc-backref" href="#id7">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/14.0/l10n_it_fatturapa_pec">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/16.0/l10n_it_fatturapa_pec">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
21 changes: 12 additions & 9 deletions l10n_it_fatturapa_pec/tests/e_invoice_common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright 2018 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.tests import Form

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


Expand Down Expand Up @@ -29,32 +31,33 @@ def setUp(self):
dict(
code="REC",
name="Receivable",
user_type_id=self.ref("account.data_account_type_receivable"),
account_type="asset_receivable",
reconcile=True,
)
)
self.account_income_id = self.account_model.create(
dict(
code="INC",
name="Income",
user_type_id=self.ref("account.data_account_type_revenue"),
account_type="income",
reconcile=True,
)
)
self.partner = self.env.ref("l10n_it_fatturapa.res_partner_fatturapa_2")
self.product = self.env.ref("product.product_product_5")
self.env.company.sdi_channel_id = self.env.ref(
"l10n_it_fatturapa_pec.sdi_channel_pec"
)
self.env.company.sdi_channel_id.pec_server_id = self.env[
"ir.mail_server"
].create(
sdi_channel_form = Form(self.env["sdi.channel"])
sdi_channel_form.name = "PEC"
sdi_channel_form.channel_type = "pec"
sdi_channel_form.pec_server_id = self.env["ir.mail_server"].create(
{
"name": "dummy",
"smtp_host": "smtp_host",
"email_from_for_fatturaPA": "[email protected]",
}
)
sdi_channel_form.fetch_pec_server_id = self._create_fetchmail_pec_server()
self.sdi_channel_id = sdi_channel_form.save()
self.env.company.sdi_channel_id = self.sdi_channel_id.id

def _create_invoice(self):
tax = self.tax_model.create(
Expand Down Expand Up @@ -84,7 +87,7 @@ def _create_invoice(self):

def _get_export_wizard(self, invoice):
wizard = self.wizard_model.create({})
return wizard.with_context({"active_ids": [invoice.id]})
return wizard.with_context(active_ids=[invoice.id])

def _create_e_invoice(self):
invoice = self._create_invoice()
Expand Down
3 changes: 1 addition & 2 deletions l10n_it_fatturapa_pec/tests/test_e_invoice_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def setUp(self):
super(TestEInvoiceResponse, self).setUp()
self.PEC_server = self._create_fetchmail_pec_server()
self.env.company.vat = "IT03339130126"
self.set_sequences(15, "2018-01-07")
self.attach_in_model = self.env["fatturapa.attachment.in"]

@staticmethod
Expand Down Expand Up @@ -134,7 +133,7 @@ def test_process_response_INVIO_broken_XML(self):
error_mails_nbr = outbound_mail_model.search_count(error_mail_domain)
self.assertFalse(error_mails_nbr)

with mock.patch("odoo.addons.fetchmail.models.fetchmail.POP3") as mock_pop3:
with mock.patch("odoo.addons.mail.models.fetchmail.POP3") as mock_pop3:
instance = mock_pop3.return_value
instance.stat.return_value = (1, 1)
instance.retr.return_value = ("", [incoming_mail], "")
Expand Down
6 changes: 6 additions & 0 deletions l10n_it_fatturapa_pec/tests/test_e_invoice_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ def test_send_check_fetchmail(self):
PEC server configured raises UserError"""
e_invoice = self._create_e_invoice()

# Remove PEC server
self.sdi_channel_id.fetch_pec_server_id.is_fatturapa_pec = False

# There is no PEC server configured
with self.assertRaises(UserError):
e_invoice.send_via_pec()

# Add PEC server
self.sdi_channel_id.fetch_pec_server_id.is_fatturapa_pec = True

@mute_logger("odoo.addons.mail.models.mail_mail")
def test_sender_error(self):
"""Sending e-invoice without configuring email_from_for_fatturaPA
Expand Down
19 changes: 14 additions & 5 deletions l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,22 @@
name="inherit_id"
ref="l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form"
/>
<field
name="groups_id"
eval="[(4,ref('l10n_it_fatturapa_pec.group_force_e_inv_export_state'))]"
/>
<field name="arch" type="xml">
<field name="state" position="attributes">
<attribute name="clickable">1</attribute>
<attribute name="invisible">1</attribute>
</field>
<field name="state" position="after">
<field
name="state"
groups="!l10n_it_fatturapa_pec.group_force_e_inv_export_state"
widget="statusbar"
/>
<field
name="state"
groups="l10n_it_fatturapa_pec.group_force_e_inv_export_state"
widget="statusbar"
clickable="1"
/>
</field>
</field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_fatturapa_pec/views/fetchmail_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<record id="view_email_server_form_e_invoice" model="ir.ui.view">
<field name="name">view_email_server_form_e_invoice</field>
<field name="model">fetchmail.server</field>
<field name="inherit_id" ref="fetchmail.view_email_server_form" />
<field name="inherit_id" ref="mail.view_email_server_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='server_type']" position="after">
<field name="is_fatturapa_pec" />
Expand Down

0 comments on commit cf6fbfa

Please sign in to comment.