Merge lp:~hbee/openobject-addons/7.0-merge_purchase_requisitions_wkf_fix into lp:~therp-nl/openobject-addons/7.0-merge_purchase_requisitions

Proposed by Paulius Sladkevičius @ hbee
Status: Merged
Merged at revision: 9552
Proposed branch: lp:~hbee/openobject-addons/7.0-merge_purchase_requisitions_wkf_fix
Merge into: lp:~therp-nl/openobject-addons/7.0-merge_purchase_requisitions
Diff against target: 46 lines (+10/-6)
1 file modified
purchase_requisition/wizard/purchase_requisition_merge.py (+10/-6)
To merge this branch: bzr merge lp:~hbee/openobject-addons/7.0-merge_purchase_requisitions_wkf_fix
Reviewer Review Type Date Requested Status
Stefan Rijnhart (Opener) (community) Needs Information
Review via email: mp+193705@code.launchpad.net

Description of the change

Without workflow redirect of merged requisitions procurements get stuck

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks! I gather that this code redirects the requisition subflow on the procurement order. I think this change ignores the possibility of a requisition with remaining lines. The target branch for that reason moves the actual link betwee procurements and requisitions to the level of the requisition line. Therefore, it seems to me that the workflow should be redirected when the requisition_line_id is written to the procurement order, in make_po(). What do you think?

review: Needs Information
Revision history for this message
Paulius Sladkevičius @ hbee (komsas) wrote :

Mine code redirects removed requisitions to a new created requisitions, that should be fine. Your concern about remaining lines is correct, that should be handled too.

I see problem that requisition line don't have states or workflow, like a task/stock move.
What about situation when half requisition lines will be merged others not, when procurement should go to done/cancel state? Theoretically I think it should go when both requisitions workflow are finished.

To solve this we should take similar why how is stock move or tasks are handled on the procurement, but problem is that we have procurement subflow to requisition not to requisition line.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Can you please expand on the problems that you foresee? I don't see the problem so far.

Procurement orders can only refer to a single line. When the wizard in this branch unlinks a requisition because it has no lines, there should not be a purchase order refering to it.

When requisitions are merged and then later on split up again, updating the individual procurement orders subflow with the new requisition ids derived from the requisition lines should suffice. Then, when a requisition is cancelled, the procurement workflow should pick this up automatically.

While it is true that requisition lines do not have state, their requisitions do and the wizard only works on lines from draft requisitions (+ additional restrictions) so repartitioning those should not affect their procurement orders' workflow states.

Am I missing something?

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Oh, I can think of one issue now, when looking at this branch: https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-opw-593185-rha/+merge/166651 (merged in OCB). This cleans up requisitions when procurements are cancelled. That is obviously not compatible with merged requisitions. It should probably be refactored to raise an error saying that the procurement can only be cancelled once the requisition has been cleaned up manually if there are more than one lines on the requisition.

Revision history for this message
Paulius Sladkevičius @ hbee (komsas) wrote :

You are right, if you update procurement orders subflow individually when they will be merged to a new requisition it should work fine. Let me know (like a reviewer I suppose) to check a new code regarding this issue, then I could test it out. If you don't plan to make it I could try to check out where to put such patch.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Paulius,

to follow up on this issue, I started out by merging your branch (also to give you credits). I ended up though as expected by reverting your fix and updating the procurement subflows based on the requisition ids of each requisition line with a ridiculous sql query here: http://bazaar.launchpad.net/~therp-nl/openobject-addons/7.0-merge_purchase_requisitions/revision/9553.

Thank you very much for pointing out the workflow issues and suggesting a fix!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'purchase_requisition/wizard/purchase_requisition_merge.py'
2--- purchase_requisition/wizard/purchase_requisition_merge.py 2013-10-29 09:29:53 +0000
3+++ purchase_requisition/wizard/purchase_requisition_merge.py 2013-11-03 19:35:11 +0000
4@@ -23,6 +23,7 @@
5
6 from openerp.osv import orm, fields
7 from openerp.tools.translate import _
8+from openerp import netsvc
9
10
11 class purchase_requisition_merge(orm.TransientModel):
12@@ -63,12 +64,13 @@
13
14 @return: act window to the form view of the newly created requisition
15 """
16+ wf_service = netsvc.LocalService("workflow")
17 merge = self.browse(cr, uid, merge_ids[0], context=context)
18 if not merge.line_ids:
19 orm.except_orm(
20 _('Error'),
21 _('Please select a number of requisition lines to merge.'))
22-
23+
24 # Get a unique set of requisitions from the list of lines
25 requisitions = list(set(
26 [line.requisition_id for line in merge.line_ids]))
27@@ -89,12 +91,14 @@
28 requisition_obj.write(
29 cr, uid, target_requisition_id,
30 {'date_end': minimum_date_planned}, context=context)
31-
32+
33 requisitions[0].refresh()
34- requisition_obj.unlink(
35- cr, uid,
36- [req.id for req in requisitions if not req.line_ids],
37- context=context)
38+
39+ requisitions = [req.id for req in requisitions if not req.line_ids]
40+ for old_id in requisitions:
41+ wf_service.trg_redirect(uid, 'purchase.requisition', old_id,
42+ target_requisition_id, cr)
43+ requisition_obj.unlink(cr, uid, requisitions, context=context)
44
45 return {
46 'type': 'ir.actions.act_window',

Subscribers

People subscribed via source and target branches

to all changes: