[FIX] mrp: find company bom when MO created from procurement through cron
Manufacturing Orders can be created from procurements, as SUPERUSER_ID, since the procurements can be processed through the WH scheduler, which is always ran as SUPERUSER_ID In such a case, the record rules are ignored, and a BOM normally not accessible to a user thanks to the multi-company record rule could be chosen as the BOM of the MO. This revision forces to find a BOM from a specific company in such a case. opw-640120
This commit is contained in:
parent
f722254018
commit
235cd2d015
|
@ -212,6 +212,8 @@ class mrp_bom(osv.osv):
|
|||
@param properties: List of related properties.
|
||||
@return: False or BoM id.
|
||||
"""
|
||||
if not context:
|
||||
context = {}
|
||||
if properties is None:
|
||||
properties = []
|
||||
if product_id:
|
||||
|
@ -229,6 +231,8 @@ class mrp_bom(osv.osv):
|
|||
else:
|
||||
# neither product nor template, makes no sense to search
|
||||
return False
|
||||
if context.get('company_id'):
|
||||
domain = domain + [('company_id', '=', context['company_id'])]
|
||||
domain = domain + [ '|', ('date_start', '=', False), ('date_start', '<=', time.strftime(DEFAULT_SERVER_DATE_FORMAT)),
|
||||
'|', ('date_stop', '=', False), ('date_stop', '>=', time.strftime(DEFAULT_SERVER_DATE_FORMAT))]
|
||||
# order to prioritize bom with product_id over the one without
|
||||
|
|
|
@ -86,7 +86,7 @@ class procurement_order(osv.osv):
|
|||
else:
|
||||
properties = [x.id for x in procurement.property_ids]
|
||||
bom_id = bom_obj._bom_find(cr, uid, product_id=procurement.product_id.id,
|
||||
properties=properties, context=context)
|
||||
properties=properties, context=dict(context, company_id=procurement.company_id.id))
|
||||
bom = bom_obj.browse(cr, uid, bom_id, context=context)
|
||||
routing_id = bom.routing_id.id
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue