diff --git a/addons/mrp_jit/mrp_jit.py b/addons/mrp_jit/mrp_jit.py
index 4ad5cca5f20..01d94692a9d 100644
--- a/addons/mrp_jit/mrp_jit.py
+++ b/addons/mrp_jit/mrp_jit.py
@@ -27,6 +27,7 @@ class procurement_order(osv.osv):
def create(self, cr, uid, vals, context=None):
procurement_id = super(procurement_order, self).create(cr, uid, vals, context=context)
+ # TODO: maybe this is not necessary anymore as we do this already
self.run(cr, uid, [procurement_id], context=context)
self.check(cr, uid, [procurement_id], context=context)
return procurement_id
diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py
index 69e2b1cbf23..4e8b163eced 100644
--- a/addons/procurement/procurement.py
+++ b/addons/procurement/procurement.py
@@ -154,13 +154,14 @@ class procurement_order(osv.osv):
def run(self, cr, uid, ids, context=None):
for procurement in self.browse(cr, uid, ids, context=context):
- if self._assign(cr, uid, procurement, context=context):
- procurement.refresh()
- self._run(cr, uid, procurement, context=context or {})
- self.write(cr, uid, [procurement.id], {'state': 'running'}, context=context)
- else:
- self.message_post(cr, uid, [procurement.id], body=_('No rule matching this procurement'), context=context)
- self.write(cr, uid, [procurement.id], {'state': 'exception'}, context=context)
+ if procurement.state not in ("running", "done"):
+ if self._assign(cr, uid, procurement, context=context):
+ procurement.refresh()
+ self._run(cr, uid, procurement, context=context or {})
+ self.write(cr, uid, [procurement.id], {'state': 'running'}, context=context)
+ else:
+ self.message_post(cr, uid, [procurement.id], body=_('No rule matching this procurement'), context=context)
+ self.write(cr, uid, [procurement.id], {'state': 'exception'}, context=context)
return True
def check(self, cr, uid, ids, context=None):
diff --git a/addons/sale_journal/sale_journal_view.xml b/addons/sale_journal/sale_journal_view.xml
index 3247f73d1cd..0c11029b48b 100644
--- a/addons/sale_journal/sale_journal_view.xml
+++ b/addons/sale_journal/sale_journal_view.xml
@@ -128,7 +128,7 @@
stock.picking
-
+
diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py
index 95ebfa33e89..3163365ffc0 100644
--- a/addons/sale_stock/sale_stock.py
+++ b/addons/sale_stock/sale_stock.py
@@ -205,16 +205,20 @@ class sale_order(osv.osv):
write_done_ids = []
write_cancel_ids = []
for order in self.browse(cr, uid, ids, context={}):
+ #TODO: Need to rethink what happens when cancelling
for line in order.order_line:
- for procurement in line.procurement_ids:
- if procurement.state == 'done':
- write_done_ids.append(line.id)
- else:
- finished = False
- if (procurement.state == 'cancel'):
- canceled = True
- if line.state != 'exception':
+ states = [x.state for x in line.procurement_ids]
+ cancel = all([x == 'cancel' for x in states])
+ doneorcancel = all([x in ('done', 'cancel') for x in states])
+ if cancel:
+ canceled = True
+ if line.state != 'exception':
write_cancel_ids.append(line.id)
+ if not doneorcancel:
+ finished = False
+ if doneorcancel and not cancel:
+ write_done_ids.append(line.id)
+
if write_done_ids:
self.pool.get('sale.order.line').write(cr, uid, write_done_ids, {'state': 'done'})
if write_cancel_ids:
@@ -256,8 +260,7 @@ class sale_order(osv.osv):
res = []
for order in self.browse(cr, uid, ids, context={}):
for line in order.order_line:
- if line.procurement_id:
- res.append(line.procurement_id.id)
+ res += [x.id for x in line.procurement_ids]
return res
class sale_order_line(osv.osv):