mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
set pull rule of customer location like split_procurement to allow when warehouse is two/three steps delivery propagate move by mts-mto in pick/pack/out
This commit is contained in:
committed by
Pierrick Brun
parent
d7f081484e
commit
e2dc0a6b44
@@ -70,6 +70,26 @@ class Warehouse(models.Model):
|
||||
'picking_type_id': warehouse.mto_pull_id.picking_type_id.id,
|
||||
}
|
||||
|
||||
@api.model
|
||||
def _get_push_pull_rules(self, warehouse, active, values, new_route_id):
|
||||
pull_obj = self.env['procurement.rule']
|
||||
res = super(Warehouse, self)._get_push_pull_rules(
|
||||
warehouse, active, values, new_route_id)
|
||||
customer_location = warehouse._get_partner_locations()
|
||||
location_id = customer_location[0].id
|
||||
if warehouse.mto_mts_management:
|
||||
for pull in res[1]:
|
||||
if pull['location_id'] == location_id:
|
||||
pull_mto_mts = pull.copy()
|
||||
pull_mto_mts_id = pull_obj.create(pull_mto_mts)
|
||||
pull.update({
|
||||
'action': 'split_procurement',
|
||||
'mto_rule_id': pull_mto_mts_id.id,
|
||||
'mts_rule_id': pull_mto_mts_id.id,
|
||||
'sequence': 10
|
||||
})
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def create_routes(self, warehouse):
|
||||
pull_model = self.env['procurement.rule']
|
||||
@@ -94,7 +114,11 @@ class Warehouse(models.Model):
|
||||
for warehouse in self:
|
||||
if warehouse.mts_mto_rule_id:
|
||||
warehouse.mts_mto_rule_id.unlink()
|
||||
return super(Warehouse, self).write(vals)
|
||||
res = super(Warehouse, self).write(vals)
|
||||
if 'mto_mts_management' in vals:
|
||||
self.with_context({'active_test': False}).change_route(
|
||||
warehouse, new_delivery_step=warehouse.delivery_steps)
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def get_all_routes_for_wh(self, warehouse):
|
||||
|
||||
@@ -34,12 +34,15 @@ class TestMtoMtsRoute(TransactionCase):
|
||||
|
||||
def test_standard_mts_route(self):
|
||||
self.procurement.run()
|
||||
procurement_id = self.procurement_obj.search([
|
||||
('group_id', '=', self.procurement.group_id.id),
|
||||
('move_ids', '!=', False)], limit=1)
|
||||
self.assertEqual('make_to_stock',
|
||||
self.procurement.move_ids[0].procure_method)
|
||||
procurement_id.move_ids[0].procure_method)
|
||||
self.assertEqual(self.procurement.product_qty,
|
||||
self.procurement.move_ids[0].product_uom_qty)
|
||||
procurement_id.move_ids[0].product_uom_qty)
|
||||
self.assertEqual('confirmed',
|
||||
self.procurement.move_ids[0].state)
|
||||
procurement_id.move_ids[0].state)
|
||||
|
||||
def test_mts_mto_route_split(self):
|
||||
mto_mts_route = self.env.ref('stock_mts_mto_rule.route_mto_mts')
|
||||
@@ -81,6 +84,7 @@ class TestMtoMtsRoute(TransactionCase):
|
||||
self.warehouse.mto_mts_management = True
|
||||
self.product = self.env.ref('product.product_product_4')
|
||||
self.company_partner = self.env.ref('base.main_partner')
|
||||
self.procurement_obj = self.env['procurement.order']
|
||||
self.group = self.env['procurement.group'].create({
|
||||
'name': 'test',
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user