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

I just can't find a working external id for the model hr_employee. When I look at the meta data in debug it says "XML ID: /". In the database ir.model.data I have:

id: 4633

module: hr

model: hr.employee

I've tried the id 4633, hr.hr_employee, hr_employee, hr.hr.employee, hr.employee, ... nothing works.

All the time I get the error: "External ID not found in the system"

My rule looks like

<data noupdate="1">
	<record id="hr_izracun_place.current_company_employee_access_rule" model="ir.rule">
		<field name="name">Show employees by company</field>
		<field name="model_id" ref="hr.hr_employee"/>
		<field name="domain_force">
			[('address_id', 'in' [user.company_id.id])]
		</field>
	</record>
</data>

I really don't know how to get this working and why it's not working? 

 


อวตาร
ละทิ้ง

why don't you just check in Odoo how they defined it. here is an example

<field name="model_id" ref="model_account_move"/> for model account.move

if using outside the module in which the model is defined, then you will have to define like module_name.model_model_name

ผู้เขียน คำตอบที่ดีที่สุด

2 hours of googling and nothing, but after posting the question I find the answer in next try. One can see the external identifier in debug mode under Settings -> Technical -> ... -> External Identifiers

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

As far as I can tell, the model ID is auto-generated based on module and model.

For example: the model my.object in the module my_module

When searching for it:

self.env['my.object']

When referencing it in XML:

<field name="model_id" ref="my_module.model_my_object">

Notice that the . (dot) character is replaced by _ (underscore) in the model reference.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 20
6015
4
ธ.ค. 19
4147
2
มิ.ย. 21
6606
2
ก.ค. 25
4491
2
ธ.ค. 24
7670