Skip to Content
Menu
This question has been flagged
2 Replies
3931 Zobrazenia

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
Zrušiť

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
Zrušiť
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
Zrušiť
Related Posts Replies Zobrazenia Aktivita
2
júl 19
4212
0
máj 19
4259
1
apr 19
2025
1
jún 17
3719
1
mar 15
6284