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

[16.0] [REF] Comunicazione con SdI tramite WebService (SDICoop) + allineamento generale di l10n_it_sdi_channel #3785

Merged
merged 50 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5e3f068
[IMP] l10n_it_fatturapa: Common objects and views for SdI files
SirTakobi May 20, 2022
2f35f6b
[REF] l10n_it_fatturapa_in: Use common objects and views for SdI files
SirTakobi May 20, 2022
a27bbe6
[REF] l10n_it_fatturapa_out: Use common objects and views for SdI files
SirTakobi May 20, 2022
85a77b7
[IMP] l10n_it_sdi_channel: Generic send method for Electronic Invoices
SirTakobi May 20, 2022
abb391f
[REF] l10n_it_fatturapa_pec: Use SdI channel's send method
SirTakobi May 20, 2022
028ebc0
[IMP] l10n_it_sdi_channel: Generic method to receive FE from SdI
SirTakobi May 23, 2022
daa0892
[REF] l10n_it_fatturapa_pec: Use SdI channel's generic method to rece…
SirTakobi May 23, 2022
9b2c47a
[IMP] l10n_it_sdi_channel: Generic method to receive notification fro…
SirTakobi May 23, 2022
ef06c08
[REF] l10n_it_fatturapa_pec: Use common objects and views for SdI files
SirTakobi May 23, 2022
1089500
[REF] l10n_it_fatturapa_pec: Do not constrain or check other channel …
SirTakobi Jun 9, 2022
4a1f20a
[IMP] l10n_it_fatturapa_out: Allow a specific group to force attachme…
SirTakobi Jun 21, 2022
881109b
[REF] l10n_it_fatturapa_pec: Group to force attachment.out state move…
SirTakobi Jun 21, 2022
d8be43c
FIX l10n_it_fatturapa: Il campo "id" non esiste nel modello "fatturap…
eLBati Dec 14, 2023
f9f0999
FIX l10n_it_fatturapa: Il campo "datas" non esiste nel modello "fattu…
eLBati Dec 14, 2023
8244700
FIX l10n_it_fatturapa_out: La vista ereditata non può avere "Gruppi" …
eLBati Dec 14, 2023
e555aad
[ADD] l10n_it_fatturapa_sdicoop
SirTakobi May 20, 2022
5667a51
[REF] l10n_it_fatturapa_sdicoop: Test one button to validate, export …
SirTakobi Jul 14, 2022
0fe6eb0
[IMP] l10n_it_fatturapa_sdicoop: Test notification for E-bill
SirTakobi Jul 25, 2022
f66abb3
Reformatted after template update
SirTakobi Aug 5, 2022
c532f5c
Manually fix manifest website key
SirTakobi Aug 5, 2022
ba31d22
[IMP] l10n_it_fatturapa_sdicoop: pre-commit execution
SirTakobi Jan 4, 2023
e7e1d81
[MIG] l10n_it_fatturapa_sdicoop: Migration to 14.0
SirTakobi Jan 4, 2023
5412087
[UPD] Update l10n_it_fatturapa_sdicoop.pot
Mar 24, 2023
a221824
[UPD] README.rst
OCA-git-bot Mar 24, 2023
d3a2cc3
Added translation using Weblate (Italian)
francesco-ooops Apr 7, 2023
3bfafb8
Translated using Weblate (Italian)
francesco-ooops Apr 7, 2023
3ab9c6b
[UPD] README.rst
OCA-git-bot Sep 3, 2023
c497037
porting l10n_it_fatturapa_sdicoop to 16.0
eLBati Dec 14, 2023
8583931
[IMP] l10n_it_fatturapa_out: Show sending/delivering data
SirTakobi Mar 14, 2023
4ae2db9
[IMP] l10n_it_sdi_channel: Show SdI response
SirTakobi Mar 14, 2023
8593d7d
[IMP] l10n_it_fatturapa_pec: Use common Sending User
SirTakobi Mar 14, 2023
06ebabb
[IMP] l10n_it_sdi_channel: One button to validate, export and send
SirTakobi Jul 14, 2022
944c3bf
[REF] l10n_it_fatturapa_pec: Test one button to validate, export and …
SirTakobi Jul 14, 2022
cbb070e
[IMP] l10n_it_sdi_channel: Allow user to be notified of new e-bills o…
SirTakobi Jul 25, 2022
256d6f1
Use related field for channel_id, avoid to directly write channel_id,…
eLBati Jun 24, 2022
fadfc33
[FIX] l10n_it_sdi_channel: Subscribe to related channel
SirTakobi Jul 25, 2022
4f2b3e0
[REF] l10n_it_fatturapa_pec: Channel in a company must be owned by th…
SirTakobi Jan 5, 2023
827cb28
[COV] l10n_it_sdi_channel: Test State tracking
SirTakobi Mar 15, 2023
a95ad23
FIX l10n_it_sdi_channel: DeprecationWarning: Deprecated method flush(…
eLBati Dec 14, 2023
f562808
FIX l10n_it_fatturapa_sdicoop: Due to security restrictions, you are …
eLBati Dec 14, 2023
2da29dd
[14.0] l10n_it_fatturapa_in: forward port of https://github.com/OCA/l…
SirTakobi Jul 7, 2023
cc54fab
[14.0] l10n_it_fatturapa_pec: forward port of https://github.com/OCA/…
SirTakobi Jul 7, 2023
dafdc15
FIX l10n_it_sdi_channel avoiding not needed flush and test. Tests sho…
eLBati Dec 18, 2023
2cdf7a7
FIX l10n_it_fatturapa_pec tests
eLBati Dec 18, 2023
bca7d80
FIX l10n_it_fatturapa_in test avoiding error lines in logs
eLBati Dec 18, 2023
30b8a6c
[FIX] l10n_it_fatturapa_import_zip: Adapt to new signature
SirAionTech Dec 6, 2023
97469fa
pre-commit run
eLBati Dec 18, 2023
2d619eb
[14.0] .pre-commit-config.yaml: reintroduce ignore for test data
TheMule71 Jul 7, 2023
20a4fa1
FIX porting l10n_it_sdi_channel using with_user
eLBati Dec 21, 2023
f143cf4
pre-commit
eLBati Mar 1, 2024
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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,4 @@ repos:
- id: pylint_odoo
args:
- --rcfile=.pylintrc-mandatory
- --ignore=l10n_it_fatturapa_in/tests/data/
1 change: 1 addition & 0 deletions l10n_it_fatturapa/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"views/account_view.xml",
"views/company_view.xml",
"views/partner_view.xml",
"views/fatturapa_attachment_views.xml",
"views/related_document_type_views.xml",
"security/ir.model.access.csv",
],
Expand Down
3 changes: 2 additions & 1 deletion l10n_it_fatturapa/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
)
def pdf_preview(self, attachment_id, **data):
attach = request.env["ir.attachment"].browse(int(attachment_id))
html = attach.get_fattura_elettronica_preview()
fatturapa_attachment_model = request.env["fatturapa.attachment"]
html = fatturapa_attachment_model.get_fattura_elettronica_preview(attach)

Check warning on line 16 in l10n_it_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa/controllers/main.py#L15-L16

Added lines #L15 - L16 were not covered by tests
return request.make_response(html)
53 changes: 42 additions & 11 deletions l10n_it_fatturapa/models/ir_attachment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2022 Simone Rubino - TAKOBI
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import base64
import binascii
import logging
Expand All @@ -6,9 +9,9 @@

import lxml.etree as ET

from odoo import fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.modules import get_resource_path
from odoo.modules import get_module_resource
from odoo.tools.translate import _

_logger = logging.getLogger(__name__)
Expand All @@ -28,17 +31,38 @@
return re_base64.match(s)


class Attachment(models.Model):
_inherit = "ir.attachment"

class FatturaPAAttachment(models.Model):
_name = "fatturapa.attachment"
_description = "SdI file"
_inherits = {
"ir.attachment": "ir_attachment_id",
}
_inherit = [
"mail.thread",
"l10n_it_fatturapa.attachment.e_invoice.link",
]
_order = "id desc"

id = fields.Id()
ir_attachment_id = fields.Many2one(
comodel_name="ir.attachment",
string="Attachment",
required=True,
ondelete="cascade",
)
att_name = fields.Char(
string="SdI file name",
related="ir_attachment_id.name",
store=True,
)
ftpa_preview_link = fields.Char(
"Preview link", readonly=True, compute="_compute_ftpa_preview_link"
)

def _compute_ftpa_preview_link(self):
for att in self:
att.ftpa_preview_link = (
att.get_base_url() + "/fatturapa/preview/%s" % att.id
att.get_base_url() + "/fatturapa/preview/%s" % att.ir_attachment_id.id
)

def ftpa_preview(self):
Expand All @@ -49,6 +73,7 @@
"target": "new",
}

@api.model
def remove_xades_sign(self, xml):
# Recovering parser is needed for files where strings like
# xmlns:ds="http://www.w3.org/2000/09/xmldsig#""
Expand All @@ -66,6 +91,7 @@
ET.cleanup_namespaces(elem)
return ET.tostring(root)

@api.model
def strip_xml_content(self, xml):
recovering_parser = ET.XMLParser(recover=True)
root = ET.XML(xml, parser=recovering_parser)
Expand All @@ -76,14 +102,18 @@
info = cms.ContentInfo.load(data)
return info["content"]["encap_content_info"]["content"].native

@api.model
def cleanup_xml(self, xml_string):
xml_string = self.remove_xades_sign(xml_string)
xml_string = self.strip_xml_content(xml_string)
return xml_string

def get_xml_string(self):
def get_xml_string(self, attachment=None):
if not attachment:
self.ensure_one()
attachment = self.ir_attachment_id
try:
data = base64.b64decode(self.datas)
data = base64.b64decode(attachment.datas)
except binascii.Error as e:
raise UserError(_("Corrupted attachment %s.") % e.args) from e

Expand Down Expand Up @@ -113,8 +143,9 @@
except AttributeError as e:
raise UserError(_("Invalid xml %s.") % e.args) from e

def get_fattura_elettronica_preview(self):
xml_string = self.get_xml_string()
@api.model
def get_fattura_elettronica_preview(self, attachment):
xml_string = self.get_xml_string(attachment)

Check warning on line 148 in l10n_it_fatturapa/models/ir_attachment.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa/models/ir_attachment.py#L148

Added line #L148 was not covered by tests
xml_file = BytesIO(xml_string)
recovering_parser = ET.XMLParser(recover=True)
dom = ET.parse(xml_file, parser=recovering_parser)
Expand All @@ -132,7 +163,7 @@
else:
raise ValidationError(_("Unexpected root element: %s", root_tag))

xsl_path = get_resource_path("l10n_it_fatturapa", "data", preview_style)
xsl_path = get_module_resource("l10n_it_fatturapa", "data", preview_style)

Check warning on line 166 in l10n_it_fatturapa/models/ir_attachment.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa/models/ir_attachment.py#L166

Added line #L166 was not covered by tests
xslt = ET.parse(xsl_path)
transform = ET.XSLT(xslt)
newdom = transform(dom)
Expand Down
1 change: 1 addition & 0 deletions l10n_it_fatturapa/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ access_fatturapa_summary_data_manager,access_fatturapa_summary_data_manager,mode
access_fatturapa_summary_data,access_fatturapa_summary_data,model_fatturapa_summary_data,account.group_account_invoice,1,0,0,0
access_withholding_data_line_manager,access_withholding_data_line_manager,model_withholding_data_line,account.group_account_manager,1,1,1,1
access_withholding_data_line,access_withholding_data_line,model_withholding_data_line,account.group_account_invoice,1,0,0,0
access_fatturapa_attachment,access_fatturapa_attachment,model_fatturapa_attachment,account.group_account_invoice,1,1,1,1
59 changes: 59 additions & 0 deletions l10n_it_fatturapa/views/fatturapa_attachment_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Copyright 2022 Simone Rubino - TAKOBI
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="fatturapa_attachment_view_form" model="ir.ui.view">
<field name="name">Form view for SdI file</field>
<field name="model">fatturapa.attachment</field>
<field name="arch" type="xml">
<form string="SdI file">
<sheet>
<group>
<group name="preview">
<field name='id' invisible="1" />
<label for="datas" />
<div>
<div>
<field name="datas" filename="name" />
</div>
<div>
<button
type="object"
name="ftpa_preview"
string="Show preview"
style="margin-bottom:10px;"
attrs="{'invisible': [('id', '=', False)]}"
/>
</div>
</div>
<field name="name" invisible="True" />
</group>
</group>
<notebook>
<page name="history" string="History">
<label for="create_uid" string="Created by" />
<div name="creation_div">
<field
name="create_uid"
readonly="1"
class="oe_inline"
/> on
<field
name="create_date"
readonly="1"
class="oe_inline"
/>
</div>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
</div>
</form>
</field>
</record>
</odoo>
4 changes: 2 additions & 2 deletions l10n_it_fatturapa_import_zip/models/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,6 @@ class FatturaPAAttachmentOut(models.Model):
ondelete="restrict",
)

def get_invoice_obj(self, fatturapa_attachment):
xml_string = fatturapa_attachment.get_xml_string()
def get_invoice_obj(self):
xml_string = self.get_xml_string()
return efattura.CreateFromDocument(xml_string)
Loading
Loading