0

I'm working on a python application that connects to Odoo through the External API. My goal is to upload multiple documents to the Partner model, business related documents of multiple types, important to the Contact.

The documents should be visible for the Odoo administrator in Contacts/My Contact/Documents/my_file. Another important thing is that i will need to set certain Tags to the documents.

I spent a few hours searching for the xmlrpc call to achieve this, but without any luck. I did see some references for "hr.employee" and image upload, but "res.partner" doesn't have similar calls.

Does anyone have experience with this?

Macaret
  • 797
  • 9
  • 33

2 Answers2

0

AFAIK res.partner does not have an ir.attachment field.

To add documents to res.partner : Add a relational field pointing to ir.attachment

To manage tags to documents : Simply add a Selection field to ir.attachment

To view your documents : Inherit the form view of res.partner and you can add a new notebook to view your attachments.

  • re.partner has "document_count" and it gives the correct number of Documents that are in the Documents screen for each Contact. Where is that number taken from? – Macaret Jan 20 '21 at 14:01
  • I can't find any field with the name document_count, are you sure it is a res.partner field ? – InvertedPawn Jan 20 '21 at 14:54
  • Almost no model has direct relations to `ir.attachment`, it's a indirect relation by `ir.attachment`'s fields res_id and res_model. The chatter extension which can be used for models will show the attachments with a little widget. But that's not needed to create attachments "for a model". And the count fields are usually just searching (counting) with a search domain using res_id and res_model. – CZoellner Jan 20 '21 at 17:11
0

You just need the partner ID for creating attachments.

A very simple example for partner with ID 4711 is:

id = models.execute_kw(db, uid, password, 'ir.attachment', 'create', [{
    'res_id': 4711, 'res_model': 'res.partner', 'name': 'my name',
    # and every other required field for model ir.attachment
}])
CZoellner
  • 13,553
  • 3
  • 25
  • 38