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

Requested reviews:
  Bhumika (OpenERP) (sbh-openerp)
Related bugs:
  Bug #772724 in OpenERP Addons: "[project] If one task is done, error on 
re-scheduling Tasks"
  https://bugs.launchpad.net/openobject-addons/+bug/772724

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

Changes :
 - [FIX]Bug #772724 : [project] If one task is done, error on re-scheduling 
Tasks
Kindly Review This.
Thank You
    

-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-772724-jam/+merge/65444
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-772724-jam.
=== modified file 'project/project.py'
--- project/project.py	2011-06-15 15:35:22 +0000
+++ project/project.py	2011-06-22 06:33:10 +0000
@@ -529,8 +529,6 @@
     #
     # Override view according to the company definition
     #
-
-
     def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
         users_obj = self.pool.get('res.users')
 
@@ -562,13 +560,27 @@
                 res['fields'][f]['string'] = res['fields'][f]['string'].replace('Hours',tm)
         return res
 
+    def _check_child_task(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
+        tasks = self.browse(cr, uid, ids, context=context)
+        for task in tasks:
+            if task.child_ids:
+                for child in task.child_ids:
+                    if child.state in ['draft', 'open', 'pending']:
+                        raise osv.except_osv(_("Warning !"), _("Child task still open.\nPlease cancel or complete child task first."))
+        return True
+
     def action_close(self, cr, uid, ids, context=None):
         # This action open wizard to send email to partner or project manager after close task.
-        project_id = len(ids) and ids[0] or False
-        if not project_id: return False
-        task = self.browse(cr, uid, project_id, context=context)
+        if context == None:
+            context = {}
+        task_id = len(ids) and ids[0] or False
+        self._check_child_task(cr, uid, ids, context=context)
+        if not task_id: return False
+        task = self.browse(cr, uid, task_id, context=context)
         project = task.project_id
-        res = self.do_close(cr, uid, [project_id], context=context)
+        res = self.do_close(cr, uid, [task_id], context=context)
         if project.warn_manager or project.warn_customer:
             return {
                 'name': _('Send Email after close task'),
@@ -643,6 +655,7 @@
     def do_cancel(self, cr, uid, ids, *args):
         request = self.pool.get('res.request')
         tasks = self.browse(cr, uid, ids)
+        self._check_child_task(cr, uid, ids, context=context)
         for task in tasks:
             project = task.project_id
             if project.warn_manager and project.user_id and (project.user_id.id != uid):
@@ -736,13 +749,19 @@
                     index = sorted_types.index(typeid)
                     self.write(cr, uid, task.id, {'type_id': sorted_types[index+1]})
         return True
-        
+
     def next_type(self, cr, uid, ids, *args):
         return self._change_type(cr, uid, ids, True, *args)
 
     def prev_type(self, cr, uid, ids, *args):
         return self._change_type(cr, uid, ids, False, *args)
-       
+
+    def unlink(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
+        self._check_child_task(cr, uid, ids, context=context)
+        res = super(task, self).unlink(cr, uid, ids, context)
+        return res
 
 task()
 

_______________________________________________
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