summaryrefslogtreecommitdiff
path: root/addons/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'addons/plugin')
-rw-r--r--addons/plugin/plugin_handler.py36
1 files changed, 17 insertions, 19 deletions
diff --git a/addons/plugin/plugin_handler.py b/addons/plugin/plugin_handler.py
index 42754951317..95fe80f3b29 100644
--- a/addons/plugin/plugin_handler.py
+++ b/addons/plugin/plugin_handler.py
@@ -6,7 +6,6 @@ Created on 18 oct. 2011
from osv import osv, fields
-
class plugin_handler(osv.osv_memory):
_name = 'plugin.handler'
@@ -37,7 +36,7 @@ class plugin_handler(osv.osv_memory):
@param email: email is a standard RFC2822 email message
@return Dictionary which contain id and the model name of the document linked with the mail
if no document is found the id = 0
- (model_name, res_id, url, name_get)
+ (model_name, res_id, url, name_get)
"""
mail_message_obj = self.pool.get('mail.message')
model = ""
@@ -52,7 +51,7 @@ class plugin_handler(osv.osv_memory):
msg_ids = mail_message_obj.search(cr, uid, [('message_id','=', message_id)])
msg_id = len(msg_ids) and msg_ids[0] or False
if not msg_id and parent_id:
- msg_id = parent_id
+ msg_id = parent_id
if msg_id:
msg = mail_message_obj.browse(cr, uid, msg_id)
res_id = msg.res_id
@@ -61,7 +60,6 @@ class plugin_handler(osv.osv_memory):
name = self.pool.get(model).name_get(cr, uid, [res_id])[0][1]
return (model,res_id, url,name)
-
def document_type(self, cr, uid, context=None):
"""
Return the list of available model to push
@@ -74,13 +72,13 @@ class plugin_handler(osv.osv_memory):
doc_dict['res.partner'] = "Partner"
return doc_dict.items()
- # Can be used where search record was used
+ # Can be used where search record was used
def list_document_get(self, cr, uid, model, name):
"""
This function return the result of name_search on the object model
- @param model: the name of the model
+ @param model: the name of the model
@param : the name of the document
- @return : the result of name_search a list of tuple
+ @return : the result of name_search a list of tuple
[(id, 'name')]
"""
return self.pool.get(model).name_search(cr, uid, name)
@@ -89,7 +87,7 @@ class plugin_handler(osv.osv_memory):
"""
@param email: email is a standard RFC2822 email message
@param model: On which model the message is pushed
- @param thread_id: on which document the message is pushed, if thread_id = 0 a new document is created
+ @param thread_id: on which document the message is pushed, if thread_id = 0 a new document is created
@return Dictionary which contain model , url and resource id.
"""
mail_message = self.pool.get('mail.message')
@@ -97,7 +95,7 @@ class plugin_handler(osv.osv_memory):
msg = self.pool.get('mail.thread').message_parse(cr, uid, email)
message_id = msg.get('message-id')
mail_ids = mail_message.search(cr, uid, [('message_id','=',message_id),('res_id','=',res_id),('model','=',model)])
-
+
if message_id and mail_ids :
mail_record = mail_message.browse(cr, uid, mail_ids)[0]
res_id = mail_record.res_id
@@ -109,11 +107,11 @@ class plugin_handler(osv.osv_memory):
res_id = model_obj.message_process(cr, uid, model, email)
notify = "Mail successfully pushed, a new %s has been created " % model
else:
- model_obj.message_post(cr, uid, [res_id],
- body= msg.get('body'),
- subject= msg.get('subject'),
- type= 'email',
- parent_id= msg.get('parent_id'),
+ model_obj.message_post(cr, uid, [res_id],
+ body= msg.get('body'),
+ subject= msg.get('subject'),
+ type= 'email',
+ parent_id= msg.get('parent_id'),
attachments= msg.get('attachments'))
notify = "Mail successfully pushed"
url = self._make_url(cr, uid, res_id, model)
@@ -123,7 +121,7 @@ class plugin_handler(osv.osv_memory):
"""
@param data : the data use to create the res.partner
[('field_name', value)], field name is required
- @param partner_id : On which partner the address is attached
+ @param partner_id : On which partner the address is attached
if partner_id = 0 then create a new partner with the same name that the address
@return : the partner_id sended or created, this allow the plugin to open the right partner page
"""
@@ -138,7 +136,7 @@ class plugin_handler(osv.osv_memory):
return ('res.partner', partner_id, url)
# Specific to outlook rfc822 is not available so we split in arguments headerd,body,attachemnts
- def push_message_outlook(self, cr, uid, model, headers,res_id=0 ,body=False, body_html=False, attachments=False):
+ def push_message_outlook(self, cr, uid, model, headers, res_id=0, body=False, body_html=False, attachments=False):
# ----------------------------------------
# solution 1
# construct a fake rfc822 from the separated arguement
@@ -149,14 +147,14 @@ class plugin_handler(osv.osv_memory):
# solution 2
# use self.pushmessage only with header and body
# add attachemnt yourself after
- mail_message = self.pool.get('mail.message')
+ mail_message = self.pool.get('mail.message')
ir_attachment_obj = self.pool.get('ir.attachment')
attach_ids = []
msg = self.pool.get('mail.thread').message_parse(cr, uid, headers)
- message_id = msg.get('message-id')
+ message_id = msg.get('message-id')
push_mail = self.push_message(cr, uid, model, headers, res_id)
res_id = push_mail[1]
- model = push_mail[0]
+ model = push_mail[0]
for name in attachments.keys():
attachment_ids = ir_attachment_obj.search(cr, uid, [('res_model', '=', model), ('res_id', '=', res_id), ('datas_fname', '=', name)])
if attachment_ids: