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

I really don't know how to search on google for this question. Is it possible to use fields from relation fields in the attrs "domains"?

I'm getting only  Uncaught Error: Unknown field error.

I want to hide a group until a certain value is selected from a Many2One selection.

<group colspan="4" attrs="{'invisible': [('analysis_document_types_id.value', 'not in', ['xxx', 'yyy'])]}">
	<group string="Contacts Projects" colspan="2">
		<field name="project_ids" widget="many2many_checkboxes" nolabel="1"/>
	</group>
</group>
อวตาร
ละทิ้ง

what you want is : If your M2O field is empty, then Hide your field field_1 for ex. Right ?

Then what you need to do is :

<group colspan="4" attrs="{'invisible': [('M2O_field', '=', False)]}">....</group>

And if you want to hide it when your M2o field equals a specific value.

Then do this :

<group colspan="4"

attrs="{'invisible': [('M2O_field','in',[%(Module.record_Xml_id)d, %(Module.record_Xml_id)d])]}">....</group>

ผู้เขียน

Hi Ibrahim, your probably works but I don't have time figuring it out and you didn't explain your attrs. So I rather tried Zbiks workaround with a related field.

คำตอบที่ดีที่สุด

You use the related type field, like this:

my_value = fields.Char(string="My related value", related='analysis_document_types_id.value')

and

attrs="{'invisible': [('my_value', 'not in', ['xxx', 'yyy'])]}"

 
อวตาร
ละทิ้ง
ผู้เขียน

Thanks your workaround works!

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 21
6830
1
พ.ย. 24
1693
1
ก.ย. 21
9481
1
ม.ค. 24
17075
1
มี.ค. 24
30745