From d44a5a2741d0144183e93a2764ed748f04b33166 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, 12 insertions(+), 9 deletions(-) diff --git a/l10n_it_delivery_note/models/stock_picking.py b/l10n_it_delivery_note/models/stock_picking.py index 63050605e338..3d9de44406d6 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,18 @@ 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." - ) + src_partner_id = ( + self.company_id.partner_id + if picking_type_code == ["outgoing"] + else partner_id + ) - elif not dest_partner_id: - dest_partner_id = partner_id + if not dest_partner_id: + dest_partner_id = ( + self.company_id.partner_id + if picking_type_code == ["incoming"] + else partner_id + ) return (src_partner_id, dest_partner_id)