-
-
Notifications
You must be signed in to change notification settings - Fork 344
[18.0][IMP]l10n_it_delivery_note: electronic invoicing DatiDdt #5048
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
base: 18.0
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| "maintainers": ["MarcoCalcagni", "aleuffre", "renda-dev"], | ||
| "depends": [ | ||
| "delivery_carrier_partner", | ||
| "l10n_it_stock_ddt", | ||
| "mail", | ||
| "sale", | ||
| "sale_stock", | ||
|
|
@@ -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", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inoltre: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. capito, nascondiamo anche quello |
||
|
|
||
| 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> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E in
ci sono? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
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> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. chiamando super, se la fattura ha There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| @property | ||
| def _delivery_note_fields(self): | ||
| from collections import OrderedDict | ||
|
|
||

There was a problem hiding this comment.
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_iddil10n_it_edinon è anche lui da nascondere, in quanto non più usato per l'XML?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Si, meglio nasconderlo