[IMP] Phantom BoMs only out of services products should work
This commit is contained in:
parent
68aee1c82e
commit
11828c69db
|
@ -115,7 +115,7 @@ class StockMove(osv.osv):
|
||||||
proc = proc_obj.copy(cr, uid, move.procurement_id.id, default=valdef, context=context)
|
proc = proc_obj.copy(cr, uid, move.procurement_id.id, default=valdef, context=context)
|
||||||
else:
|
else:
|
||||||
proc = proc_obj.create(cr, uid, valdef, context=context)
|
proc = proc_obj.create(cr, uid, valdef, context=context)
|
||||||
proc_obj.run(cr, uid, [proc], context=context)
|
proc_obj.run(cr, uid, [proc], context=context) #could be omitted
|
||||||
|
|
||||||
|
|
||||||
#check if new moves needs to be exploded
|
#check if new moves needs to be exploded
|
||||||
|
|
|
@ -69,19 +69,6 @@ class mrp_production(osv.osv):
|
||||||
res[production.id] = move.procurement_id and move.procurement_id.sale_line_id and move.procurement_id.sale_line_id.order_id.client_order_ref or False
|
res[production.id] = move.procurement_id and move.procurement_id.sale_line_id and move.procurement_id.sale_line_id.order_id.client_order_ref or False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _hook_create_post_procurement(self, cr, uid, production, procurement_id, context=None):
|
|
||||||
def get_parent_move(move):
|
|
||||||
if move.move_dest_id:
|
|
||||||
return get_parent_move(move.move_dest_id)
|
|
||||||
return move
|
|
||||||
|
|
||||||
res = super(mrp_production, self)._hook_create_post_procurement(cr, uid, production, procurement_id, context)
|
|
||||||
if production.move_prod_id:
|
|
||||||
parent_move_line = get_parent_move(production.move_prod_id)
|
|
||||||
if parent_move_line and parent_move_line.sale_line_id:
|
|
||||||
self.pool.get('procurement.order').write(cr, uid, procurement_id, {'sale_line_id': parent_move_line.sale_line_id.id})
|
|
||||||
return res
|
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'sale_name': fields.function(_ref_calc, multi='sale_name', type='char', string='Sale Name', help='Indicate the name of sales order.'),
|
'sale_name': fields.function(_ref_calc, multi='sale_name', type='char', string='Sale Name', help='Indicate the name of sales order.'),
|
||||||
'sale_ref': fields.function(_ref_calc, multi='sale_name', type='char', string='Sale Reference', help='Indicate the Customer Reference from sales order.'),
|
'sale_ref': fields.function(_ref_calc, multi='sale_name', type='char', string='Sale Reference', help='Indicate the Customer Reference from sales order.'),
|
||||||
|
|
|
@ -206,11 +206,13 @@ class procurement_order(osv.osv):
|
||||||
return super(procurement_order, self)._run(cr, uid, procurement, context=context)
|
return super(procurement_order, self)._run(cr, uid, procurement, context=context)
|
||||||
|
|
||||||
def run(self, cr, uid, ids, autocommit=False, context=None):
|
def run(self, cr, uid, ids, autocommit=False, context=None):
|
||||||
res = super(procurement_order, self).run(cr, uid, ids, autocommit=autocommit, context=context)
|
new_ids = [x.id for x in self.browse(cr, uid, ids, context=context) if x.state not in ('running', 'done', 'cancel')]
|
||||||
|
res = super(procurement_order, self).run(cr, uid, new_ids, autocommit=autocommit, context=context)
|
||||||
|
|
||||||
#after all the procurements are run, check if some created a draft stock move that needs to be confirmed
|
#after all the procurements are run, check if some created a draft stock move that needs to be confirmed
|
||||||
#(we do that in batch because it fasts the picking assignation and the picking state computation)
|
#(we do that in batch because it fasts the picking assignation and the picking state computation)
|
||||||
move_to_confirm_ids = []
|
move_to_confirm_ids = []
|
||||||
for procurement in self.browse(cr, uid, ids, context=context):
|
for procurement in self.browse(cr, uid, new_ids, context=context):
|
||||||
if procurement.state == "running" and procurement.rule_id and procurement.rule_id.action == "move":
|
if procurement.state == "running" and procurement.rule_id and procurement.rule_id.action == "move":
|
||||||
move_to_confirm_ids += [m.id for m in procurement.move_ids if m.state == 'draft']
|
move_to_confirm_ids += [m.id for m in procurement.move_ids if m.state == 'draft']
|
||||||
if move_to_confirm_ids:
|
if move_to_confirm_ids:
|
||||||
|
@ -223,8 +225,8 @@ class procurement_order(osv.osv):
|
||||||
'''
|
'''
|
||||||
if procurement.rule_id and procurement.rule_id.action == 'move':
|
if procurement.rule_id and procurement.rule_id.action == 'move':
|
||||||
uom_obj = self.pool.get('product.uom')
|
uom_obj = self.pool.get('product.uom')
|
||||||
|
# In case Phantom BoM splits only into procurements
|
||||||
if not procurement.move_ids:
|
if not procurement.move_ids:
|
||||||
import pdb; pdb.set_trace()
|
|
||||||
return True
|
return True
|
||||||
cancel_test_list = [x.state == 'cancel' for x in procurement.move_ids]
|
cancel_test_list = [x.state == 'cancel' for x in procurement.move_ids]
|
||||||
done_cancel_test_list = [x.state in ('done', 'cancel') for x in procurement.move_ids]
|
done_cancel_test_list = [x.state in ('done', 'cancel') for x in procurement.move_ids]
|
||||||
|
@ -237,8 +239,6 @@ class procurement_order(osv.osv):
|
||||||
return True
|
return True
|
||||||
elif all_cancel:
|
elif all_cancel:
|
||||||
self.message_post(cr, uid, [procurement.id], body=_('All stock moves have been cancelled for this procurement.'), context=context)
|
self.message_post(cr, uid, [procurement.id], body=_('All stock moves have been cancelled for this procurement.'), context=context)
|
||||||
elif not cancel_test_list:
|
|
||||||
self.write(cr, uid, [procurement.id], {'state': 'done'}, context=context)
|
|
||||||
self.write(cr, uid, [procurement.id], {'state': 'cancel'}, context=context)
|
self.write(cr, uid, [procurement.id], {'state': 'cancel'}, context=context)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue