|
| 1 | +# Copyright 2025 Michael Tietz (MT Software) <mtietz@mt-software.de> |
| 2 | +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) |
| 3 | +from datetime import datetime |
| 4 | + |
| 5 | +from .common import PromiseReleaseCommonCase |
| 6 | + |
| 7 | + |
| 8 | +class TestAvailableToPromiseReleaseCancelFixedPick(PromiseReleaseCommonCase): |
| 9 | + @classmethod |
| 10 | + def setUpClass(cls): |
| 11 | + super().setUpClass() |
| 12 | + |
| 13 | + cls._update_qty_in_location(cls.loc_bin1, cls.product1, 50.0) |
| 14 | + cls._update_qty_in_location(cls.loc_bin1, cls.product2, 50.0) |
| 15 | + pick_rule = cls.wh.delivery_route_id.rule_ids.filtered( |
| 16 | + lambda r: r.location_src_id == cls.loc_stock |
| 17 | + ) |
| 18 | + pick_rule.group_propagation_option = "fixed" |
| 19 | + pick_rule.group_id = cls.env["procurement.group"].create({"name": "Fixed"}) |
| 20 | + delivery_route = cls.wh.delivery_route_id |
| 21 | + delivery_route.write( |
| 22 | + { |
| 23 | + "available_to_promise_defer_pull": True, |
| 24 | + "allow_unrelease_return_done_move": True, |
| 25 | + } |
| 26 | + ) |
| 27 | + cls.cleanup_type = cls.env["stock.picking.type"].create( |
| 28 | + { |
| 29 | + "name": "Cancel Cleanup", |
| 30 | + "default_location_dest_id": cls.loc_stock.id, |
| 31 | + "sequence_code": "CCP", |
| 32 | + "code": "internal", |
| 33 | + } |
| 34 | + ) |
| 35 | + cls.pick_type = pick_rule.picking_type_id |
| 36 | + cls.pick_type.return_picking_type_id = cls.cleanup_type |
| 37 | + |
| 38 | + def test_full_cancel(self): |
| 39 | + picking_chain1 = self._create_picking_chain( |
| 40 | + self.wh, [(self.product1, 10)], date=datetime(2019, 9, 2, 16, 0) |
| 41 | + ) |
| 42 | + picking_chain2 = self._create_picking_chain( |
| 43 | + self.wh, [(self.product1, 10)], date=datetime(2019, 9, 2, 16, 0) |
| 44 | + ) |
| 45 | + ship_picking1 = self._out_picking(picking_chain1) |
| 46 | + ship_picking1.release_available_to_promise() |
| 47 | + ship_picking2 = self._out_picking(picking_chain2) |
| 48 | + ship_picking2.release_available_to_promise() |
| 49 | + self.assertNotEqual(ship_picking1, ship_picking2) |
| 50 | + pick1 = self._prev_picking(ship_picking1) |
| 51 | + pick2 = self._prev_picking(ship_picking2) |
| 52 | + self.assertEqual(pick1, pick2) |
| 53 | + self._deliver(pick1) |
| 54 | + self.assertEqual(ship_picking1.state, "assigned") |
| 55 | + self.assertEqual(ship_picking2.state, "assigned") |
| 56 | + ship_picking2.action_cancel() |
| 57 | + self.assertEqual(ship_picking2.state, "cancel") |
| 58 | + self.assertEqual(ship_picking1.state, "assigned") |
| 59 | + |
| 60 | + def test_partial_cancel(self): |
| 61 | + picking_chain1 = self._create_picking_chain( |
| 62 | + self.wh, |
| 63 | + [(self.product1, 10), (self.product2, 10)], |
| 64 | + date=datetime(2019, 9, 2, 16, 0), |
| 65 | + ) |
| 66 | + picking_chain2 = self._create_picking_chain( |
| 67 | + self.wh, |
| 68 | + [(self.product1, 10), (self.product2, 10)], |
| 69 | + date=datetime(2019, 9, 2, 16, 0), |
| 70 | + ) |
| 71 | + ship_picking1 = self._out_picking(picking_chain1) |
| 72 | + ship_picking1.release_available_to_promise() |
| 73 | + ship_picking2 = self._out_picking(picking_chain2) |
| 74 | + ship_picking2.release_available_to_promise() |
| 75 | + self.assertNotEqual(ship_picking1, ship_picking2) |
| 76 | + pick1 = self._prev_picking(ship_picking1) |
| 77 | + pick2 = self._prev_picking(ship_picking2) |
| 78 | + self.assertEqual(pick1, pick2) |
| 79 | + self._deliver(pick1) |
| 80 | + self.assertEqual(ship_picking1.state, "assigned") |
| 81 | + self.assertEqual(ship_picking2.state, "assigned") |
| 82 | + ship2_product2_move = ship_picking2.move_ids.filtered( |
| 83 | + lambda m: m.product_id == self.product2 |
| 84 | + ) |
| 85 | + ship2_product2_move._action_cancel() |
| 86 | + self.assertEqual(ship_picking2.state, "assigned") |
| 87 | + self.assertEqual(ship_picking1.state, "assigned") |
0 commit comments