mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[12.0][IMP] stock_orderpoint_move_link: add simple test.
This commit is contained in:
1
stock_orderpoint_move_link/tests/__init__.py
Normal file
1
stock_orderpoint_move_link/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import test_stock_orderpoint_move_link
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
|
||||||
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo.tests.common import SavepointCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestStockOrderpointMoveLink(SavepointCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
|
||||||
|
cls.product_obj = cls.env['product.product']
|
||||||
|
cls.orderpoint_obj = cls.env['stock.warehouse.orderpoint']
|
||||||
|
cls.loc_obj = cls.env['stock.location']
|
||||||
|
cls.route_obj = cls.env['stock.location.route']
|
||||||
|
cls.group_obj = cls.env['procurement.group']
|
||||||
|
cls.move_obj = cls.env['stock.move']
|
||||||
|
|
||||||
|
cls.warehouse = cls.env.ref('stock.warehouse0')
|
||||||
|
cls.stock_loc = cls.env.ref('stock.stock_location_stock')
|
||||||
|
|
||||||
|
# Create a new locations and routes:
|
||||||
|
cls.intermediate_loc = cls.loc_obj.create({
|
||||||
|
'name': 'Test location 1',
|
||||||
|
'usage': 'internal',
|
||||||
|
'location_id': cls.warehouse.view_location_id.id,
|
||||||
|
})
|
||||||
|
test_route = cls.route_obj.create({
|
||||||
|
'name': 'Stock -> Test 1',
|
||||||
|
'product_selectable': True,
|
||||||
|
'rule_ids': [(0, 0, {
|
||||||
|
'name': 'stock to test',
|
||||||
|
'action': 'pull',
|
||||||
|
'location_id': cls.intermediate_loc.id,
|
||||||
|
'location_src_id': cls.stock_loc.id,
|
||||||
|
'procure_method': 'make_to_stock',
|
||||||
|
'picking_type_id': cls.env.ref(
|
||||||
|
'stock.picking_type_internal').id,
|
||||||
|
'propagate': True
|
||||||
|
})]
|
||||||
|
})
|
||||||
|
cls.need_loc = cls.loc_obj.create({
|
||||||
|
'name': 'Test location 2',
|
||||||
|
'usage': 'internal',
|
||||||
|
'location_id': cls.warehouse.view_location_id.id,
|
||||||
|
})
|
||||||
|
test_route_2 = cls.route_obj.create({
|
||||||
|
'name': 'Test 1 -> Test 2',
|
||||||
|
'product_selectable': True,
|
||||||
|
'rule_ids': [(0, 0, {
|
||||||
|
'name': 'Test 1 to Test 2',
|
||||||
|
'action': 'pull',
|
||||||
|
'location_id': cls.need_loc.id,
|
||||||
|
'location_src_id': cls.intermediate_loc.id,
|
||||||
|
'procure_method': 'make_to_order',
|
||||||
|
'picking_type_id': cls.env.ref(
|
||||||
|
'stock.picking_type_internal').id,
|
||||||
|
'propagate': True
|
||||||
|
})]
|
||||||
|
})
|
||||||
|
|
||||||
|
# Prepare Products:
|
||||||
|
routes = test_route_2 + test_route
|
||||||
|
cls.product = cls.product_obj.create({
|
||||||
|
'name': 'Test Product',
|
||||||
|
'route_ids': [(6, 0, routes.ids)],
|
||||||
|
})
|
||||||
|
|
||||||
|
# Create Orderpoint:
|
||||||
|
cls.orderpoint_need_loc = cls.orderpoint_obj.create({
|
||||||
|
'warehouse_id': cls.warehouse.id,
|
||||||
|
'location_id': cls.need_loc.id,
|
||||||
|
'product_id': cls.product.id,
|
||||||
|
'product_min_qty': 10.0,
|
||||||
|
'product_max_qty': 50.0,
|
||||||
|
'product_uom': cls.product.uom_id.id,
|
||||||
|
})
|
||||||
|
cls.group_obj.run_scheduler()
|
||||||
|
|
||||||
|
def test_01_stock_orderpoint_move_link(self):
|
||||||
|
"""Tests if manual procurement fills orderpoint_ids field."""
|
||||||
|
move = self.move_obj.search([
|
||||||
|
('orderpoint_ids', '=', self.orderpoint_need_loc.id)])
|
||||||
|
self.assertTrue(len(move), 2)
|
||||||
Reference in New Issue
Block a user