Files
stock-logistics-warehouse/stock_helper/tests/test_location_is_sublocation_of.py
Guewen Baconnier f04c497a9e Add stock_helper: share common code used by stock modules
The first method is: StockLocation.is_sublocation_of()

This method is currently used in:

* wms/stock_dynamic_routing
* wms/shopfloor
* wms/stock_move_source_relocate
* stock-logistics-warehouse/stock_reserve_rule
* ddmrp/ddmrp

The goal will be to use this module as dependency instead of
reimplementing the method in each.

Other methods should follow in "stock_helper".

Note: I opened https://github.com/odoo/odoo/pull/53866 to propose a
generic version of this method, expecting odoo's opinion, but got no
answer.
2021-03-19 12:51:27 +01:00

49 lines
1.6 KiB
Python

# Copyright 2020-2021 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from .common import StockHelperCommonCase
class TestStockLocationIsSublocationOf(StockHelperCommonCase):
def test_is_sublocation_of_equal(self):
self.assertTrue(self.shelf1_loc.is_sublocation_of(self.shelf1_loc))
def test_is_sublocation_of_equal_child_ko(self):
bin_loc = self.env["stock.location"].create(
{"name": "bin", "location_id": self.shelf1_loc.id}
)
self.assertFalse(self.shelf1_loc.is_sublocation_of(bin_loc))
def test_is_sublocation_of_equal_child_sibling(self):
self.assertFalse(self.shelf1_loc.is_sublocation_of(self.shelf2_loc))
def test_is_sublocation_of_any_ok(self):
self.assertTrue(
self.shelf1_loc.is_sublocation_of(self.stock_loc | self.customer_loc)
)
def test_is_sublocation_of_any_ko(self):
self.assertFalse(
self.shelf1_loc.is_sublocation_of(self.supplier_loc | self.customer_loc)
)
def test_is_sublocation_of_all_ok(self):
self.assertTrue(
self.shelf1_loc.is_sublocation_of(
self.stock_loc | self.stock_loc.location_id, func=all
)
)
def test_is_sublocation_of_all_ko(self):
self.assertFalse(
self.shelf1_loc.is_sublocation_of(
self.stock_loc | self.customer_loc, func=all
)
)
self.assertFalse(
self.shelf1_loc.is_sublocation_of(
self.supplier_loc | self.customer_loc, func=all
)
)