[WIP] Add _get_route_domain for finding suitable rules in purchase/mrp when stock_location is installed
bzr revid: jco@openerp.com-20130712083740-hz8um0e208r7jsbi
This commit is contained in:
parent
a3891c5014
commit
a93abb22e1
|
@ -47,7 +47,8 @@ class procurement_order(osv.osv):
|
|||
if not rule_id:
|
||||
#if there isn't any specific procurement.rule defined for the product, we try to directly supply it from a supplier
|
||||
if procurement.product_id.supply_method == 'manufacture' and procurement.product_id.bom_id: #Actually not needed anymore?
|
||||
rule_id = self.pool.get('procurement.rule').search(cr, uid, [('action', '=', 'manufacture'), ('location_id', '=', procurement.location_id.id)], context=context)
|
||||
domain = [('action', '=', 'manufacture'), ('location_id', '=', procurement.location_id.id)] + self._get_route_domain(cr, uid, procurement, context=context)
|
||||
rule_id = self.pool.get('procurement.rule').search(cr, uid, domain, context=context)
|
||||
rule_id = rule_id and rule_id[0] or False
|
||||
return rule_id
|
||||
|
||||
|
|
|
@ -166,6 +166,10 @@ class procurement_order(osv.osv):
|
|||
#
|
||||
# Method to overwrite in different procurement modules
|
||||
#
|
||||
|
||||
def _get_route_domain(self, cr, uid, procurement, context=None):
|
||||
return []
|
||||
|
||||
def _find_suitable_rule(self, cr, uid, procurement, context=None):
|
||||
'''This method returns a procurement.rule that depicts what to do with the given procurement
|
||||
in order to complete its needs. It returns False if no suiting rule is found.
|
||||
|
|
|
@ -1039,7 +1039,8 @@ class procurement_order(osv.osv):
|
|||
if not rule_id:
|
||||
#if there isn't any specific procurement.rule defined for the product, we try to directly supply it from a supplier
|
||||
if procurement.product_id.supply_method == 'buy' and self._check_supplier_info(cr, uid, [procurement.id], context=context):
|
||||
rule_id = self.pool.get('procurement.rule').search(cr, uid, [('action', '=', 'buy'), ('location_id', '=', procurement.location_id.id)], context=context)
|
||||
domain = [('action', '=', 'buy'), ('location_id', '=', procurement.location_id.id)] + self._get_route_domain(cr, uid, procurement, context=context)
|
||||
rule_id = self.pool.get('procurement.rule').search(cr, uid, domain, context=context)
|
||||
rule_id = rule_id and rule_id[0] or False
|
||||
return rule_id
|
||||
|
||||
|
|
|
@ -54,7 +54,8 @@ class procurement_order(osv.osv):
|
|||
res = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
|
||||
if not res:
|
||||
rule_obj = self.pool.get('procurement.rule')
|
||||
res = rule_obj.search(cr, uid, [('location_id', '=', procurement.location_id.id)], context=context)
|
||||
domain = [('location_id', '=', procurement.location_id.id)] + self._get_route_domain(cr, uid, procurement, context=context)
|
||||
res = rule_obj.search(cr, uid, domain, context=context)
|
||||
res = res and res[0] or False
|
||||
return res
|
||||
|
||||
|
|
|
@ -145,14 +145,19 @@ class procurement_order(osv.osv):
|
|||
})
|
||||
return d
|
||||
|
||||
# TODO: implement using routes on products
|
||||
def _find_suitable_rule(self, cr, uid, procurement, context=None):
|
||||
res = False
|
||||
if procurement.location_id:
|
||||
rule_obj = self.pool.get('procurement.rule')
|
||||
route_ids = [x.id for x in procurement.product_id.route_ids]
|
||||
res = rule_obj.search(cr, uid, [('location_id', '=', procurement.location_id.id), ('route_id', 'in', route_ids), ], context=context)
|
||||
return res and res[0] or super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
|
||||
# # TODO: implement using routes on products
|
||||
# def _find_suitable_rule(self, cr, uid, procurement, context=None):
|
||||
# res = False
|
||||
# if procurement.location_id:
|
||||
# rule_obj = self.pool.get('procurement.rule')
|
||||
# route_ids = [x.id for x in procurement.product_id.route_ids]
|
||||
# res = rule_obj.search(cr, uid, [('location_id', '=', procurement.location_id.id), ('route_id', 'in', route_ids), ], context=context)
|
||||
# return res and res[0] or super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
|
||||
|
||||
|
||||
def _get_route_domain(self, cr, uid, procurement, context=None):
|
||||
route_ids = [x.id for x in procurement.product_id.route_ids]
|
||||
return [('route_id', 'in', route_ids)]
|
||||
|
||||
class product_putaway_strategy(osv.osv):
|
||||
_name = 'product.putaway'
|
||||
|
|
Loading…
Reference in New Issue