diff --git a/addons/mail_gateway/mail_gateway.py b/addons/mail_gateway/mail_gateway.py
index c2e1da843ca..3cb2019e85a 100644
--- a/addons/mail_gateway/mail_gateway.py
+++ b/addons/mail_gateway/mail_gateway.py
@@ -112,7 +112,7 @@ class mailgate_thread(osv.osv):
if history:
for att in attach:
attachments.append(att_obj.create(cr, uid, {'name': att[0], 'datas': base64.encodestring(att[1])}))
-
+
for param in (email, email_cc, email_bcc):
if isinstance(param, list):
param = ", ".join(param)
@@ -141,7 +141,7 @@ class mailgate_thread(osv.osv):
mailgate_thread()
def format_date_tz(date, tz=None):
- if not date:
+ if not date:
return 'n/a'
format = tools.DEFAULT_SERVER_DATETIME_FORMAT
return tools.server_to_local_timestamp(date, format, format, tz)
@@ -191,7 +191,7 @@ class mailgate_message(osv.osv):
'description': fields.text('Description', readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner', required=False),
'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments', readonly=True),
- 'display_text': fields.function(_get_display_text, method=True, type='text', size="512", string='Display Text'),
+ 'display_text': fields.function(_get_display_text, method=True, type='text', size="512", string='Display Text'),
}
def init(self, cr):
@@ -224,7 +224,7 @@ class mailgate_tool(osv.osv_memory):
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param model: OpenObject Model
- @param res_ids: Ids of the record of OpenObject model created
+ @param res_ids: Ids of the record of OpenObject model created
@param msg: Email details
@param attach: Email attachments
"""
@@ -241,7 +241,7 @@ class mailgate_tool(osv.osv_memory):
'res_model': model,
'email_cc': msg.get('cc'),
'email_from': msg.get('from'),
- 'email_to': msg.get('to'),
+ 'email_to': msg.get('to'),
'message_id': msg.get('message-id'),
'references': msg.get('references') or msg.get('in-reply-to'),
'res_id': res_id,
@@ -283,6 +283,7 @@ class mailgate_tool(osv.osv_memory):
tools.misc._email_send(smtp_from, self.to_email(email_error), msg, openobject_id=res.id)
def process_email(self, cr, uid, model, message, attach=True, context=None):
+ print "processssss_emaillllllllll",model
"""This function Processes email and create record for given OpenERP model
@param self: The object pointer
@param cr: the current row, from the database cursor,
diff --git a/addons/thunderbird/__openerp__.py b/addons/thunderbird/__openerp__.py
index 703aec6ad67..ed16b4909a9 100644
--- a/addons/thunderbird/__openerp__.py
+++ b/addons/thunderbird/__openerp__.py
@@ -22,11 +22,11 @@
{
"name" : "Thunderbird Interface",
"version" : "1.0",
- "author" : "Axelor",
- "website" : "http://www.axelor.com/",
- "depends" : ["base"],
+ "author" : "OpenERP SA & Axelor",
+ "website" : "http://www.openerp.com/",
+ "depends" : ["base","mail_gateway"],
"category" : "Generic Modules/Thunderbird interface",
- "description": '''
+ "description": """
This module is required for the thuderbird plug-in to work
properly.
@@ -35,8 +35,7 @@
a project, an analytical account, or any other object and attach selected
mail as .eml file in attachment of selected record.
- You can create new case in crm using Create Case button.
- Select a section for which you want to create case.''',
+ """,
"init_xml" : [],
"demo_xml" : [],
"update_xml" : ['thunderbird_installer.xml',
diff --git a/addons/thunderbird/partner/partner.py b/addons/thunderbird/partner/partner.py
index 9d351841f55..4e5baf25904 100644
--- a/addons/thunderbird/partner/partner.py
+++ b/addons/thunderbird/partner/partner.py
@@ -25,27 +25,117 @@ from osv import osv,fields
import base64
import netsvc
from tools.translate import _
+import email
+import tools
+import binascii
+class email_server_tools(osv.osv_memory):
+ _inherit = "email.server.tools"
+ def history_message(self, cr, uid, model, res_id, message):
+ #@param message: string of mail which is read from EML File
+ attachment_pool = self.pool.get('ir.attachment')
+ msg = self.parse_message(message)
+ attachments = msg.get('attachments', [])
+ att_ids = []
+ for attachment in attachments:
+ data_attach = {
+ 'name': attachment,
+ 'datas': binascii.b2a_base64(str(attachments.get(attachment))),
+ 'datas_fname': attachment,
+ 'description': 'Mail attachment From Thunderbird msg_id: %s' %(msg.get('message_id', '')),
+ 'res_model': model,
+ 'res_id': res_id,
+ }
+ att_ids.append(attachment_pool.create(cr, uid, data_attach))
+ return self.history(cr, uid, model, res_id, msg, att_ids)
+
+ def parse_message(self, message):
+ #TOCHECK: put this function in mailgateway
+ msg_txt = email.message_from_string(message)
+ message_id = msg_txt.get('message-id', False)
+ msg = {}
+ msg_txt = email.message_from_string(message)
+ fields = msg_txt.keys()
+ msg['id'] = message_id
+ msg['message-id'] = message_id
+
+ if 'Subject' in fields:
+ msg['subject'] = self._decode_header(msg_txt.get('Subject'))
+
+ if 'Content-Type' in fields:
+ msg['content-type'] = msg_txt.get('Content-Type')
+
+ if 'From' in fields:
+ msg['from'] = self._decode_header(msg_txt.get('From'))
+
+ if 'Delivered-To' in fields:
+ msg['to'] = self._decode_header(msg_txt.get('Delivered-To'))
+
+ if 'CC' in fields:
+ msg['cc'] = self._decode_header(msg_txt.get('CC'))
+
+ if 'Reply-to' in fields:
+ msg['reply'] = self._decode_header(msg_txt.get('Reply-To'))
+
+ if 'Date' in fields:
+ msg['date'] = self._decode_header(msg_txt.get('Date'))
+
+ if 'Content-Transfer-Encoding' in fields:
+ msg['encoding'] = msg_txt.get('Content-Transfer-Encoding')
+
+ if 'References' in fields:
+ msg['references'] = msg_txt.get('References')
+
+ if 'In-Reply-To' in fields:
+ msg['in-reply-to'] = msg_txt.get('In-Reply-To')
+
+ if 'X-Priority' in fields:
+ msg['priority'] = msg_txt.get('X-Priority', '3 (Normal)').split(' ')[0]
+
+ if not msg_txt.is_multipart() or 'text/plain' in msg.get('Content-Type', ''):
+ encoding = msg_txt.get_content_charset()
+ body = msg_txt.get_payload(decode=True)
+ msg['body'] = tools.ustr(body, encoding)
+
+ attachments = {}
+ has_plain_text = False
+ if msg_txt.is_multipart() or 'multipart/alternative' in msg.get('content-type', ''):
+ body = ""
+ for part in msg_txt.walk():
+ if part.get_content_maintype() == 'multipart':
+ continue
+
+ encoding = part.get_content_charset()
+ filename = part.get_filename()
+ if part.get_content_maintype()=='text':
+ content = part.get_payload(decode=True)
+ if filename:
+ attachments[filename] = content
+ elif not has_plain_text:
+ # main content parts should have 'text' maintype
+ # and no filename. we ignore the html part if
+ # there is already a plaintext part without filename,
+ # because presumably these are alternatives.
+ content = tools.ustr(content, encoding)
+ if part.get_content_subtype() == 'html':
+ body = tools.ustr(tools.html2plaintext(content))
+ elif part.get_content_subtype() == 'plain':
+ body = content
+ has_plain_text = True
+ elif part.get_content_maintype() in ('application', 'image'):
+ if filename :
+ attachments[filename] = part.get_payload(decode=True)
+ else:
+ res = part.get_payload(decode=True)
+ body += tools.ustr(res, encoding)
+
+ msg['body'] = body
+ msg['attachments'] = attachments
+ return msg
+email_server_tools()
class thunderbird_partner(osv.osv_memory):
_name = "thunderbird.partner"
_description="Thunderbid mails"
- _rec_name="sender"
-
- def mailcreate(self,cr,user,vals):
- dictcreate = dict(vals)
- import email
- header_name = email.Header.decode_header(dictcreate['name'])
- dictcreate['name'] = header_name and header_name[0] and header_name[0][0]
- address_obj = self.pool.get('res.partner.address')
- case_pool = self.pool.get(dictcreate.get('object','crm.lead'))
- partner_ids = address_obj.search(cr,user,[('email','=',dictcreate['email_from'])])
- partner = address_obj.read(cr,user,partner_ids,['partner_id','name'])
- if partner and partner[0] and partner[0]['partner_id']:
- dictcreate.update({'partner_id':partner[0]['partner_id'][0],'partner_name':partner[0]['name']})
- create_id = case_pool.create(cr, user, dictcreate)
- cases = case_pool.browse(cr,user,[create_id])
- case_pool._history(cr, user, cases, _('Archive'), history=True, email=False)
- return create_id
def create_contact(self,cr,user,vals):
dictcreate = dict(vals)
@@ -54,6 +144,21 @@ class thunderbird_partner(osv.osv_memory):
create_id = self.pool.get('res.partner.address').create(cr, user, dictcreate)
return create_id
+ def history_message(self,cr,uid,vals):
+ dictcreate = dict(vals)
+ server_tools_pool = self.pool.get('email.server.tools')
+ res_id = int(dictcreate.get('res_id'))
+ model = str(dictcreate.get('model'))
+ message = str(dictcreate.get('message'))
+ server_tools_pool.history_message(cr,uid,model,res_id,message)
+ return True
+
+ def process_email(self,cr,uid,vals):
+ dictcreate = dict(vals)
+ model = str(dictcreate.get('model'))
+ message = str(dictcreate.get('message'))
+ return self.pool.get('email.server.tools').process_email(cr, uid, model, message, attach=True, context=None)
+
def search_contact(self, cr, user, vals):
address_obj = self.pool.get('res.partner.address')
partner = address_obj.search(cr, user,[('email','=',vals)])
@@ -161,21 +266,7 @@ class thunderbird_partner(osv.osv_memory):
name_get.append(er_val)
return name_get
- def create_attachment(self,cr,user,vals):
- dictcreate = dict(vals)
- datas = [dictcreate['datas']]
- name = [dictcreate['name']]
- f_name = [dictcreate['datas_fname']]
- if(dictcreate['datas'].__contains__(',')):
- name = dictcreate['name'].split(',')
- datas = dictcreate['datas'].split(',')
- f_name = dictcreate['datas_fname'].split(',')
- for i in range(0,datas.__len__()):
- dictcreate['name'] = name[i]
- dictcreate['datas'] = datas[i]
- dictcreate['datas_fname'] = f_name[i]
- create_id = self.pool.get('ir.attachment').create(cr,user,dictcreate)
- return 0
+
def list_alldocument(self,cr,user,vals):
obj_list= [('crm.lead','Lead'),('project.issue','Project Issue'), ('hr.applicant','HR Recruitment')]
diff --git a/addons/thunderbird/plugin/chrome/openerp_plugin.jar b/addons/thunderbird/plugin/chrome/openerp_plugin.jar
index ac560f93909..b5ce0747bcd 100644
Binary files a/addons/thunderbird/plugin/chrome/openerp_plugin.jar and b/addons/thunderbird/plugin/chrome/openerp_plugin.jar differ
diff --git a/addons/thunderbird/plugin/chrome/openerp_plugin/content/address.xul b/addons/thunderbird/plugin/chrome/openerp_plugin/content/address.xul
index 407821ef4db..2d6f0e2dec1 100644
--- a/addons/thunderbird/plugin/chrome/openerp_plugin/content/address.xul
+++ b/addons/thunderbird/plugin/chrome/openerp_plugin/content/address.xul
@@ -17,13 +17,14 @@
+
-
+
@@ -107,8 +108,7 @@
-
-
+
diff --git a/addons/thunderbird/plugin/chrome/openerp_plugin/content/plugin.xul b/addons/thunderbird/plugin/chrome/openerp_plugin/content/plugin.xul
index b21d6e8e481..137bdca7904 100644
--- a/addons/thunderbird/plugin/chrome/openerp_plugin/content/plugin.xul
+++ b/addons/thunderbird/plugin/chrome/openerp_plugin/content/plugin.xul
@@ -34,7 +34,7 @@
Documents
-
+
diff --git a/addons/thunderbird/plugin/chrome/openerp_plugin/content/tiny_xmlrpc.js b/addons/thunderbird/plugin/chrome/openerp_plugin/content/tiny_xmlrpc.js
index eca1491224d..535b8417c7b 100755
--- a/addons/thunderbird/plugin/chrome/openerp_plugin/content/tiny_xmlrpc.js
+++ b/addons/thunderbird/plugin/chrome/openerp_plugin/content/tiny_xmlrpc.js
@@ -970,7 +970,7 @@ var listSearchContactHandler = {
var t = getMobilenumber();}
if(strlSearchResult=="email" && strlSearchResultValue!=''){
- setSenderEmail(sendername);
+ setSenderEmail(strlSearchResultValue);
var t = getSenderEmail();}
if(strlSearchResult=="res_id"){
@@ -1000,7 +1000,7 @@ var listSearchContactdetailHandler = {
if(strlSearchResult=="email" && strlSearchResultValue=='')
{
alert("Contact is not Available")
- document.getElementById("txtemail").value = sendername;
+ document.getElementById("txtemail").value = strlSearchResultValue;
}
if(strlSearchResult=="partner_name"){
document.getElementById("txtname").value =strlSearchResultValue;}
@@ -1380,7 +1380,70 @@ var listArchiveHandler = {
}
//function to archive the mail content through xmlrpc request
-function archivemail(){
+
+function parse_eml(){
+ var fpath =""
+ if(navigator.userAgent.indexOf('Linux')!= -1){
+ fpath ="/tmp/"
+ }
+ else if(navigator.userAgent.indexOf('Win')!= -1){
+ fpath ="C:\\"
+ }
+ else if(navigator.userAgent.indexOf('Mac OS X')!= -1){
+ fpath ="/tmp/"
+ }
+
+ name = fpath + getFileName() +".eml"
+
+ var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+ file.initWithPath( name );
+ if ( file.exists() == false ) {
+ return null;
+ } else {
+ var is = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance( Components.interfaces.nsIFileInputStream );
+ is.init( file,0x01, 00004, null);
+ var sis = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance( Components.interfaces.nsIScriptableInputStream );
+ sis.init( is );
+ var output = sis.read( sis.available() );
+ return output
+ }
+}
+function upload_archivemail()
+{
+ list_documents = document.getElementById('listSearchBox')
+ var context = []
+ var cnt = list_documents.selectedCount
+ for(i=0;i<=cnt;i++)
+ {
+ var object = list_documents.getSelectedItem(i)
+ var eml_string = parse_eml();
+ var model = object.label;
+ var res_id = object.value;
+ var branchobj = getPref();
+ setServerService('xmlrpc/object');
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
+ var xmlRpcClient = getXmlRpc();
+ var strDbName = xmlRpcClient.createType(xmlRpcClient.STRING,{});
+ strDbName.data = branchobj.getCharPref("serverdbname");
+ var struids = xmlRpcClient.createType(xmlRpcClient.INT,{});
+ struids.data = branchobj.getIntPref('userid');
+ var strpass = xmlRpcClient.createType(xmlRpcClient.STRING,{});
+ strpass.data = branchobj.getCharPref("password");
+ var strmethod = xmlRpcClient.createType(xmlRpcClient.STRING,{});
+ strmethod.data = 'history_message';
+ var strobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
+ strobj.data = 'thunderbird.partner';
+ var resobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
+ var a = ['model', 'res_id','message'];
+ var b = [model, res_id,eml_string];
+ var arrofarr = dictcontact(a,b)
+ xmlRpcClient.asyncCall(listArchiveHandler,null,'execute',[strDbName,struids,strpass,strobj,strmethod,arrofarr],6);
+
+ }
+
+}
+
+function create_archivemail(){
var popup = document.getElementById("section").selectedItem; // a element
if (String(popup) != "null"){
@@ -1398,11 +1461,12 @@ function archivemail(){
var strpass = xmlRpcClient.createType(xmlRpcClient.STRING,{});
strpass.data = branchobj.getCharPref("password");
var strmethod = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- strmethod.data = 'mailcreate';
+ strmethod.data = 'process_email';
var strobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
strobj.data = 'thunderbird.partner';
- var a = ['name','object','date','email_from','email_cc','description','user_id'];
- var b = [getSubject(),object,getReceivedDate(),getSenderEmail(),getCCList(),getMessageBody(),branchobj.getIntPref('userid')];
+ var eml_string = parse_eml()
+ var a = ['model', 'message'];
+ var b = [object, eml_string];
var arrofarr = dictcontact(a,b);
xmlRpcClient.asyncCall(listArchiveHandler,null,'execute',[strDbName,struids,strpass,strobj,strmethod,arrofarr],6);
}
@@ -1532,7 +1596,7 @@ var listAttachHandler = {
}
//function to create a new attachment record
-function createAttachment(popup,res_id){
+function createAttachment(popup, res_id){
var branchobj = getPref();
setServerService('xmlrpc/object');
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
@@ -1993,91 +2057,6 @@ function listSearchDocumentAttachment(){
//function to create a new attachment record
-function createAttachmentEML()
-{
- if(document.getElementById('listSearchBox').selectedItem)
- {
- data_attach = "no"
- if(getPref().getCharPref('attachmentlength')>0 && getAttachment() == "yes"){
- createAttachment(document.getElementById('listSearchBox').selectedItem.label , document.getElementById('listSearchBox').selectedItem.value)
- data_attach = "yes"
- }
- var fpath =""
- if(navigator.userAgent.indexOf('Linux')!= -1){
- fpath ="/tmp/"
- }
- else if(navigator.userAgent.indexOf('Win')!= -1){
- fpath ="C:\\"
- }
- else if(navigator.userAgent.indexOf('Mac OS X')!= -1){
- fpath ="/tmp/"
- }
-
- var encoded_string=""
- name = fpath + getFileName() +".eml"
-
- var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
- file.initWithPath( name );
- if ( file.exists() == false ) {
- return null;
- } else {
- var is = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance( Components.interfaces.nsIFileInputStream );
- is.init( file,0x01, 00004, null);
- var sis = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance( Components.interfaces.nsIScriptableInputStream );
- sis.init( is );
- var output = sis.read( sis.available() );
- encoded_string += encode64(output)+',';
- encoded_string = encoded_string.substring(0,encoded_string.length-1);
- a = ":"
- if (data_attach == "yes")
- {
- alert("Mail Archived Successfully With Attachments");
- window.close();
- }
- else
- {
- alert("Mail Archived Successfully" + a);
- window.close();
- }
-
- }
-
- attach_eml="yes";
- var branchobj = getPref();
- setServerService('xmlrpc/object');
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
- var xmlRpcClient = getXmlRpc();
- var strDbName = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- strDbName.data = branchobj.getCharPref("serverdbname");
- var struids = xmlRpcClient.createType(xmlRpcClient.INT,{});
- struids.data = branchobj.getIntPref('userid');
- var strpass = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- strpass.data = branchobj.getCharPref("password");
- var strmethod = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- strmethod.data = 'create_attachment';
- var strobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- strobj.data = 'thunderbird.partner';
- var resobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- var popup = document.getElementById("section").selectedItem; // a element
- object=popup.value;
- resobj.data = object;
- filename = getFileName()
- if (getFileName().length > 60)
- {
- filename = filename.substring(0,60) ;
-
- }
- filename = filename + ".eml"
- var a = ['name','datas','res_model','description','res_id','datas_fname'];
- var b = [getFileName(),encoded_string,document.getElementById('listSearchBox').selectedItem.label,getSubject()+'\n'+getSenderEmail() ,document.getElementById('listSearchBox').selectedItem.value ,filename];
- var arrofarr = dictcontact(a,b);
- xmlRpcClient.asyncCall(listAttachHandler,null,'execute',[strDbName,struids,strpass,strobj,strmethod,arrofarr],6);
- }
- else
- {
- alert("you must select only one record");
- }
-}
//function to create a new attachment record
@@ -2182,7 +2161,7 @@ function win_close()
function attachmentWidnowOpen(msg)
{
- if(getPref().getCharPref('attachmentlength')>0)
+ /* if(getPref().getCharPref('attachmentlength')>0)
{
if (msg=="create"){
@@ -2221,7 +2200,7 @@ function attachmentWidnowOpen(msg)
}
}
else
- {
+ { */
if (msg=="create")
{
var popup = document.getElementById("section").selectedItem; // a element
@@ -2229,7 +2208,7 @@ function attachmentWidnowOpen(msg)
object=popup.value;
if (object=="" || object == undefined) { alert("select at least one document !")}
else{
- archivemail()
+ create_archivemail()
}
}
else
@@ -2241,11 +2220,11 @@ function attachmentWidnowOpen(msg)
{
if(document.getElementById('listSearchBox').selectedItem)
{
- createAttachmentEML()
+ upload_archivemail()
}
else{
alert("you must select only one record");
}
}
- }
+ //}
}
diff --git a/addons/thunderbird/plugin/openerp_plugin.xpi b/addons/thunderbird/plugin/openerp_plugin.xpi
index 9f2faef2434..1031f6a6f99 100644
Binary files a/addons/thunderbird/plugin/openerp_plugin.xpi and b/addons/thunderbird/plugin/openerp_plugin.xpi differ
diff --git a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin.jar b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin.jar
index aabf5e84a1c..a828062c10a 100644
Binary files a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin.jar and b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin.jar differ
diff --git a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/address.xul b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/address.xul
index 407821ef4db..2d6f0e2dec1 100644
--- a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/address.xul
+++ b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/address.xul
@@ -17,13 +17,14 @@
+
-
+
@@ -107,8 +108,7 @@
-
-
+
diff --git a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/plugin.xul b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/plugin.xul
index b21d6e8e481..137bdca7904 100644
--- a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/plugin.xul
+++ b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/plugin.xul
@@ -34,7 +34,7 @@
Documents
-
+
diff --git a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/tiny_xmlrpc.js b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/tiny_xmlrpc.js
index eca1491224d..535b8417c7b 100755
--- a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/tiny_xmlrpc.js
+++ b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/tiny_xmlrpc.js
@@ -970,7 +970,7 @@ var listSearchContactHandler = {
var t = getMobilenumber();}
if(strlSearchResult=="email" && strlSearchResultValue!=''){
- setSenderEmail(sendername);
+ setSenderEmail(strlSearchResultValue);
var t = getSenderEmail();}
if(strlSearchResult=="res_id"){
@@ -1000,7 +1000,7 @@ var listSearchContactdetailHandler = {
if(strlSearchResult=="email" && strlSearchResultValue=='')
{
alert("Contact is not Available")
- document.getElementById("txtemail").value = sendername;
+ document.getElementById("txtemail").value = strlSearchResultValue;
}
if(strlSearchResult=="partner_name"){
document.getElementById("txtname").value =strlSearchResultValue;}
@@ -1380,7 +1380,70 @@ var listArchiveHandler = {
}
//function to archive the mail content through xmlrpc request
-function archivemail(){
+
+function parse_eml(){
+ var fpath =""
+ if(navigator.userAgent.indexOf('Linux')!= -1){
+ fpath ="/tmp/"
+ }
+ else if(navigator.userAgent.indexOf('Win')!= -1){
+ fpath ="C:\\"
+ }
+ else if(navigator.userAgent.indexOf('Mac OS X')!= -1){
+ fpath ="/tmp/"
+ }
+
+ name = fpath + getFileName() +".eml"
+
+ var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+ file.initWithPath( name );
+ if ( file.exists() == false ) {
+ return null;
+ } else {
+ var is = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance( Components.interfaces.nsIFileInputStream );
+ is.init( file,0x01, 00004, null);
+ var sis = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance( Components.interfaces.nsIScriptableInputStream );
+ sis.init( is );
+ var output = sis.read( sis.available() );
+ return output
+ }
+}
+function upload_archivemail()
+{
+ list_documents = document.getElementById('listSearchBox')
+ var context = []
+ var cnt = list_documents.selectedCount
+ for(i=0;i<=cnt;i++)
+ {
+ var object = list_documents.getSelectedItem(i)
+ var eml_string = parse_eml();
+ var model = object.label;
+ var res_id = object.value;
+ var branchobj = getPref();
+ setServerService('xmlrpc/object');
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
+ var xmlRpcClient = getXmlRpc();
+ var strDbName = xmlRpcClient.createType(xmlRpcClient.STRING,{});
+ strDbName.data = branchobj.getCharPref("serverdbname");
+ var struids = xmlRpcClient.createType(xmlRpcClient.INT,{});
+ struids.data = branchobj.getIntPref('userid');
+ var strpass = xmlRpcClient.createType(xmlRpcClient.STRING,{});
+ strpass.data = branchobj.getCharPref("password");
+ var strmethod = xmlRpcClient.createType(xmlRpcClient.STRING,{});
+ strmethod.data = 'history_message';
+ var strobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
+ strobj.data = 'thunderbird.partner';
+ var resobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
+ var a = ['model', 'res_id','message'];
+ var b = [model, res_id,eml_string];
+ var arrofarr = dictcontact(a,b)
+ xmlRpcClient.asyncCall(listArchiveHandler,null,'execute',[strDbName,struids,strpass,strobj,strmethod,arrofarr],6);
+
+ }
+
+}
+
+function create_archivemail(){
var popup = document.getElementById("section").selectedItem; // a element
if (String(popup) != "null"){
@@ -1398,11 +1461,12 @@ function archivemail(){
var strpass = xmlRpcClient.createType(xmlRpcClient.STRING,{});
strpass.data = branchobj.getCharPref("password");
var strmethod = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- strmethod.data = 'mailcreate';
+ strmethod.data = 'process_email';
var strobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
strobj.data = 'thunderbird.partner';
- var a = ['name','object','date','email_from','email_cc','description','user_id'];
- var b = [getSubject(),object,getReceivedDate(),getSenderEmail(),getCCList(),getMessageBody(),branchobj.getIntPref('userid')];
+ var eml_string = parse_eml()
+ var a = ['model', 'message'];
+ var b = [object, eml_string];
var arrofarr = dictcontact(a,b);
xmlRpcClient.asyncCall(listArchiveHandler,null,'execute',[strDbName,struids,strpass,strobj,strmethod,arrofarr],6);
}
@@ -1532,7 +1596,7 @@ var listAttachHandler = {
}
//function to create a new attachment record
-function createAttachment(popup,res_id){
+function createAttachment(popup, res_id){
var branchobj = getPref();
setServerService('xmlrpc/object');
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
@@ -1993,91 +2057,6 @@ function listSearchDocumentAttachment(){
//function to create a new attachment record
-function createAttachmentEML()
-{
- if(document.getElementById('listSearchBox').selectedItem)
- {
- data_attach = "no"
- if(getPref().getCharPref('attachmentlength')>0 && getAttachment() == "yes"){
- createAttachment(document.getElementById('listSearchBox').selectedItem.label , document.getElementById('listSearchBox').selectedItem.value)
- data_attach = "yes"
- }
- var fpath =""
- if(navigator.userAgent.indexOf('Linux')!= -1){
- fpath ="/tmp/"
- }
- else if(navigator.userAgent.indexOf('Win')!= -1){
- fpath ="C:\\"
- }
- else if(navigator.userAgent.indexOf('Mac OS X')!= -1){
- fpath ="/tmp/"
- }
-
- var encoded_string=""
- name = fpath + getFileName() +".eml"
-
- var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
- file.initWithPath( name );
- if ( file.exists() == false ) {
- return null;
- } else {
- var is = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance( Components.interfaces.nsIFileInputStream );
- is.init( file,0x01, 00004, null);
- var sis = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance( Components.interfaces.nsIScriptableInputStream );
- sis.init( is );
- var output = sis.read( sis.available() );
- encoded_string += encode64(output)+',';
- encoded_string = encoded_string.substring(0,encoded_string.length-1);
- a = ":"
- if (data_attach == "yes")
- {
- alert("Mail Archived Successfully With Attachments");
- window.close();
- }
- else
- {
- alert("Mail Archived Successfully" + a);
- window.close();
- }
-
- }
-
- attach_eml="yes";
- var branchobj = getPref();
- setServerService('xmlrpc/object');
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
- var xmlRpcClient = getXmlRpc();
- var strDbName = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- strDbName.data = branchobj.getCharPref("serverdbname");
- var struids = xmlRpcClient.createType(xmlRpcClient.INT,{});
- struids.data = branchobj.getIntPref('userid');
- var strpass = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- strpass.data = branchobj.getCharPref("password");
- var strmethod = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- strmethod.data = 'create_attachment';
- var strobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- strobj.data = 'thunderbird.partner';
- var resobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
- var popup = document.getElementById("section").selectedItem; // a element
- object=popup.value;
- resobj.data = object;
- filename = getFileName()
- if (getFileName().length > 60)
- {
- filename = filename.substring(0,60) ;
-
- }
- filename = filename + ".eml"
- var a = ['name','datas','res_model','description','res_id','datas_fname'];
- var b = [getFileName(),encoded_string,document.getElementById('listSearchBox').selectedItem.label,getSubject()+'\n'+getSenderEmail() ,document.getElementById('listSearchBox').selectedItem.value ,filename];
- var arrofarr = dictcontact(a,b);
- xmlRpcClient.asyncCall(listAttachHandler,null,'execute',[strDbName,struids,strpass,strobj,strmethod,arrofarr],6);
- }
- else
- {
- alert("you must select only one record");
- }
-}
//function to create a new attachment record
@@ -2182,7 +2161,7 @@ function win_close()
function attachmentWidnowOpen(msg)
{
- if(getPref().getCharPref('attachmentlength')>0)
+ /* if(getPref().getCharPref('attachmentlength')>0)
{
if (msg=="create"){
@@ -2221,7 +2200,7 @@ function attachmentWidnowOpen(msg)
}
}
else
- {
+ { */
if (msg=="create")
{
var popup = document.getElementById("section").selectedItem; // a element
@@ -2229,7 +2208,7 @@ function attachmentWidnowOpen(msg)
object=popup.value;
if (object=="" || object == undefined) { alert("select at least one document !")}
else{
- archivemail()
+ create_archivemail()
}
}
else
@@ -2241,11 +2220,11 @@ function attachmentWidnowOpen(msg)
{
if(document.getElementById('listSearchBox').selectedItem)
{
- createAttachmentEML()
+ upload_archivemail()
}
else{
alert("you must select only one record");
}
}
- }
+ //}
}