From 3cce9bb2e46d8aa4ec0954f9ea152198e0357ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 13 Mar 2024 11:14:35 +0100 Subject: [PATCH] [FIX] stock_picking_delivery_link: Test compatibility with purchase Avoid test errors if the purchase module is installed TT46563 --- .../tests/test_delivery_link.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/stock_picking_delivery_link/tests/test_delivery_link.py b/stock_picking_delivery_link/tests/test_delivery_link.py index af01dd9e51..cc0d64eafd 100644 --- a/stock_picking_delivery_link/tests/test_delivery_link.py +++ b/stock_picking_delivery_link/tests/test_delivery_link.py @@ -26,6 +26,16 @@ def setUpClass(cls): "product_id": test_carrier_product.id, } ) + # We need to know if purchase module is installed + cls.purchase_installed = False + if "purchased_product_qty" in cls.env["product.product"]._fields: + cls.purchase_installed = True + cls.vendor = cls.env["res.partner"].create({"name": "Test vendor"}) + cls.product.write( + { + "seller_ids": [(0, 0, {"partner_id": cls.vendor.id})], + } + ) def test_ship_data_from_pick(self): move1 = self._create_move( @@ -123,6 +133,12 @@ def test_put_in_pack_from_pick_with_wizard(self): ) ship_move._assign_picking() ship_move._action_confirm() + # Confirm purchase order + if self.purchase_installed: + purchase = self.env["purchase.order"].search( + [("partner_id", "=", self.vendor.id)] + ) + purchase.button_confirm() pick_move = ship_move.move_orig_ids[0] pick_picking = pick_move.picking_id ship_picking = ship_move.picking_id @@ -170,6 +186,12 @@ def test_put_in_pack_from_pick_without_wizard(self): ) ship_move._assign_picking() ship_move._action_confirm() + # Confirm purchase order + if self.purchase_installed: + purchase = self.env["purchase.order"].search( + [("partner_id", "=", self.vendor.id)] + ) + purchase.button_confirm() pick_move = ship_move.move_orig_ids[0] pick_picking = pick_move.picking_id ship_picking = ship_move.picking_id