Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
113 changes: 76 additions & 37 deletions l10n_it_delivery_note/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

============================
ITA - Documento di trasporto
============================
Expand All @@ -11,13 +7,13 @@ ITA - Documento di trasporto
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:dfdd6f11110f3e834e26048a8e73d0e41a5d20f09ec6b2fdd529821fc0c6d38d
!! source digest: sha256:7e407a63e5642e24e05e9d2b3c84749acf0f77abf7825e750f7b1d84cccddd54
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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
Expand Down Expand Up @@ -48,8 +44,28 @@ installed together.

There are two available settings:

- Base (default): one picking, one DN.
- Advanced: more picking in one DN.
- Base (default): one picking, one DN.
- Advanced: more picking in one DN.

**Electronic Invoicing Integration**

This module integrates with Italian electronic invoicing
(``l10n_it_stock_ddt``).

It automatically adds Delivery Note references to the FatturaPA XML,
including:

- DDT Number
- DDT Date
- Line references

The module also handles the distinction between immediate and deferred
invoices:

- **TD01 (Immediate invoice)**: when the invoice has the same date as
the linked DDTs
- **TD24 (Deferred invoice)**: when the invoice is issued on a
different day than the DDTs

**Italiano**

Expand All @@ -66,8 +82,28 @@ Non è possibile avere installati contemporaneamente ``l10n_it_ddt`` e

Ci sono due impostazioni possibili.

- Base (predefinita): un prelievo, un DDT.
- Avanzata: più prelievi in un DDT.
- Base (predefinita): un prelievo, un DDT.
- Avanzata: più prelievi in un DDT.

**Integrazione Fatturazione Elettronica**

Questo modulo si integra con la fatturazione elettronica italiana
(``l10n_it_stock_ddt``).

Aggiunge automaticamente i riferimenti ai DDT nell'XML della FatturaPA,
includendo:

- Numero del DDT
- Data del DDT
- Riferimenti alle righe

Il modulo gestisce anche la distinzione tra fatture immediate e
differite:

- **TD01 (Fattura immediata)**: quando la fattura ha la stessa data dei
DDT collegati
- **TD24 (Fattura differita)**: quando la fattura è emessa in un giorno
diverso rispetto ai DDT

**Table of contents**

Expand Down Expand Up @@ -100,11 +136,14 @@ To configure this module, go to:
In delivery note type you can specify if the product price have to be
printed in the delivery note report/slip.

- *Inventory → Configuration → Delivery Notes → Conditions of
Transport*
- *Inventory → Configuration → Delivery Notes → Appearances of Goods*
- *Inventory → Configuration → Delivery Notes → Reasons of Transport*
- *Inventory → Configuration → Delivery Notes → Methods of Transport*
- *Inventory → Configuration → Delivery Notes → Conditions of
Transport*
- *Inventory → Configuration → Delivery Notes → Appearances of
Goods*
- *Inventory → Configuration → Delivery Notes → Reasons of
Transport*
- *Inventory → Configuration → Delivery Notes → Methods of
Transport*

3. *Settings → User & Companies → Users*

Expand Down Expand Up @@ -142,10 +181,10 @@ Funzionalità avanzata

Vengono attivate varie funzionalità aggiuntive:

- più prelievi per un DDT
- selezione multipla di prelievi e generazione dei DDT
- aggiunta righe nota e righe sezione descrittive.
- lista dei DDT.
- più prelievi per un DDT
- selezione multipla di prelievi e generazione dei DDT
- aggiunta righe nota e righe sezione descrittive.
- lista dei DDT.

Il report DDT stampa in righe aggiuntive i lotti/seriali e le scadenze
del prodotto.
Expand Down Expand Up @@ -187,39 +226,39 @@ Authors
Contributors
------------

- Riccardo Bellanova <r.bellanova@apuliasoftware.it>
- Riccardo Bellanova <r.bellanova@apuliasoftware.it>

- Matteo Bilotta <mbilotta@linkeurope.it>
- Matteo Bilotta <mbilotta@linkeurope.it>

- Giuseppe Borruso <gborruso@dinamicheaziendali.it>
- Giuseppe Borruso <gborruso@dinamicheaziendali.it>

- Marco Calcagni <mcalcagni@dinamicheaziendali.it>
- Marco Calcagni <mcalcagni@dinamicheaziendali.it>

- Marco Colombo <marco.colombo@gmail.com>
- Marco Colombo <marco.colombo@gmail.com>

- Gianmarco Conte <gconte@dinamicheaziendali.it>
- Gianmarco Conte <gconte@dinamicheaziendali.it>

- Letizia Freda <letizia.freda@netfarm.it>
- Letizia Freda <letizia.freda@netfarm.it>

- Andrea Piovesana <andrea.m.piovesana@gmail.com>
- Andrea Piovesana <andrea.m.piovesana@gmail.com>

- Alex Comba <alex.comba@agilebg.com>
- Alex Comba <alex.comba@agilebg.com>

- `Ooops <https://www.ooops404.com>`__:
- `Ooops <https://www.ooops404.com>`__:

- Giovanni Serra <giovanni@gslab.it>
- Foresti Francesco <francesco.foresti@ooops404.com>
- Giovanni Serra <giovanni@gslab.it>
- Foresti Francesco <francesco.foresti@ooops404.com>

- Nextev Srl <odoo@nextev.it>
- Nextev Srl <odoo@nextev.it>

- `PyTech-SRL <https://www.pytech.it>`__:
- `PyTech-SRL <https://www.pytech.it>`__:

- Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it>
- Sebastiano Picchi <sebastiano.picchi@pytech.it>
- Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it>
- Sebastiano Picchi <sebastiano.picchi@pytech.it>

- `Aion Tech <https://aiontech.company/>`__:
- `Aion Tech <https://aiontech.company/>`__:

- Simone Rubino <simone.rubino@aion-tech.it>
- Simone Rubino <simone.rubino@aion-tech.it>

Maintainers
-----------
Expand Down
2 changes: 2 additions & 0 deletions l10n_it_delivery_note/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"maintainers": ["MarcoCalcagni", "aleuffre", "renda-dev"],
"depends": [
"delivery_carrier_partner",
"l10n_it_stock_ddt",
"mail",
"sale",
"sale_stock",
Expand All @@ -34,6 +35,7 @@
"security/res_groups.xml",
"security/res_users.xml",
"data/delivery_note_data.xml",
"data/l10n_it_delivery_note_template.xml",
"report/delivery_data.xml",
"report/report_delivery_note.xml",
"views/account_move.xml",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il campo l10n_it_ddt_id di l10n_it_edi non è anche lui da nascondere, in quanto non più usato per l'XML?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si, meglio nasconderlo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inoltre: l10n_it_stock_ddt aggiunge un pulsante "DDTs" sulla fattura che mostra i picking. Mi pare che l10n_it_delivery_note aggiunga già il suo pulsante , quindi quello di l10n_it_stock_ddt sarebbe da nascondere

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capito, nascondiamo anche quello

Expand Down
35 changes: 35 additions & 0 deletions l10n_it_delivery_note/data/l10n_it_delivery_note_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template
id="l10n_it_delivery_note_data"
inherit_id="l10n_it_edi.account_invoice_it_FatturaPA_export"
priority="99"
>
<!-- Replace the DatiDDT block with l10n_it_ddt_id condition -->
<xpath expr='//DatiDDT[@t-if="record.l10n_it_ddt_id"]' position="replace">
<t t-if="dati_ddt_list" t-foreach="dati_ddt_list" t-as="ddt_data">
<DatiDDT>
<NumeroDDT
t-if="ddt_data.get('NumeroDDT')"
t-esc="format_alphanumeric(ddt_data['NumeroDDT'][-20:])"
/>
<DataDDT t-esc="format_date(ddt_data['DataDDT'])" />
<t
t-if="ddt_data.get('RiferimentoNumeroLinea') and len(dati_ddt_list) > 1"
t-foreach="ddt_data.get('RiferimentoNumeroLinea')"
t-as="NumeroLinea"
>
<RiferimentoNumeroLinea t-esc="NumeroLinea" />
</t>
</DatiDDT>
</t>
</xpath>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E in DatiTrasporto attualmente cosa ci finisce?

  • MezzoTrasporto / CausaleTrasporto
  • NumeroColli / PesoLordo / PesoNetto
  • DataOraRitiro / DataInizioTrasporto

ci sono?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non ho capito bene, ma il template principale è in l10n_it_edi_extension.

Il template in invoice_it_template.xml popola solo il sotto-tag di DatiTrasporto, ovvero IndirizzoResa, con:

  • indirizzo,
  • CAP,
  • comune,
  • provincia,
  • nazione.

Le voci che hai indicato non sono al suo interno.

<!-- Replace the DatiDDT block with ddt_dict condition -->
<xpath
expr='//t[@t-if="ddt_dict and not record.l10n_it_ddt_id"]'
position="replace"
>
<!-- Do nothing - we only want delivery note DDTs, not picking DDTs -->
</xpath>
</template>
</odoo>
82 changes: 82 additions & 0 deletions l10n_it_delivery_note/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,85 @@ def button_cancel(self): # pylint: disable=missing-return
dn_lines.sync_invoice_status()
dn_lines.delivery_note_id._compute_invoice_status()
dn_lines.delivery_note_id.state = "confirm"

def _l10n_it_edi_invoice_is_direct(self):
"""An invoice is direct if ddt are all done the same day as the invoice."""
if self.delivery_note_ids:
return all(
ddt.date and ddt.date == self.invoice_date
for ddt in self.delivery_note_ids
)
return super()._l10n_it_edi_invoice_is_direct()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chiamando super, se la fattura ha l10n_it_ddt_ids e le date corrispondono, ritorna True ; questo non produce una classificazione TD01/TD24 sbagliata? dovremmo considerare solo le date dei delivery note?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hai ragione, non bisogna delegare al super, se la fattura ha delivery note è meglio usare quella.


def _l10n_it_edi_get_values(self, pdf_values=None):
"""Extend to add dati_ddt_list for delivery notes."""
values = super()._l10n_it_edi_get_values(pdf_values)
values["dati_ddt_list"] = self._get_dati_ddt()
return values

def _get_dati_ddt(self):
"""
Get the data for rendering DatiDDT.

:return: a list of dictionaries, with one dictionary per involved DdT.
Each dictionary has shape:
{
'_delivery_note': <stock.delivery.note record of the involved the DdT>,
'NumeroDDT': <string representing the DdT>,
'DataDDT': <date of the DdT>,
'_invoice_lines': (optional)
<account.move.line records of invoice lines involved in the DdT>,
'RiferimentoNumeroLinea': (optional)
<list of integers representing invoice line numbers>,
}
"""
self.ensure_one()
dati_ddt_list = []

if not self.delivery_note_ids:
return dati_ddt_list

e_invoice_lines = self.line_ids.filtered(
lambda x: x.display_type == "product"
).sorted(lambda line: line.sequence)
e_invoice_lines_list = list(e_invoice_lines)

for delivery_note in self.delivery_note_ids:
ddt_data = {
"_delivery_note": delivery_note,
"NumeroDDT": delivery_note.name,
"DataDDT": delivery_note.date,
}

# Find invoice lines linked to this delivery note
e_invoice_delivery_note_lines = e_invoice_lines.filtered(
lambda line, dn=delivery_note: line.delivery_note_id == dn
)

if e_invoice_delivery_note_lines:
# RiferimentoNumeroLinea contains 1-based line numbers
lines_refs_list = [
e_invoice_lines_list.index(line) + 1
for line in e_invoice_delivery_note_lines
]
ddt_data.update(
{
"_invoice_lines": e_invoice_delivery_note_lines,
"RiferimentoNumeroLinea": lines_refs_list,
}
)
elif len(self.delivery_note_ids) == 1:
# If there's only one DDT and no lines are linked, include all lines
# This handles the case where update_delivery_note_lines() wasn't called
ddt_data.update(
{
"_invoice_lines": e_invoice_lines,
"RiferimentoNumeroLinea": list(
range(1, len(e_invoice_lines_list) + 1)
),
}
)

dati_ddt_list.append(ddt_data)

return dati_ddt_list
20 changes: 20 additions & 0 deletions l10n_it_delivery_note/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,26 @@ class StockPicking(models.Model):
dn_supplier_number = fields.Char(string="Supplier DN Number", copy=False)
dn_supplier_date = fields.Date(string="Supplier DN Date", copy=False)

l10n_it_ddt_number = fields.Char(
compute="_compute_l10n_it_ddt_number",
store=True,
readonly=False,
)

@api.depends("delivery_note_id.name")
def _compute_l10n_it_ddt_number(self):
for picking in self:
if picking.delivery_note_id:
picking.l10n_it_ddt_number = picking.delivery_note_id.name
else:
picking.l10n_it_ddt_number = False

def _action_done(self):
result = super()._action_done()
for picking in self.filtered(lambda p: p.delivery_note_id):
picking.write({"l10n_it_ddt_number": picking.delivery_note_id.name})
return result

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aggiunto per far funzionare i filtri di odoo standard.

Image

@eLBati puoi aggiornare la review?

@property
def _delivery_note_fields(self):
from collections import OrderedDict
Expand Down
26 changes: 26 additions & 0 deletions l10n_it_delivery_note/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ There are two available settings:
- Base (default): one picking, one DN.
- Advanced: more picking in one DN.

**Electronic Invoicing Integration**

This module integrates with Italian electronic invoicing (`l10n_it_stock_ddt`).

It automatically adds Delivery Note references to the FatturaPA XML, including:
- DDT Number
- DDT Date
- Line references

The module also handles the distinction between immediate and deferred invoices:
- **TD01 (Immediate invoice)**: when the invoice has the same date as the linked DDTs
- **TD24 (Deferred invoice)**: when the invoice is issued on a different day than the DDTs

**Italiano**

Questo modulo consente di gestire i DDT.
Expand All @@ -34,3 +47,16 @@ Ci sono due impostazioni possibili.

- Base (predefinita): un prelievo, un DDT.
- Avanzata: più prelievi in un DDT.

**Integrazione Fatturazione Elettronica**

Questo modulo si integra con la fatturazione elettronica italiana (`l10n_it_stock_ddt`).

Aggiunge automaticamente i riferimenti ai DDT nell'XML della FatturaPA, includendo:
- Numero del DDT
- Data del DDT
- Riferimenti alle righe

Il modulo gestisce anche la distinzione tra fatture immediate e differite:
- **TD01 (Fattura immediata)**: quando la fattura ha la stessa data dei DDT collegati
- **TD24 (Fattura differita)**: quando la fattura è emessa in un giorno diverso rispetto ai DDT
Loading
Loading