Skip to Content
Menu
This question has been flagged
2 Replies
3058 Views

Hello,


I manage to create customers and invoices and link them through the API. But I have a problem when trying to import invoices from the ODOO interface.

The error is that the external id corresponding to the partner_id / id I provide does not match any records.

What should I do so that the clients created through the API are found in this list? and is it possible to configure this id when creating the client via the API?


Thank you

Avatar
Discard

If the partner is already registered, then fetch the related partner and assign in invoice. Both creation and fetching partners are possible with ODOO web services/API

Best Answer

If you are creating a Customer / Vendor using something like this:

new_customer_vals = {
'name': customer_name,
'company_type': 'company',
...
}
new_partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', new_customer_vals)

Then you can create the External ID immediately after you create the Partner record using something like this:

new_external_id_vals = {
'model': 'res.partner',
'module': 'api_generated',
'name': unique_customer_ref,
'res_id': new_partner_id,
}
it_worked = sock.execute(dbname, uid, pwd, 'ir.model.data', 'create', new_external_id_vals)
Avatar
Discard
Best Answer

When you create invoices using a partner external_id that external_id needs to be created.

When you import something you can provide Odoo with and external_id or Odoo can generate it for you. External ID is a reference that you and Odoo agree to used to reference an object. Odoo external id's used for import are ephemeral but they allow you to name your imported partner so that you refer them next time you import. Other option is to use the Database ID which is the existing id of the partner on the Odoo database (once created never changes).

Avatar
Discard
Related Posts Replies Views Activity
2
Jul 19
3017
0
May 19
3066
1
Apr 19
2025
1
Jun 17
2478
1
Mar 15
5367