Nimesh Contractor(Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-cancel-po-atp-partial_return-nco into 
lp:~openerp-dev/openobject-addons/trunk-cancel-po-atp.

Requested reviews:
  Atul Patel(OpenERP) (atp-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-cancel-po-atp-partial_return-nco/+merge/122218

Hello sir,

         When partially product are retrun, po can't be cancelled, if all 
products are not returned for that po.

Thanks,
 NCO.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-cancel-po-atp-partial_return-nco/+merge/122218
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-cancel-po-atp.
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py	2012-08-30 17:39:27 +0000
+++ purchase/purchase.py	2012-08-31 09:39:30 +0000
@@ -490,13 +490,14 @@
     
     def action_cancel(self, cr, uid, ids, context=None):
         wf_service = netsvc.LocalService("workflow")
-        pick_obj = self.pool.get('stock.picking')
+        move_obj = self.pool.get('stock.move')
         inv_obj = self.pool.get('account.invoice')
         for purchase in self.browse(cr, uid, ids, context=context):
             for pick in purchase.picking_ids:
                 if pick.state == 'done':
-                    picking_out_ids = pick_obj.search(cr, uid, [('type','=','out'),('state','=','done'), ('purchase_id.id', '=', purchase.id)], context=context)
-                    if picking_out_ids:
+                    move_out_ids = move_obj.search(cr, uid, [('picking_id.type','=','out'),('state','=','done'),('origin', '=', pick.origin)], context=context)
+                    move_in_ids = move_obj.search(cr, uid, [('picking_id.type','=','in'),('state','=','done'),('origin', '=', pick.origin)], context=context)
+                    if len(move_out_ids) == len(move_in_ids):
                         wf_service.trg_validate(uid, 'purchase.order', purchase.id, 'purchase_cancel', cr)
                     else:
                         raise osv.except_osv(

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to