summaryrefslogtreecommitdiff
path: root/addons/project_mailgate/project_mailgate.py
diff options
context:
space:
mode:
authorVijaykumar Baladaniya <vba@tinyerp.com>2012-07-09 18:31:13 +0530
committerVijaykumar Baladaniya <vba@tinyerp.com>2012-07-09 18:31:13 +0530
commitbe2e95656aaa113addea2b510fcdcf2f890eaaa4 (patch)
treeabcb3dd4ef350a1b8ad0eaffdd2b9a1cb91521af /addons/project_mailgate/project_mailgate.py
parentb982ea278b33132def3927417b7a854b98b5028a (diff)
parent3925f76ce85854e5d4834902a05f57bcfc5ace85 (diff)
[MERGE]merged with trunk-survey-layout-tta
bzr revid: vba@tinyerp.com-20120709130113-3lchipgil9oqpglg
Diffstat (limited to 'addons/project_mailgate/project_mailgate.py')
-rw-r--r--addons/project_mailgate/project_mailgate.py43
1 files changed, 23 insertions, 20 deletions
diff --git a/addons/project_mailgate/project_mailgate.py b/addons/project_mailgate/project_mailgate.py
index a36366f450e..0ca2687b7f0 100644
--- a/addons/project_mailgate/project_mailgate.py
+++ b/addons/project_mailgate/project_mailgate.py
@@ -19,30 +19,35 @@
#
##############################################################################
+import binascii
from osv import fields, osv
from tools.translate import _
import tools
-import binascii
-
class project_tasks(osv.osv):
_inherit = 'project.task'
def message_new(self, cr, uid, msg, custom_values=None, context=None):
- res_id = super(project_tasks,self).message_new(cr, uid, msg, custom_values=custom_values, context=context)
- subject = msg.get('subject')
- msg_from = msg.get('from')
- data = {
+ """ Overrides mail_thread message_new that is called by the mailgateway
+ through message_process.
+ This override updates the document according to the email.
+ """
+ if custom_values is None: custom_values = {}
+ custom_values.update({
'name': subject,
'planned_hours': 0.0,
- }
- data.update(self.message_partner_by_email(cr, uid, msg_from))
- self.write(cr, uid, [res_id], data, context)
- return res_id
-
- def message_update(self, cr, uid, ids, msg, data={}, default_act='pending'):
- act = 'do_'+default_act
+ 'subject': msg.get('subject'),
+ })
+ custom_values.update(self.message_partner_by_email(cr, uid, msg.get('from', False), context=context))
+ return super(project_tasks,self).message_new(cr, uid, msg, custom_values=custom_values, context=context)
+ def message_update(self, cr, uid, ids, msg, update_vals=None, context=None):
+ """ Overrides mail_thread message_update that is called by the mailgateway
+ through message_process.
+ This method updates the task according to the email.
+ """
+ if update_vals is None: update_vals = {}
+ act = False
maps = {
'cost':'planned_hours',
}
@@ -54,17 +59,15 @@ class project_tasks(osv.osv):
field = maps.get(match)
if field:
try:
- data[field] = float(res.group(2).lower())
+ update_vals[field] = float(res.group(2).lower())
except (ValueError, TypeError):
pass
elif match.lower() == 'state' \
and res.group(2).lower() in ['cancel','close','draft','open','pending']:
act = 'do_%s' % res.group(2).lower()
-
- self.write(cr, uid, ids, data, context=context)
- getattr(self,act)(cr, uid, ids, context=context)
- self.message_append_note(cr, uid, [res_id], body=msg, context=context)
- return True
+ if act:
+ getattr(self,act)(cr, uid, ids, context=context)
+ return super(project_tasks,self).message_update(cr, uid, msg, update_vals=update_vals, context=context)
def message_thread_followers(self, cr, uid, ids, context=None):
followers = super(project_tasks,self).message_thread_followers(cr, uid, ids, context=context)
@@ -74,5 +77,5 @@ class project_tasks(osv.osv):
followers[task.id] = filter(None, task_followers)
return followers
-project_tasks()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: