[FIX] stock, jit: run isn't supposed to be called without jit

This is related to ddfc07a6a2.

If procurement_jit_stock is not installed,
the method `run` of `procurement.order` is not
supposed to be called
This commit is contained in:
Denis Ledoux 2015-06-30 18:32:45 +02:00
parent 3378e6212b
commit fcc2852a27
2 changed files with 19 additions and 7 deletions

View File

@ -35,4 +35,12 @@ class procurement_order(osv.osv):
return self.run(cr, uid, procurement_ids, context=context)
return res
class stock_move(osv.osv):
_inherit = "stock.move"
def _create_procurements(self, cr, uid, moves, context=None):
res = super(stock_move, self)._create_procurements(cr, uid, moves, context=dict(context or {}, procurement_autorun_defer=True))
self.pool['procurement.order'].run(cr, uid, res, context=context)
return res
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1956,6 +1956,12 @@ class stock_move(osv.osv):
""" This will create a procurement order """
return self.pool.get("procurement.order").create(cr, uid, self._prepare_procurement_from_move(cr, uid, move, context=context), context=context)
def _create_procurements(self, cr, uid, moves, context=None):
res = []
for move in moves:
res.append(self._create_procurement(cr, uid, move, context=context))
return res
def write(self, cr, uid, ids, vals, context=None):
if context is None:
context = {}
@ -2197,13 +2203,11 @@ class stock_move(osv.osv):
if key not in to_assign:
to_assign[key] = []
to_assign[key].append(move.id)
proc_ids = []
for move in self.browse(cr, uid, states['confirmed'], context=context):
if move.procure_method == 'make_to_order':
proc_ids.append(self._create_procurement(cr, uid, move, context=dict(context, procurement_autorun_defer=True)))
states['waiting'].append(move.id)
states['confirmed'].remove(move.id)
self.pool['procurement.order'].run(cr, uid, proc_ids, context=context)
moves = [move for move in self.browse(cr, uid, states['confirmed'], context=context) if move.procure_method == 'make_to_order']
self._create_procurements(cr, uid, moves, context=context)
for move in moves:
states['waiting'].append(move.id)
states['confirmed'].remove(move.id)
for state, write_ids in states.items():
if len(write_ids):