From 8ead37d377c645189f033c824b1233fd9343c8c5 Mon Sep 17 00:00:00 2001 From: Borruso Date: Wed, 11 May 2022 12:59:25 +0200 Subject: [PATCH] [FIX] l10n_it_delivery_note: fix partner ddt --- l10n_it_delivery_note/models/stock_picking.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/l10n_it_delivery_note/models/stock_picking.py b/l10n_it_delivery_note/models/stock_picking.py index 63050605e338..db2056c9b855 100644 --- a/l10n_it_delivery_note/models/stock_picking.py +++ b/l10n_it_delivery_note/models/stock_picking.py @@ -374,6 +374,7 @@ def _get_partners(self): partner_id = self.mapped("partner_id") src_location_id = self.mapped("location_id") dest_location_id = self.mapped("location_dest_id") + picking_type_code = self.mapped("picking_type_code") src_warehouse_id = src_location_id.get_warehouse() dest_warehouse_id = dest_location_id.get_warehouse() @@ -382,16 +383,16 @@ def _get_partners(self): dest_partner_id = dest_warehouse_id.partner_id if not src_partner_id: - src_partner_id = partner_id - - if not dest_partner_id: - raise ValueError( - "Fields 'src_partner_id' and 'dest_partner_id' " - "cannot be both unset." - ) - - elif not dest_partner_id: - dest_partner_id = partner_id + if picking_type_code == ["outgoing"]: + src_partner_id = self.company_id.partner_id + else: + src_partner_id = partner_id + + if not dest_partner_id: + if picking_type_code == ["incoming"]: + dest_partner_id = self.company_id.partner_id + else: + dest_partner_id = partner_id return (src_partner_id, dest_partner_id)