From 320efea40c3e9c144e5a0c894e7fb856334e0599 Mon Sep 17 00:00:00 2001 From: Johan De Taeye Date: Tue, 8 Oct 2024 18:40:00 +0200 Subject: [PATCH] set correct warehouse for PO exported from frepple --- frepple/controllers/inbound.py | 40 +++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/frepple/controllers/inbound.py b/frepple/controllers/inbound.py index 5f1d2754..7c2fd1a4 100644 --- a/frepple/controllers/inbound.py +++ b/frepple/controllers/inbound.py @@ -281,16 +281,36 @@ def run(self): # Create purchase order if supplier_id not in supplier_reference: - po = proc_order.create( - { - "company_id": self.company.id, - "partner_id": supplier_id, - # TODO Odoo has no place to store the location and criticality - # int(elem.get('location_id')), - # elem.get('criticality'), - "origin": "frePPLe", - } - ) + po_args = { + "company_id": self.company.id, + "partner_id": supplier_id, + "origin": "frePPLe", + } + try: + picking_type_id = stck_picking_type.search( + [ + ("code", "=", "incoming"), + ( + "warehouse_id", + "=", + int(elem.get("location_id")), + ), + ], + limit=1, + )[:1] + if not picking_type_id: + picking_type_id = stck_picking_type.search( + [ + ("code", "=", "incoming"), + ("warehouse_id", "=", False), + ], + limit=1, + )[:1] + if picking_type_id: + po_args["picking_type_id"] = picking_type_id.id + except Exception: + pass + po = proc_order.create(po_args) po.payment_term_id = ( po.partner_id.property_supplier_payment_term_id.id )