how can we create attachments in odoo through API call .i need to fetch chat history from an mobile application to odoo which may contain attachments(image/Pdf).need to create these as attachments in Odoo as well.how can we do that
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hello Genelia,
Please find Code in Comment.
Hope this answer helps you.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
You can create attachment in odoo from any API by following steps :
- store binary content from the API response in a seperate variable and then create dictionary as shown below:
attachment_vals = {
'name': 'attachment_name.pdf',
'type': 'binary',
'raw': document_content, // binary content
'res_model': record._name,
'res_id': record.id
}
self.env['ir.attachment'].create(attachment_vals)
it will create an attachment and will be visible under the record in "Attachment Section".
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up