|
|
|
@@ -215,7 +215,7 @@ class stock_location_route(osv.osv):
|
|
|
|
|
_columns = {
|
|
|
|
|
'name': fields.char('Route Name', required=True),
|
|
|
|
|
'sequence': fields.integer('Sequence'),
|
|
|
|
|
'pull_ids': fields.one2many('procurement.rule', 'route_id', 'Pull Rules', copy=True),
|
|
|
|
|
'pull_ids': fields.one2many('procurement.rule', 'route_id', 'Procurement Rules', copy=True),
|
|
|
|
|
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the route without removing it."),
|
|
|
|
|
'push_ids': fields.one2many('stock.location.path', 'route_id', 'Push Rules', copy=True),
|
|
|
|
|
'product_selectable': fields.boolean('Applicable on Product'),
|
|
|
|
@@ -1812,7 +1812,7 @@ class stock_move(osv.osv):
|
|
|
|
|
states={'done': [('readonly', True)]}, help="Remaining Quantity in default UoM according to operations matched with this move"),
|
|
|
|
|
'procurement_id': fields.many2one('procurement.order', 'Procurement'),
|
|
|
|
|
'group_id': fields.many2one('procurement.group', 'Procurement Group'),
|
|
|
|
|
'rule_id': fields.many2one('procurement.rule', 'Procurement Rule', help='The pull rule that created this stock move'),
|
|
|
|
|
'rule_id': fields.many2one('procurement.rule', 'Procurement Rule', help='The procurement rule that created this stock move'),
|
|
|
|
|
'push_rule_id': fields.many2one('stock.location.path', 'Push Rule', help='The push rule that created this stock move'),
|
|
|
|
|
'propagate': fields.boolean('Propagate cancel and split', help='If checked, when this move is cancelled, cancel the linked move too'),
|
|
|
|
|
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type'),
|
|
|
|
@@ -3200,24 +3200,24 @@ class stock_warehouse(osv.osv):
|
|
|
|
|
reception_route_id = route_obj.create(cr, uid, route_vals, context=context)
|
|
|
|
|
wh_route_ids.append((4, reception_route_id))
|
|
|
|
|
push_rules_list, pull_rules_list = self._get_push_pull_rules(cr, uid, warehouse, True, values, reception_route_id, context=context)
|
|
|
|
|
#create the push/pull rules
|
|
|
|
|
#create the push/procurement rules
|
|
|
|
|
for push_rule in push_rules_list:
|
|
|
|
|
push_obj.create(cr, uid, vals=push_rule, context=context)
|
|
|
|
|
for pull_rule in pull_rules_list:
|
|
|
|
|
#all pull rules in reception route are mto, because we don't want to wait for the scheduler to trigger an orderpoint on input location
|
|
|
|
|
#all procurement rules in reception route are mto, because we don't want to wait for the scheduler to trigger an orderpoint on input location
|
|
|
|
|
pull_rule['procure_method'] = 'make_to_order'
|
|
|
|
|
pull_obj.create(cr, uid, vals=pull_rule, context=context)
|
|
|
|
|
|
|
|
|
|
#create MTS route and pull rules for delivery and a specific route MTO to be set on the product
|
|
|
|
|
#create MTS route and procurement rules for delivery and a specific route MTO to be set on the product
|
|
|
|
|
route_name, values = routes_dict[warehouse.delivery_steps]
|
|
|
|
|
route_vals = self._get_reception_delivery_route(cr, uid, warehouse, route_name, context=context)
|
|
|
|
|
#create the route and its pull rules
|
|
|
|
|
#create the route and its procurement rules
|
|
|
|
|
delivery_route_id = route_obj.create(cr, uid, route_vals, context=context)
|
|
|
|
|
wh_route_ids.append((4, delivery_route_id))
|
|
|
|
|
dummy, pull_rules_list = self._get_push_pull_rules(cr, uid, warehouse, True, values, delivery_route_id, context=context)
|
|
|
|
|
for pull_rule in pull_rules_list:
|
|
|
|
|
pull_obj.create(cr, uid, vals=pull_rule, context=context)
|
|
|
|
|
#create MTO pull rule and link it to the generic MTO route
|
|
|
|
|
#create MTO procurement rule and link it to the generic MTO route
|
|
|
|
|
mto_pull_vals = self._get_mto_pull_rule(cr, uid, warehouse, values, context=context)[0]
|
|
|
|
|
mto_pull_id = pull_obj.create(cr, uid, mto_pull_vals, context=context)
|
|
|
|
|
|
|
|
|
@@ -3235,7 +3235,7 @@ class stock_warehouse(osv.osv):
|
|
|
|
|
#create route selectable on the product to resupply the warehouse from another one
|
|
|
|
|
self._create_resupply_routes(cr, uid, warehouse, warehouse.resupply_wh_ids, warehouse.default_resupply_wh_id, context=context)
|
|
|
|
|
|
|
|
|
|
#return routes and mto pull rule to store on the warehouse
|
|
|
|
|
#return routes and mto procurement rule to store on the warehouse
|
|
|
|
|
return {
|
|
|
|
|
'route_ids': wh_route_ids,
|
|
|
|
|
'mto_pull_id': mto_pull_id,
|
|
|
|
@@ -3270,7 +3270,7 @@ class stock_warehouse(osv.osv):
|
|
|
|
|
route_name, values = routes_dict[new_delivery_step]
|
|
|
|
|
route_obj.write(cr, uid, warehouse.delivery_route_id.id, {'name': self._format_routename(cr, uid, warehouse, route_name, context=context)}, context=context)
|
|
|
|
|
dummy, pull_rules_list = self._get_push_pull_rules(cr, uid, warehouse, True, values, warehouse.delivery_route_id.id, context=context)
|
|
|
|
|
#create the pull rules
|
|
|
|
|
#create the procurement rules
|
|
|
|
|
for pull_rule in pull_rules_list:
|
|
|
|
|
pull_obj.create(cr, uid, vals=pull_rule, context=context)
|
|
|
|
|
|
|
|
|
@@ -3280,11 +3280,11 @@ class stock_warehouse(osv.osv):
|
|
|
|
|
route_name, values = routes_dict[new_reception_step]
|
|
|
|
|
route_obj.write(cr, uid, warehouse.reception_route_id.id, {'name': self._format_routename(cr, uid, warehouse, route_name, context=context)}, context=context)
|
|
|
|
|
push_rules_list, pull_rules_list = self._get_push_pull_rules(cr, uid, warehouse, True, values, warehouse.reception_route_id.id, context=context)
|
|
|
|
|
#create the push/pull rules
|
|
|
|
|
#create the push/procurement rules
|
|
|
|
|
for push_rule in push_rules_list:
|
|
|
|
|
push_obj.create(cr, uid, vals=push_rule, context=context)
|
|
|
|
|
for pull_rule in pull_rules_list:
|
|
|
|
|
#all pull rules in receipt route are mto, because we don't want to wait for the scheduler to trigger an orderpoint on input location
|
|
|
|
|
#all procurement rules in receipt route are mto, because we don't want to wait for the scheduler to trigger an orderpoint on input location
|
|
|
|
|
pull_rule['procure_method'] = 'make_to_order'
|
|
|
|
|
pull_obj.create(cr, uid, vals=pull_rule, context=context)
|
|
|
|
|
|
|
|
|
@@ -3449,7 +3449,7 @@ class stock_warehouse(osv.osv):
|
|
|
|
|
warehouse = self.browse(cr, uid, new_id, context=context)
|
|
|
|
|
self.create_sequences_and_picking_types(cr, uid, warehouse, context=context)
|
|
|
|
|
|
|
|
|
|
#create routes and push/pull rules
|
|
|
|
|
#create routes and push/procurement rules
|
|
|
|
|
new_objects_dict = self.create_routes(cr, uid, new_id, warehouse, context=context)
|
|
|
|
|
self.write(cr, uid, warehouse.id, new_objects_dict, context=context)
|
|
|
|
|
return new_id
|
|
|
|
@@ -3482,14 +3482,14 @@ class stock_warehouse(osv.osv):
|
|
|
|
|
#rename location
|
|
|
|
|
location_id = warehouse.lot_stock_id.location_id.id
|
|
|
|
|
location_obj.write(cr, uid, location_id, {'name': code}, context=context)
|
|
|
|
|
#rename route and push-pull rules
|
|
|
|
|
#rename route and push-procurement rules
|
|
|
|
|
for route in warehouse.route_ids:
|
|
|
|
|
route_obj.write(cr, uid, route.id, {'name': route.name.replace(warehouse.name, name, 1)}, context=context)
|
|
|
|
|
for pull in route.pull_ids:
|
|
|
|
|
pull_obj.write(cr, uid, pull.id, {'name': pull.name.replace(warehouse.name, name, 1)}, context=context)
|
|
|
|
|
for push in route.push_ids:
|
|
|
|
|
push_obj.write(cr, uid, push.id, {'name': pull.name.replace(warehouse.name, name, 1)}, context=context)
|
|
|
|
|
#change the mto pull rule name
|
|
|
|
|
#change the mto procurement rule name
|
|
|
|
|
if warehouse.mto_pull_id.id:
|
|
|
|
|
pull_obj.write(cr, uid, warehouse.mto_pull_id.id, {'name': warehouse.mto_pull_id.name.replace(warehouse.name, name, 1)}, context=context)
|
|
|
|
|
|
|
|
|
@@ -3514,7 +3514,7 @@ class stock_warehouse(osv.osv):
|
|
|
|
|
for mto_pull_val in mto_pull_vals:
|
|
|
|
|
pull_obj.create(cr, uid, mto_pull_val, context=context)
|
|
|
|
|
else:
|
|
|
|
|
# We need to delete all the MTO pull rules, otherwise they risk to be used in the system
|
|
|
|
|
# We need to delete all the MTO procurement rules, otherwise they risk to be used in the system
|
|
|
|
|
pulls = pull_obj.search(cr, uid, ['&', ('route_id', '=', mto_route_id), ('location_id.usage', '=', 'transit'), ('location_src_id', '=', warehouse.lot_stock_id.id)], context=context)
|
|
|
|
|
if pulls:
|
|
|
|
|
pull_obj.unlink(cr, uid, pulls, context=context)
|
|
|
|
|