Hello everyone,
I'm trying to send messages with attachments in mailbox using xmlrpc (ir.attachment and mail.channel).
With admin account as sender, I can see my attachments without any problem. But as receiver in the same chat conversation, the images are not shown (I see just camera icon) and pdf files have the following error: PDF.js Version 2.2.228 (build: d7afb74a)
Message: Missing PDF "http://10.20.168.7:8069/web/content/884".
Here is a part of my script:
with open(attachment_filepath ,'rb') as raw_data:
attachment1 = base64.b64encode(raw_data.read())
attachment = attachment1.decode('ascii')
file_type = re.search('\.(.*)',entry_name)
filetype = file_type.group()
name = 'attachment' + filetype
if filetype == '.pdf':
mimetype = 'application/pdf'
elif filetype == '.jpg' or filetype == '.jpeg' :
mimetype = 'image/jpeg'
elif filetype == '.png':
mimetype = 'image/png'
else:
mimetype = 'text/plain'
if has_attachment is True:
attach_args = [{
'name' : name,
'datas' : attachment,
'store_fname' :attachment,
'mimetype' : mimetype,
'type': 'binary',
}]
attachment_exe = models.execute_kw(db, uid, API_KEY, 'ir.attachment', 'create', attach_args)
attachment_ids = [attachment_exe]
else:
attachment_ids = []
args = [{
'author_id': 3,
'email_from': 'administrator',
'create_uid': [2, 'administrator'],
'subject': subject,
'body': body,
'attachment_ids' : attachment_ids,
'message_type' : 'email',
'model' : 'mail.channel',
'starred': True,
'reply_to': 'administrator',
'partner_ids': partner_ids,
'reaction_ids' : [3],
'is_internal' : True,
'reply_to_force_new': True,
'mail_server_id': 1,
'parent_id' : False,
'res_id' : res_id,
}]
message = models.execute_kw(db, uid, API_KEY, 'mail.message', 'create', args)
Is it something related to access right? Does anybody have an idea?
Thank you in advance
Maryam