[FIX] fixed find_suitable_rule, fixed data for main warehouse and added debug statement for crashing yaml test
bzr revid: qdp-launchpad@openerp.com-20131003091709-q4boyc5dwz2ec7ho
This commit is contained in:
parent
b1d9c439d2
commit
11fa96bbbd
|
@ -40,14 +40,6 @@ class procurement_order(osv.osv):
|
|||
'production_id': fields.many2one('mrp.production', 'Manufacturing Order'),
|
||||
}
|
||||
|
||||
def _find_suitable_rule(self, cr, uid, procurement, context=None):
|
||||
rule_id = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
|
||||
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
|
||||
rule_id = self._search_suitable_rule(cr, uid, procurement, [('action', '=', 'manufacture'), ('location_id', '=', procurement.location_id.id)], context=context)
|
||||
rule_id = rule_id and rule_id[0] or False
|
||||
return rule_id
|
||||
|
||||
def _run(self, cr, uid, procurement, context=None):
|
||||
if procurement.rule_id and procurement.rule_id.action == 'manufacture':
|
||||
#make a manufacturing order for the procurement
|
||||
|
|
|
@ -1126,14 +1126,6 @@ class procurement_order(osv.osv):
|
|||
'purchase_line_id': fields.many2one('purchase.order.line', 'Purchase Order'),
|
||||
}
|
||||
|
||||
def _find_suitable_rule(self, cr, uid, procurement, context=None):
|
||||
rule_id = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
|
||||
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
|
||||
rule_id = self._search_suitable_rule(cr, uid, procurement, [('action', '=', 'buy'), ('location_id', '=', procurement.location_id.id)], context=context)
|
||||
rule_id = rule_id and rule_id[0] or False
|
||||
return rule_id
|
||||
|
||||
def _run(self, cr, uid, procurement, context=None):
|
||||
print "dans le run de purchase"
|
||||
print procurement
|
||||
|
|
|
@ -57,6 +57,11 @@
|
|||
print 'procurement_order', procurement_order.state
|
||||
print 'test', procurement_order.purchase_line_id.order_id
|
||||
print 'test rule name', procurement_order.rule_id.name
|
||||
print 'test route sequence', [(r.name, r.sequence) for r in procurement_order.route_ids]
|
||||
rule_seq = []
|
||||
for route in procurement_order.route_ids:
|
||||
rule_seq += [(ru.name, ru.route_sequence, ru.sequence) for ru in route.pull_ids]
|
||||
print '####RULES SEQ####', rule_seq
|
||||
purchase_id = procurement_order.purchase_line_id.order_id.id
|
||||
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
|
|
|
@ -581,27 +581,34 @@ class procurement_order(osv.osv):
|
|||
})
|
||||
return d
|
||||
|
||||
def _find_parent_locations(self, cr, uid, procurement, context=None):
|
||||
location = procurement.location_id
|
||||
res = [location.id]
|
||||
while location.location_id:
|
||||
location = location.location_id
|
||||
res.append(location.id)
|
||||
return res
|
||||
|
||||
def _find_suitable_rule(self, cr, uid, procurement, context=None):
|
||||
rule_id = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
|
||||
if not rule_id:
|
||||
rule_id = self._search_suitable_rule(cr, uid, procurement, [('location_id', '=', procurement.location_id.id)], context=context) #action=move
|
||||
#a rule defined on 'Stock' is suitable for a procurement in 'Stock\Bin A'
|
||||
all_parent_location_ids = self._find_parent_locations(cr, uid, procurement, context=context)
|
||||
rule_id = self._search_suitable_rule(cr, uid, procurement, [('location_id', 'in', all_parent_location_ids)], context=context)
|
||||
rule_id = rule_id and rule_id[0] or False
|
||||
return rule_id
|
||||
|
||||
def _search_suitable_rule(self, cr, uid, procurement, domain, context=None):
|
||||
'''we try to first find a rule among the ones defined on the procurement order group and if none is found, we try on the routes defined for the product, and finally we fallback on the default behavior'''
|
||||
categ_obj = self.pool.get("product.category")
|
||||
categ_id = procurement.product_id.categ_id.id
|
||||
route_ids1 = [x.id for x in procurement.product_id.route_ids + procurement.product_id.categ_id.total_route_ids]
|
||||
route_ids2 = [x.id for x in procurement.route_ids]
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids1)], order = 'route_sequence, sequence', context=context)
|
||||
product_route_ids = [x.id for x in procurement.product_id.route_ids + procurement.product_id.categ_id.total_route_ids]
|
||||
procurement_route_ids = [x.id for x in procurement.route_ids]
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', product_route_ids)], order = 'route_sequence, sequence', context=context)
|
||||
if not res:
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids2)], order = 'route_sequence, sequence', context=context)
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', procurement_route_ids)], order = 'route_sequence, sequence', context=context)
|
||||
if not res:
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', '=', False)], order='sequence', context=context)
|
||||
return res
|
||||
|
||||
|
||||
class product_putaway_strategy(osv.osv):
|
||||
_name = 'product.putaway'
|
||||
_description = 'Put Away Strategy'
|
||||
|
|
|
@ -84,26 +84,29 @@
|
|||
<field name="product_categ_selectable" eval="True"/>
|
||||
<field name="warehouse_selectable" eval="True"/>
|
||||
<field name="product_selectable" eval="False"/>
|
||||
<field name="active" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="procurement_rule_customer0_xdock" model="procurement.rule">
|
||||
<field name="name">Your Company: Stock → Customers</field>
|
||||
<field name="name">Your Company: Output → Customers</field>
|
||||
<field name="action">move</field>
|
||||
<field name="location_id" ref="stock.stock_location_customers"/>
|
||||
<field name="location_src_id" ref="stock.stock_location_stock"/>
|
||||
<field name="location_src_id" ref="stock.stock_location_output"/>
|
||||
<field name="procure_method">make_to_order</field>
|
||||
<field name="route_id" ref="route_warehouse0_crossdock"/>
|
||||
<field name="picking_type_id" ref="stock.picking_type_out"/>
|
||||
<field name="active" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="procurement_rule_customer0_xdock_start" model="procurement.rule">
|
||||
<field name="name">Your Company: Stock → Stock</field>
|
||||
<field name="name">Your Company: Input → Output</field>
|
||||
<field name="action">move</field>
|
||||
<field name="location_id" ref="stock.stock_location_stock"/>
|
||||
<field name="location_src_id" ref="stock.stock_location_stock"/>
|
||||
<field name="location_id" ref="stock.stock_location_output"/>
|
||||
<field name="location_src_id" ref="stock_location_input"/>
|
||||
<field name="procure_method">make_to_stock</field>
|
||||
<field name="route_id" ref="route_warehouse0_crossdock"/>
|
||||
<field name="picking_type_id" ref="stock.picking_type_internal"/>
|
||||
<field name="active" eval="False"/>
|
||||
</record>
|
||||
|
||||
<!-- reception route -->
|
||||
|
|
Loading…
Reference in New Issue