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

Requested reviews:
  Bhumika (OpenERP) (sbh-openerp)
Related bugs:
  Bug #707984 in OpenERP Addons: "[project_mailgate] Terms in history are not 
entirely translated"
  https://bugs.launchpad.net/openobject-addons/+bug/707984

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

Changes :
  - Bug #707984 : [project_mailgate] Terms in history are not entirely 
translated
    + Button Methods are written to with Work flow, so it was not passing the 
context and because of that translation was not working in history so cleaned 
the wrong parameters.
    + Improved the Code usability of the project_mailgate.py file
Kindly Review this.
Thank You

-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-707984-jam/+merge/65309
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-707984-jam.
=== modified file 'project/project.py'
--- project/project.py	2011-06-15 15:35:22 +0000
+++ project/project.py	2011-06-21 07:27:30 +0000
@@ -586,6 +586,8 @@
         """
         Close Task
         """
+        if context == None:
+            context = {}
         request = self.pool.get('res.request')
         for task in self.browse(cr, uid, ids, context=context):
             vals = {}
@@ -640,7 +642,9 @@
 
         return True
 
-    def do_cancel(self, cr, uid, ids, *args):
+    def do_cancel(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
         request = self.pool.get('res.request')
         tasks = self.browse(cr, uid, ids)
         for task in tasks:
@@ -660,7 +664,9 @@
             self.write(cr, uid, [task.id], {'state': 'cancelled', 'remaining_hours':0.0})
         return True
 
-    def do_open(self, cr, uid, ids, *args):
+    def do_open(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
         tasks= self.browse(cr,uid,ids)
         for t in tasks:
             data = {'state': 'open'}
@@ -671,7 +677,9 @@
             self.log(cr, uid, t.id, message)
         return True
 
-    def do_draft(self, cr, uid, ids, *args):
+    def do_draft(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
         self.write(cr, uid, ids, {'state': 'draft'})
         return True
 
@@ -707,7 +715,9 @@
         self.log(cr, uid, task.id, message)
         return True
 
-    def do_pending(self, cr, uid, ids, *args):
+    def do_pending(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
         self.write(cr, uid, ids, {'state': 'pending'})
         for (id, name) in self.name_get(cr, uid, ids):
             message = _("The task '%s' is pending.") % name

=== modified file 'project_mailgate/project_mailgate.py'
--- project_mailgate/project_mailgate.py	2011-01-14 00:11:01 +0000
+++ project_mailgate/project_mailgate.py	2011-06-21 07:27:30 +0000
@@ -19,17 +19,19 @@
 #
 ##############################################################################
 
-from osv import fields,osv
+from osv import fields, osv
 from tools.translate import _
 import binascii
 
+
 class project_tasks(osv.osv):
     _name = "project.task"
-    _inherit = ['mailgate.thread','project.task']
-    
+    _inherit = ['mailgate.thread', 'project.task']
+
     _columns={
-                'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)], readonly=True),
+                'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model', '=', _name)], readonly=True),
               }
+
     def message_new(self, cr, uid, msg, context=None):
 #        """
 #        Automatically calls when new email message arrives
@@ -44,21 +46,21 @@
         msg_from = msg.get('from')
         priority = msg.get('priority')
 
-        data = {      
+        data = {
             'name': subject,
             'description': body,
-            'planned_hours' : 0.0,
+            'planned_hours': 0.0,
         }
         res = mailgate_obj.get_partner(cr, uid, msg_from)
         if res:
             data.update(res)
-        res = self.create(cr, uid, data)    
-        
+        res = self.create(cr, uid, data)
+
         attachments = msg.get('attachments', [])
         for attachment in attachments or []:
             data_attach = {
                 'name': attachment,
-                'datas':binascii.b2a_base64(str(attachments.get(attachment))),
+                'datas': binascii.b2a_base64(str(attachments.get(attachment))),
                 'datas_fname': attachment,
                 'description': 'Mail attachment',
                 'res_model': self._name,
@@ -66,31 +68,31 @@
             }
             self.pool.get('ir.attachment').create(cr, uid, data_attach)
 
-        return res           
-    
-    def message_update(self, cr, uid, id, msg, data={}, default_act='pending'): 
+        return res
+
+    def message_update(self, cr, uid, id, msg, data={}, default_act='pending'):
         mailgate_obj = self.pool.get('email.server.tools')
-        msg_actions, body_data = mailgate_obj.msg_act_get(msg)           
+        msg_actions, body_data = mailgate_obj.msg_act_get(msg)
         data.update({
-            'description': body_data,            
+            'description': body_data,
         })
         act = 'do_'+default_act
         if 'state' in msg_actions:
-            if msg_actions['state'] in ['draft','close','cancel','open','pending']:
+            if msg_actions['state'] in ['draft', 'close', 'cancel', 'open', 'pending']:
                 act = 'do_' + msg_actions['state']
-        
-        for k1,k2 in [('cost','planned_hours')]:
+
+        for k1, k2 in [('cost', 'planned_hours')]:
             try:
                 data[k2] = float(msg_actions[k1])
             except:
                 pass
 
         if 'priority' in msg_actions:
-            if msg_actions['priority'] in ('1','2','3','4','5'):
+            if msg_actions['priority'] in ('1', '2', '3', '4', '5'):
                 data['priority'] = msg_actions['priority']
-        
+
         self.write(cr, uid, [id], data)
-        getattr(self,act)(cr, uid, [id])
+        getattr(self, act)(cr, uid, [id])
         return True
 
     def message_followers(self, cr, uid, ids, context=None):
@@ -108,7 +110,7 @@
 
     def msg_send(self, cr, uid, id, *args, **argv):
         return True
-    
+
     def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context=None):
         mailgate_pool = self.pool.get('mailgate.thread')
         return mailgate_pool.history(cr, uid, cases, keyword, history=history,\
@@ -116,37 +118,47 @@
                                        details=details, email_from=email_from,\
                                        message_id=message_id, attach=attach, \
                                        context=context)
-        
-    def do_draft(self, cr, uid, ids, *args, **kwargs):
-        res = super(project_tasks, self).do_draft(cr, uid, ids, *args, **kwargs)
-        tasks = self.browse(cr, uid, ids)
-        self._history(cr, uid, tasks, _('Draft'))
-        return res
-    
-    def do_open(self, cr, uid, ids, *args, **kwargs):
-        res = super(project_tasks, self).do_open(cr, uid, ids, *args, **kwargs)
-        tasks = self.browse(cr, uid, ids)
-        self._history(cr, uid, tasks, _('Open'))
-        return res
-    
-    def do_pending(self, cr, uid, ids, *args, **kwargs):
-        res = super(project_tasks, self).do_pending(cr, uid, ids, *args, **kwargs)
-        tasks = self.browse(cr, uid, ids)
-        self._history(cr, uid, tasks, _('Pending'))
-        return res
-    
-    def do_close(self, cr, uid, ids, *args, **kwargs):
-        res = super(project_tasks, self).do_close(cr, uid, ids, *args, **kwargs)
-        tasks = self.browse(cr, uid, ids)
+
+    def do_draft(self, cr, uid, ids, context):
+        if context == None:
+            context = {}
+        res = super(project_tasks, self).do_draft(cr, uid, ids, context)
+        tasks = self.browse(cr, uid, ids, context=context)
+        self._history(cr, uid, tasks, _('Draft'), context=context)
+        return res
+
+    def do_open(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
+        res = super(project_tasks, self).do_open(cr, uid, ids, context)
+        tasks = self.browse(cr, uid, ids, context=context)
+        self._history(cr, uid, tasks, _('Open'), context=context)
+        return res
+
+    def do_pending(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
+        res = super(project_tasks, self).do_pending(cr, uid, ids, context)
+        tasks = self.browse(cr, uid, ids, context=context)
+        self._history(cr, uid, tasks, _('Pending'), context=context)
+        return res
+
+    def do_close(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
+        res = super(project_tasks, self).do_close(cr, uid, ids, context)
+        tasks = self.browse(cr, uid, ids, context=context)
         for task in tasks:
             if task.state == 'done':
-                self._history(cr, uid, tasks, _('Done'))
+                self._history(cr, uid, tasks, _('Done'), context=context)
         return res
-    
-    def do_cancel(self, cr, uid, ids, *args, **kwargs):
-        res = super(project_tasks, self).do_cancel(cr, uid, ids, *args, **kwargs)
-        tasks = self.browse(cr, uid, ids)
-        self._history(cr, uid, tasks, _('Cancel'))
+
+    def do_cancel(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
+        res = super(project_tasks, self).do_cancel(cr, uid, ids, context=context)
+        tasks = self.browse(cr, uid, ids, context=context)
+        self._history(cr, uid, tasks, _('Cancel'), context=context)
         return res
 
 project_tasks()

_______________________________________________
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