Merge lp:~donkirkby/openobject-addons/mrp-jit-restart into lp:openobject-addons/5.0

Proposed by Don Kirkby
Status: Needs review
Proposed branch: lp:~donkirkby/openobject-addons/mrp-jit-restart
Merge into: lp:openobject-addons/5.0
Diff against target: 38 lines (+7/-0)
1 file modified
sale/sale.py (+7/-0)
To merge this branch: bzr merge lp:~donkirkby/openobject-addons/mrp-jit-restart
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) incorrect functional patch Disapprove
Review via email: mp+19750@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Don Kirkby (donkirkby) wrote :

This is my suggestion for fixing bug lp:522977. I took the simplistic approach of just triggering the button_restart signal on all the procurements after the stock picking has been confirmed for a sales order. There may be a way to change the order of things so that the procurement can just flow all the way through its work flow the first time, but I'm not familiar enough with it to know.

I have done two simple tests for this fix:
1. I created a new database with the mrp_jit module and the sample data, and then created and confirmed a sales order for a PC1 product. The order immediately appeared in the Available Packing list for outgoing products. This was the original bug scenario.
2. I did the exact same scenario, but on a database without the mrp_jit module. No errors were raised, and the order appeared in the Available Packing list after I ran the Compute All Schedulers wizard.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

As indicated in the MP, this does not seem to be the correct way to fix the issue, but I need to analyze it further (which is why I'm only commenting now - review will follow)

mrp_jit is a trivial module to short-circuit the trigger signal before the procurement computation, so the regular procurement workflow should indeed handle this case in a graceful manner.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Further analysis: this was broken by revision 1634, it used to work before:
  http://bazaar.launchpad.net/~openerp/openobject-addons/5.0/revision/1634

The workaround I propose instead of this 'button_restart' hack, and short of reverting rev 1634, is to allow mrp.procurement.action_confirm() to also confirm draft stock.moves, not just 'waiting' ones.
This change also seems sensible and correct to me.

The patch is trivial, but as I said on bug 522977, I still need a test case before landing it on stable. Hopefully I will be able to do that tomorrow before 5.0.7.

If you want to help test it, I will attach the patch to the bug now.

review: Disapprove (incorrect functional patch)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sale/sale.py'
2--- sale/sale.py 2010-02-08 13:14:47 +0000
3+++ sale/sale.py 2010-02-19 22:25:23 +0000
4@@ -567,6 +567,7 @@
5 for order in self.browse(cr, uid, ids, context={}):
6 output_id = order.shop_id.warehouse_id.lot_output_id.id
7 picking_id = False
8+ proc_ids = []
9 for line in order.order_line:
10 proc_id = False
11 date_planned = DateTime.now() + DateTime.DateTimeDeltaFromDays(line.delay or 0.0)
12@@ -625,6 +626,7 @@
13 'move_id': move_id,
14 'property_ids': [(6, 0, [x.id for x in line.property_ids])],
15 })
16+ proc_ids.append(proc_id)
17 wf_service = netsvc.LocalService("workflow")
18 wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
19 self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
20@@ -640,6 +642,7 @@
21 'procure_method': line.type,
22 'property_ids': [(6, 0, [x.id for x in line.property_ids])],
23 })
24+ proc_ids.append(proc_id)
25 self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
26 wf_service = netsvc.LocalService("workflow")
27 wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
28@@ -653,6 +656,10 @@
29 if picking_id:
30 wf_service = netsvc.LocalService("workflow")
31 wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
32+ for proc_id in proc_ids:
33+ wf_service = netsvc.LocalService("workflow")
34+ wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_restart', cr)
35+
36
37 if order.state == 'shipping_except':
38 val['state'] = 'progress'