Merge lp:~openerp-dev/openobject-addons/5.0-opw-17363-skh into lp:openobject-addons/5.0

Proposed by Somesh Khare
Status: Merged
Merged at revision: 2920
Proposed branch: lp:~openerp-dev/openobject-addons/5.0-opw-17363-skh
Merge into: lp:openobject-addons/5.0
Diff against target: 24 lines (+7/-0)
1 file modified
sale/sale.py (+7/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/5.0-opw-17363-skh
Reviewer Review Type Date Requested Status
Raphael Collet (OpenERP) (community) Approve
OpenERP Core Team Pending
Review via email: mp+74421@code.launchpad.net

Description of the change

Hello,

Current scenario:
   When create a sale order with MTO product/Buy, and cancel the picking for the order and cancel the sale order,
--- Procurement order is still in the confirm state.

Expected Scenario:
   When the sale order cancelled with all its picking, Procurement order should also be in the cancelled state.

proposed patch fixed this issue.

Thanks.

To post a comment you must log in.
Revision history for this message
Raphael Collet (OpenERP) (rco-openerp) wrote :

It looks fine. Have you tested it?

Revision history for this message
Raphael Collet (OpenERP) (rco-openerp) wrote :

It works, thanks.

review: Approve
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

I would like to suggest one thing here.

You could have optimized the code by removing one for loop of picking_id:
I meant, self.read and sale.picking_ids would be always same!

Similar logic should have been applied for invoice_ids as well.

Additionally:
1. To reach to procurements, you may also reach by sale order lines!
2. wf_service = netsvc.LocalService("workflow") has been used twice. You could have opted to optimize that as well.
3. Based on the suggestion of reducing loops, you can improve v6 as well.

Thanks.

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 2011-05-16 14:11:53 +0000
3+++ sale/sale.py 2011-09-07 13:03:34 +0000
4@@ -501,6 +501,7 @@
5
6 def action_cancel(self, cr, uid, ids, context={}):
7 ok = True
8+ wf_service = netsvc.LocalService("workflow")
9 sale_order_line_obj = self.pool.get('sale.order.line')
10 for sale in self.browse(cr, uid, ids):
11 for pick in sale.picking_ids:
12@@ -508,6 +509,12 @@
13 raise osv.except_osv(
14 _('Could not cancel sale order !'),
15 _('You must first cancel all packing attached to this sale order.'))
16+ if pick.state == 'cancel':
17+ for mov in pick.move_lines:
18+ proc_ids = self.pool.get('mrp.procurement').search(cr, uid, [('move_id', '=', mov.id)])
19+ if proc_ids:
20+ for proc in proc_ids:
21+ wf_service.trg_validate(uid, 'mrp.procurement', proc, 'button_check', cr)
22 for r in self.read(cr, uid, ids, ['picking_ids']):
23 for pick in r['picking_ids']:
24 wf_service = netsvc.LocalService("workflow")