← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/trunk-bug-subscription-jam into lp:openobject-addons

 

Jigar Amin - OpenERP has proposed merging lp:~openerp-dev/openobject-addons/trunk-bug-subscription-jam into lp:openobject-addons.

Requested reviews:
  Bhumika (OpenERP) (sbh-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-subscription-jam/+merge/60028

[FIX] subscription : Unlinking cron job on Subscription unlinking
[FIX] subscription : if cron job is unlinked than on setting Subscription to Done gives traceback

Kindly Review this
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-subscription-jam/+merge/60028
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-subscription-jam.
=== modified file 'subscription/subscription.py'
--- subscription/subscription.py	2011-01-14 00:11:01 +0000
+++ subscription/subscription.py	2011-05-05 08:49:25 +0000
@@ -138,14 +138,27 @@
 
     def set_done(self, cr, uid, ids, context=None):
         res = self.read(cr,uid, ids, ['cron_id'])
-        ids2 = [x['cron_id'][0] for x in res if x['id']]
-        self.pool.get('ir.cron').write(cr, uid, ids2, {'active':False})
+        if res and res[0].get('cron_id'):
+            ids2 = [x['cron_id'][0] for x in res if x['id']]
+            self.pool.get('ir.cron').write(cr, uid, ids2, {'active':False})
         self.write(cr, uid, ids, {'state':'done'})
         return True
 
     def set_draft(self, cr, uid, ids, context=None):
         self.write(cr, uid, ids, {'state':'draft'})
         return True
+    
+    def unlink(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
+        current_rec = self.browse(cr, uid, ids, context=context)
+        #On deleation of the Subscription unlink related the cron job 
+        for record in current_rec:
+            if record.cron_id:
+                self.pool.get('ir.cron').unlink(cr, uid,record.cron_id.id, context=context)
+        res = super(subscription_subscription, self).unlink(cr, uid, ids, context)
+        return res
+
 subscription_subscription()
 
 class subscription_subscription_history(osv.osv):