From b4227b5f5ee8a7e1bde1f445f35f8b48c1e5a374 Mon Sep 17 00:00:00 2001 From: Thomas Beckers Date: Mon, 13 Nov 2023 13:20:12 +0100 Subject: [PATCH] [FIX] l10n_it_stock_ddt: only get ddt if outgoing picking type When an Italian e-invoice is generated, it will include DDT sequence of DDT stock moves. If those stock moves have picking type different of 'outgoing' (eg: Dropshipping), the picking type does not have DDT sequence leading to a traceback. Now we only consider DDT stock moves if they have the outgoing picking type. Steps to reproduce: - Create local database - Install accounting, purchase, l10n_it_stock_ddt - Switch to Italian company - Activate dropshipping in settings - Put Fattura Elettronica mode in "test" in settings ("demo" mode should be fine to) - Create a a storable dropship product - Create a sale order with dropship product and confirm it - Click on purchase smart button and confirm purchase - Validate to dropship transfer - Create invoice from SO and confirm it (should get the DDT smart button) - Click "Process now" on top of invoice => Traceback opw-3544775 closes odoo/odoo#143461 X-original-commit: 27541b1e9b80db5234aff3a2591d1eb1ce9629a0 Signed-off-by: Brice Bartoletti (bib) --- addons/l10n_it_stock_ddt/models/account_invoice.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/l10n_it_stock_ddt/models/account_invoice.py b/addons/l10n_it_stock_ddt/models/account_invoice.py index b7a9eb609b4..805a8a915d9 100644 --- a/addons/l10n_it_stock_ddt/models/account_invoice.py +++ b/addons/l10n_it_stock_ddt/models/account_invoice.py @@ -47,7 +47,8 @@ class AccountMove(models.Model): invoice_line_pickings = {} for line in self.invoice_line_ids.filtered(lambda l: l.display_type not in ('line_note', 'line_section')): line_count += 1 - done_moves_related = line.sale_line_ids.mapped('move_ids').filtered(lambda m: m.state == 'done' and m.location_dest_id.usage == 'customer') + done_moves_related = line.sale_line_ids.mapped('move_ids').filtered( + lambda m: m.state == 'done' and m.location_dest_id.usage == 'customer' and m.picking_type_id.code == 'outgoing') if len(done_moves_related) <= 1: if done_moves_related and line_count not in invoice_line_pickings.get(done_moves_related.picking_id, []): invoice_line_pickings.setdefault(done_moves_related.picking_id, []).append(line_count)