Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
21367 มุมมอง

In Odoo 14 I can search a external id of a record with:

self.env.ref('simulator.example')

But I need to get the ID of a model _named simulator.simulator and this code:

self.env.ref('model_simulator_simulator')

returns:

 File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_model.py", line 1873, in xmlid_lookup
module, name = xmlid.split('.', 1)

ValueError: not enough values to unpack (expected 2, got 1)

In theory, am External ID is just a record with a name and a number that reference the real id in the database table. It doesn't seems a problem with the name, because the error for wrong names is 'Externa ID not found...'.

Why it fails searching models, actions and fields and works with records?

Thanks

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Solved.

Odoo can find 'model_simulator_simulator', but for some reason, the model needs a '.' for split, so I have to put the complete name with the module name: 'simulator.model_simulator_simulator'.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มี.ค. 17
6619
0
พ.ค. 15
4155
0
มี.ค. 15
4593
1
ก.ค. 25
2521
2
ก.ค. 25
7972