From 0abd2c8ae782c09caafdef49311435e15b9b3b8a Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Wed, 2 Apr 2014 15:41:03 +0200 Subject: [PATCH 1/5] [IMP] Should make sure to pass parameters as context for orderpoint bzr revid: jco@openerp.com-20140402134103-jpduk6k4xzh8vw97 --- addons/stock/procurement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py index cb19c3b058e..32bb12ead11 100644 --- a/addons/stock/procurement.py +++ b/addons/stock/procurement.py @@ -347,7 +347,7 @@ class procurement_order(osv.osv): product_obj = self.pool.get('product.product') return product_obj._product_available(cr, uid, [order_point.product_id.id], - {'location': order_point.location_id.id})[order_point.product_id.id]['virtual_available'] + context = {'location': order_point.location_id.id})[order_point.product_id.id]['virtual_available'] def _procure_orderpoint_confirm(self, cr, uid, \ use_new_cursor=False, context=None, user_id=False): From 63ad3afc93ee58732424b604ed16dc52755fe4fe Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Wed, 2 Apr 2014 17:06:25 +0200 Subject: [PATCH 2/5] [IMP] Crossdock route should be mto by default bzr revid: jco@openerp.com-20140402150625-w5djrfyuy63ld276 --- addons/stock/stock.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index b492496243e..338c8e9d1e5 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2947,6 +2947,7 @@ class stock_warehouse(osv.osv): 'product_selectable': True, 'product_categ_selectable': True, 'active': warehouse.delivery_steps != 'ship_only' and warehouse.reception_steps != 'one_step', + 'procure_method': 'make_to_order', 'sequence': 20, } From 8a7b3b883c8e07533b408b2a64a727ce13ae8cb8 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Wed, 2 Apr 2014 18:08:18 +0200 Subject: [PATCH 3/5] [IMP] Crossdock route should be mto bzr revid: jco@openerp.com-20140402160818-heopeego7ico7spz --- addons/stock/stock.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 338c8e9d1e5..084d554799c 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2947,7 +2947,6 @@ class stock_warehouse(osv.osv): 'product_selectable': True, 'product_categ_selectable': True, 'active': warehouse.delivery_steps != 'ship_only' and warehouse.reception_steps != 'one_step', - 'procure_method': 'make_to_order', 'sequence': 20, } @@ -2991,6 +2990,8 @@ class stock_warehouse(osv.osv): wh_route_ids.append((4, crossdock_route_id)) dummy, pull_rules_list = self._get_push_pull_rules(cr, uid, warehouse, warehouse.delivery_steps != 'ship_only' and warehouse.reception_steps != 'one_step', values, crossdock_route_id, context=context) for pull_rule in pull_rules_list: + # Fixed cross-dock is logically mto + pull_rule['procure_method'] = 'make_to_order' pull_obj.create(cr, uid, vals=pull_rule, context=context) #create route selectable on the product to resupply the warehouse from another one From c44082312e6c9d86469ceebc3fb2466e6e550655 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 3 Apr 2014 11:19:12 +0200 Subject: [PATCH 4/5] [IMP] Change quantity on hand, incoming, outgoing, virtual to include all locations of the warehouse, not just stock bzr revid: jco@openerp.com-20140403091912-r017dtfa1g23o40z --- addons/stock/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/product.py b/addons/stock/product.py index 4ed9d4db2ae..71402d363a4 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -88,7 +88,7 @@ class product_product(osv.osv): wids = warehouse_obj.search(cr, uid, [], context=context) for w in warehouse_obj.browse(cr, uid, wids, context=context): - location_ids.append(w.lot_stock_id.id) + location_ids.append(w.view_location_id.id) operator = context.get('compute_child',True) and 'child_of' or 'in' domain = context.get('force_company', False) and ['&', ('company_id', '=', context['force_company'])] or [] From d45fd02abd97ce31a018da4c34084c23d820d444 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 3 Apr 2014 17:57:35 +0200 Subject: [PATCH 5/5] [IMP] Push rules should try to find routes on warehouse first before searching anything bzr revid: jco@openerp.com-20140403155735-y357mj3gtp7j3x7i --- addons/purchase/purchase.py | 1 + addons/stock/product.py | 1 - addons/stock/stock.py | 16 ++++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index df516b20587..44401fa22f7 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -695,6 +695,7 @@ class purchase_order(osv.osv): 'procurement_id': False, 'origin': order.name, 'route_ids': order.picking_type_id.warehouse_id and [(6, 0, [x.id for x in order.picking_type_id.warehouse_id.route_ids])] or [], + 'warehouse_id':order.picking_type_id.warehouse_id.id, } diff_quantity = order_line.product_qty diff --git a/addons/stock/product.py b/addons/stock/product.py index 71402d363a4..d1b8691e0cc 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -136,7 +136,6 @@ class product_product(osv.osv): moves_in = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_in)) moves_out = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_out)) - res = {} for id in ids: res[id] = { diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 084d554799c..d0cdec8a33f 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1794,18 +1794,26 @@ class stock_move(osv.osv): # to receive goods without triggering the push rules again (which would duplicate chained operations) if not move.move_dest_id and not move.origin_returned_move_id: domain = [('location_from_id', '=', move.location_dest_id.id)] - if move.warehouse_id: - domain += ['|', ('warehouse_id', '=', move.warehouse_id.id), ('warehouse_id', '=', False)] + #priority goes to the route defined on the product and product category route_ids = [x.id for x in move.product_id.route_ids + move.product_id.categ_id.total_route_ids] rules = push_obj.search(cr, uid, domain + [('route_id', 'in', route_ids)], order='route_sequence, sequence', context=context) if not rules: - #but if there's no rule matching, we try without filtering on routes - rules = push_obj.search(cr, uid, domain, order='route_sequence, sequence', context=context) + route_ids = [] + if move.warehouse_id: + route_ids = [x.id for x in move.warehouse_id.route_ids] + elif move.picking_type_id and move.picking_type_id.warehouse_id: + route_ids = [x.id for x in move.picking_type_id.warehouse_id.route_ids] + if route_ids: + rules = push_obj.search(cr, uid, domain + [('route_id', 'in', route_ids)], order='route_sequence, sequence', context=context) + if not rules: + #but if there's no rule matching, we try without filtering on routes + rules = push_obj.search(cr, uid, domain, order='route_sequence, sequence', context=context) if rules: rule = push_obj.browse(cr, uid, rules[0], context=context) push_obj._apply(cr, uid, rule, move, context=context) return True + def _create_procurement(self, cr, uid, move, context=None): """ This will create a procurement order """