openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #06917
[Merge] lp:~openerp-dev/openobject-addons/6.0-opw-5774-rgo into lp:openobject-addons/6.0
Ravi Gohil (Open ERP) has proposed merging lp:~openerp-dev/openobject-addons/6.0-opw-5774-rgo into lp:openobject-addons/6.0.
Requested reviews:
Jay Vora (OpenERP) (jvo-openerp)
Anup(OpenERP) (ach-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-5774-rgo/+merge/61378
Hello,
When you fetch mails with attachments,the attachments were being duplicated.
This fixes the issue.
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-5774-rgo/+merge/61378
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/6.0-opw-5774-rgo.
=== modified file 'crm/crm_lead.py'
--- crm/crm_lead.py 2011-01-17 13:57:06 +0000
+++ crm/crm_lead.py 2011-05-18 11:11:10 +0000
@@ -347,6 +347,7 @@
res = self.create(cr, uid, vals, context)
attachents = msg.get('attachments', [])
+ att_ids = []
for attactment in attachents or []:
data_attach = {
'name': attactment,
@@ -356,9 +357,9 @@
'res_model': self._name,
'res_id': res,
}
- self.pool.get('ir.attachment').create(cr, uid, data_attach)
+ att_ids.append(self.pool.get('ir.attachment').create(cr, uid, data_attach))
- return res
+ return res,att_ids
def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context=None):
"""
=== modified file 'crm_claim/crm_claim.py'
--- crm_claim/crm_claim.py 2011-02-15 09:42:10 +0000
+++ crm_claim/crm_claim.py 2011-05-18 11:11:10 +0000
@@ -186,6 +186,7 @@
res = self.create(cr, uid, vals, context)
attachents = msg.get('attachments', [])
+ att_ids = []
for attactment in attachents or []:
data_attach = {
'name': attactment,
@@ -195,9 +196,9 @@
'res_model': self._name,
'res_id': res,
}
- self.pool.get('ir.attachment').create(cr, uid, data_attach)
+ att_ids.append(self.pool.get('ir.attachment').create(cr, uid, data_attach))
- return res
+ return res,att_ids
def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context=None):
"""
=== modified file 'crm_helpdesk/crm_helpdesk.py'
--- crm_helpdesk/crm_helpdesk.py 2011-02-15 09:42:10 +0000
+++ crm_helpdesk/crm_helpdesk.py 2011-05-18 11:11:10 +0000
@@ -125,6 +125,7 @@
res = self.create(cr, uid, vals, context)
attachents = msg.get('attachments', [])
+ att_ids = []
for attactment in attachents or []:
data_attach = {
'name': attactment,
@@ -134,9 +135,9 @@
'res_model': self._name,
'res_id': res,
}
- self.pool.get('ir.attachment').create(cr, uid, data_attach)
+ att_ids.append(self.pool.get('ir.attachment').create(cr, uid, data_attach))
- return res
+ return res,att_ids
def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context=None):
"""
=== modified file 'hr_recruitment/hr_recruitment.py'
--- hr_recruitment/hr_recruitment.py 2011-01-17 11:20:56 +0000
+++ hr_recruitment/hr_recruitment.py 2011-05-18 11:11:10 +0000
@@ -319,7 +319,7 @@
if res:
vals.update(res)
res = self.create(cr, uid, vals, context=context)
-
+ att_ids = []
attachents = msg.get('attachments', [])
for attactment in attachents or []:
data_attach = {
@@ -330,9 +330,9 @@
'res_model': self._name,
'res_id': res,
}
- attach_obj.create(cr, uid, data_attach, context=context)
+ att_ids.append(attach_obj.create(cr, uid, data_attach, context=context))
- return res
+ return res,att_ids
def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context=None):
"""
=== modified file 'mail_gateway/mail_gateway.py'
--- mail_gateway/mail_gateway.py 2011-03-28 14:51:27 +0000
+++ mail_gateway/mail_gateway.py 2011-05-18 11:11:10 +0000
@@ -127,9 +127,12 @@
for case in cases:
attachments = []
- for att in attach:
- attachments.append(att_obj.create(cr, uid, {'res_model':case._name,'res_id':case.id,'name': att[0], 'datas': base64.encodestring(att[1])}))
-
+ if attach:
+ for att in attach:
+ if isinstance(att,(int,long)):
+ attachments.append(att)
+ elif isinstance(att,dict):
+ attachments.append(att_obj.create(cr, uid, {'res_model':case._name,'res_id':case.id,'name': att[0], 'datas': base64.encodestring(att[1])}))
partner_id = hasattr(case, 'partner_id') and (case.partner_id and case.partner_id.id or False) or False
if not partner_id and case._name == 'res.partner':
partner_id = case.id
@@ -220,7 +223,7 @@
action_data = False
action_pool = self.pool.get('ir.actions.act_window')
message_pool = self.browse(cr ,uid, ids, context=context)[0]
- att_ids = [x.id for x in message_pool.attachment_ids]
+ att_ids = [x.id for x in message_pool.attachment_ids]
action_ids = action_pool.search(cr, uid, [('res_model', '=', 'ir.attachment')])
if action_ids:
action_data = action_pool.read(cr, uid, action_ids[0], context=context)
@@ -356,8 +359,8 @@
@param msg: email.message.Message to forward
@param email_error: Default Email address in case of any Problem
"""
+
model_pool = self.pool.get(model)
-
for res in model_pool.browse(cr, uid, res_ids, context=context):
message_followers = model_pool.message_followers(cr, uid, [res.id])[res.id]
message_followers_emails = self.to_email(','.join(filter(None, message_followers)))
@@ -410,7 +413,7 @@
def create_record(msg):
att_ids = []
if hasattr(model_pool, 'message_new'):
- res_id = model_pool.message_new(cr, uid, msg, context=context)
+ res_id,att_ids = model_pool.message_new(cr, uid, msg, context=context)
if custom_values:
model_pool.write(cr, uid, [res_id], custom_values, context=context)
else:
@@ -436,7 +439,6 @@
'res_id': res_id,
}
att_ids.append(self.pool.get('ir.attachment').create(cr, uid, data_attach))
-
return res_id, att_ids
# Warning: message_from_string doesn't always work correctly on unicode,
@@ -574,7 +576,7 @@
email_cc = msg.get('cc'),
message_id = msg.get('message-id'),
references = msg.get('references', False) or msg.get('in-reply-to', False),
- attach = attachments.items(),
+ attach = attachment_ids or attachments.items(),
email_date = msg.get('date'),
context = context)
else:
=== modified file 'project_issue/project_issue.py'
--- project_issue/project_issue.py 2011-01-17 13:12:57 +0000
+++ project_issue/project_issue.py 2011-05-18 11:11:10 +0000
@@ -397,6 +397,7 @@
self.convert_to_bug(cr, uid, [res], context=context)
attachents = msg.get('attachments', [])
+ att_ids = []
for attactment in attachents or []:
data_attach = {
'name': attactment,
@@ -406,9 +407,9 @@
'res_model': self._name,
'res_id': res,
}
- self.pool.get('ir.attachment').create(cr, uid, data_attach)
+ att_ids.append(self.pool.get('ir.attachment').create(cr, uid, data_attach))
- return res
+ return res, att_ids
def message_update(self, cr, uid, ids, vals=None, msg="", default_act='pending', context=None):
"""
=== 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-05-18 11:11:10 +0000
@@ -55,6 +55,7 @@
res = self.create(cr, uid, data)
attachments = msg.get('attachments', [])
+ att_ids = []
for attachment in attachments or []:
data_attach = {
'name': attachment,
@@ -64,9 +65,9 @@
'res_model': self._name,
'res_id': res,
}
- self.pool.get('ir.attachment').create(cr, uid, data_attach)
+ att_ids.append(self.pool.get('ir.attachment').create(cr, uid, data_attach))
- return res
+ return res,att_ids
def message_update(self, cr, uid, id, msg, data={}, default_act='pending'):
mailgate_obj = self.pool.get('email.server.tools')
@@ -94,16 +95,15 @@
return True
def message_followers(self, cr, uid, ids, context=None):
- res = []
+ res = {}
if isinstance(ids, (str, int, long)):
select = [ids]
else:
select = ids
for task in self.browse(cr, uid, select, context=context):
user_email = (task.user_id and task.user_id.address_id and task.user_id.address_id.email) or False
- res += [(user_email, False, False, task.priority)]
- if isinstance(ids, (str, int, long)):
- return len(res) and res[0] or False
+ l = [user_email]
+ res[task.id] = l
return res
def msg_send(self, cr, uid, id, *args, **argv):
Follow ups