How to get/add attachment of sale & product in JSON


(Piyush Agrawal) #1

We are unable to get/add attachment of sale & product.
Can I know the API request/method for it?

I am tryting to make json api request.

Thank you,


(Sergi Almacellas Abellana) #2

All the attachments are stored on the _ir.attachmen_t model. The resource field is used as reference to the related method. So for getting all the attachments of a sale you have to perform a search on the ir.attachment model filtering with the records that have ‘sale.sale,1’ for the resorce field (replacing 1 with the id of the sale you want to read.

The same applies for product by using the correct method.


(Piyush Agrawal) #3

Thank you for your answer
but still I am not clear with API request.

Can you give me an example for JSON?


(Sergi Almacellas Abellana) #4

Just use the search_read endpoint to read the data field and using
[(‘resource’, ‘=’, ‘sale.sale,1’)] as domain.


(Piyush Agrawal) #5

ok, thank you for answer!

Also, can you let me know how to add attachment with any record?

Thank you,


(Sergi Almacellas Abellana) #6

You have to create a ir.attachment record with the resource field referencing the record.