|
| 1 | +# Copyright 2019 Camptocamp SA |
| 2 | +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) |
| 3 | +from odoo.tests import SavepointCase |
| 4 | + |
| 5 | + |
| 6 | +class TestAbcLocation(SavepointCase): |
| 7 | + @classmethod |
| 8 | + def setUpClass(cls): |
| 9 | + super().setUpClass() |
| 10 | + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) |
| 11 | + ref = cls.env.ref |
| 12 | + cls.stock_location = ref("stock.stock_location_stock") |
| 13 | + cls.cardboxes_location = ref("stock_storage_type.stock_location_cardboxes") |
| 14 | + cls.pallets_location = ref("stock_storage_type.stock_location_pallets") |
| 15 | + cls.cardboxes_bin_1_location = ref( |
| 16 | + "stock_storage_type.stock_location_cardboxes_bin_1" |
| 17 | + ) |
| 18 | + cls.cardboxes_bin_2_location = ref( |
| 19 | + "stock_storage_type.stock_location_cardboxes_bin_2" |
| 20 | + ) |
| 21 | + cls.cardboxes_bin_3_location = ref( |
| 22 | + "stock_storage_type.stock_location_cardboxes_bin_3" |
| 23 | + ) |
| 24 | + cls.pallets_bin_1_location = ref( |
| 25 | + "stock_storage_type.stock_location_pallets_bin_1" |
| 26 | + ) |
| 27 | + cls.pallets_bin_2_location = ref( |
| 28 | + "stock_storage_type.stock_location_pallets_bin_2" |
| 29 | + ) |
| 30 | + cls.pallets_bin_3_location = ref( |
| 31 | + "stock_storage_type.stock_location_pallets_bin_3" |
| 32 | + ) |
| 33 | + cls.product = ref("product.product_product_9") |
| 34 | + |
| 35 | + def test_display_abc_storage_one_level(self): |
| 36 | + self.cardboxes_location.write({"pack_putaway_strategy": "abc"}) |
| 37 | + self.assertTrue(self.cardboxes_bin_1_location.display_abc_storage) |
| 38 | + self.assertTrue(self.cardboxes_bin_2_location.display_abc_storage) |
| 39 | + self.assertTrue(self.cardboxes_bin_3_location.display_abc_storage) |
| 40 | + self.assertFalse(self.pallets_bin_1_location.display_abc_storage) |
| 41 | + self.assertFalse(self.pallets_bin_2_location.display_abc_storage) |
| 42 | + self.assertFalse(self.pallets_bin_3_location.display_abc_storage) |
| 43 | + self.cardboxes_location.write({"pack_putaway_strategy": "ordered_locations"}) |
| 44 | + self.assertFalse(self.cardboxes_bin_1_location.display_abc_storage) |
| 45 | + self.assertFalse(self.cardboxes_bin_2_location.display_abc_storage) |
| 46 | + self.assertFalse(self.cardboxes_bin_3_location.display_abc_storage) |
| 47 | + self.assertFalse(self.pallets_bin_1_location.display_abc_storage) |
| 48 | + self.assertFalse(self.pallets_bin_2_location.display_abc_storage) |
| 49 | + self.assertFalse(self.pallets_bin_3_location.display_abc_storage) |
| 50 | + |
| 51 | + def test_display_abc_storage_two_levels(self): |
| 52 | + self.stock_location.write({"pack_putaway_strategy": "abc"}) |
| 53 | + self.assertTrue(self.cardboxes_bin_1_location.display_abc_storage) |
| 54 | + self.assertTrue(self.cardboxes_bin_2_location.display_abc_storage) |
| 55 | + self.assertTrue(self.cardboxes_bin_3_location.display_abc_storage) |
| 56 | + self.assertTrue(self.pallets_bin_1_location.display_abc_storage) |
| 57 | + self.assertTrue(self.pallets_bin_2_location.display_abc_storage) |
| 58 | + self.assertTrue(self.pallets_bin_3_location.display_abc_storage) |
| 59 | + self.stock_location.write({"pack_putaway_strategy": "none"}) |
| 60 | + self.assertFalse(self.cardboxes_bin_1_location.display_abc_storage) |
| 61 | + self.assertFalse(self.cardboxes_bin_2_location.display_abc_storage) |
| 62 | + self.assertFalse(self.cardboxes_bin_3_location.display_abc_storage) |
| 63 | + self.assertFalse(self.pallets_bin_1_location.display_abc_storage) |
| 64 | + self.assertFalse(self.pallets_bin_2_location.display_abc_storage) |
| 65 | + self.assertFalse(self.pallets_bin_3_location.display_abc_storage) |
| 66 | + |
| 67 | + def test_abc_ordered(self): |
| 68 | + self.cardboxes_location.write({"pack_putaway_strategy": "abc"}) |
| 69 | + self.cardboxes_bin_1_location.write({"abc_storage": "b"}) |
| 70 | + self.cardboxes_bin_2_location.write({"abc_storage": "a"}) |
| 71 | + self.cardboxes_bin_3_location.write({"abc_storage": "c"}) |
| 72 | + self.product.write({"abc_storage": "a"}) |
| 73 | + ordered_locations = self.cardboxes_location.get_storage_locations(self.product) |
| 74 | + self.assertEqual( |
| 75 | + ordered_locations, |
| 76 | + self.cardboxes_bin_2_location |
| 77 | + | self.cardboxes_bin_1_location |
| 78 | + | self.cardboxes_bin_3_location, |
| 79 | + ) |
| 80 | + self.product.write({"abc_storage": "b"}) |
| 81 | + ordered_locations = self.cardboxes_location.get_storage_locations(self.product) |
| 82 | + self.assertEqual( |
| 83 | + ordered_locations, |
| 84 | + self.cardboxes_bin_1_location |
| 85 | + | self.cardboxes_bin_3_location |
| 86 | + | self.cardboxes_bin_2_location, |
| 87 | + ) |
| 88 | + self.product.write({"abc_storage": "c"}) |
| 89 | + ordered_locations = self.cardboxes_location.get_storage_locations(self.product) |
| 90 | + self.assertEqual( |
| 91 | + ordered_locations, |
| 92 | + self.cardboxes_bin_3_location |
| 93 | + | self.cardboxes_bin_2_location |
| 94 | + | self.cardboxes_bin_1_location, |
| 95 | + ) |
0 commit comments