This question has been flagged
3 Replies
15355 Views

As a newbe I'm trying to import records from our 3rd party system into Odoo. We use our IDs as our main reference for records for example a customer within the company woukd be refered to as file number (1245) as well as by name, the same applys to a product e.g. id (20152) rather than its code or description. I note Odoo offers the facility to 'map' external ids using ir.model.data during the csv import which I understand and have done successfully. However we would need to show these external IDs when displaying the customer / product records whilst maintaining the ir.model.data mapping so we can update records in future.

The question is what would be the best method of achieving the above: 

1) To write a custom module to get the value via ir.model.data and expose it to the form (assuming there is not a simpler method of retrieving the external ID and displaying it) ?

2) To create a custom field and populate this with the external ID (effectively duplicating the data) and add it to the form. This seems simpler but somehow not the cleanest?

 

Avatar
Discard

Why don't you use the Reference (ref) field of a partner and Internal Reference field (default_code) of a product and supply the same External ID there? Those fields are already part of every partner and product record and are already shown on the relevant form views.

Best Answer

You should enter debug mode, go to a form view of the record you want to know the external id, and choose "view metadata". Then under XML ID you will find it

Avatar
Discard
Best Answer

To get External IDs, you can use this method get_external_id ( cr , uid , ids , *args , **kwargs ) or get_external_id () (in Odoo 8/9).

To display it, you may need to create a computed field:

ext_id = fields.Char(compute='get_external_id')

(this is an example for Odoo 8)

Avatar
Discard