Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
17264 Widoki

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?

 

Awatar
Odrzuć

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.

Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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)

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
lip 17
4773
3
lip 24
8711
1
cze 23
1869
1
gru 15
5654
0
maj 15
3942