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

how to remove option create and edit from many2many fields? For example In the sale order line or invoice lines, there is tax ids, which is a many2many field using the widget='many2many_tags', I want to remove the create and edit form here. But need to create taxes from its tree and form view.

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

Hello, you can try this,

<field name='field_name' options="{'no_create_edit': True}" />

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

To disable creation / edition of tags in many2many_tags widget pass options dictionary with either no_create or no_create_edit set.

Example:

<field name='subscribers' options="{'no_create_edit': True}" widget='many2many_tags' />

อวตาร
ละทิ้ง

Someone should accept this answer, as it is the right one now.

thanks! I was trying to use nocreate="1" but it didn't work, your solution works!

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

Please use below code.

<attribute name="options">{'no_create_edit': True, 'no_create':True, 'no_open':True}</attribute>

I hope this help you.

Best Thanks,

Ankit H Gandhi.

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

You can try this in your view. 

options="{'no_open':True,'no_create':1,'no_create_edit':1}" 
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

If you want to do it by view overriding, you can use xpath.

For example:

        <xpath expr="//tree[@string='Your Tree Name']" position="attributes">
            <attribute name="create">0</attribute>
                <attribute name="create">0</attribute>
                <attribute name="delete">0</attribute>
                <attribute name="edit">0</attribute>
        </xpath>
อวตาร
ละทิ้ง
ผู้เขียน

hello by doing as you describe it stop creation from tree view, i want stop creation and edit from population of m2m field.

What widget was used for displaying m2m field in your case?

ผู้เขียน

widget="many2many_tags"

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

options="{'no_create':True}"

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

This worked for me in V7:
options="{'create_edit':False}"

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

hello,

I just update web_m2o_enhanced module to support many2manytags widget.

You can check and use it:

Github repository

For comment and description of how to user, you can read This help question

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

Nicolas,

Thank you very much. I already used yr module for o2m and I just needed it for many2many as well ;-)

Merci!

Wiebe

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.พ. 21
3096
1
ก.ย. 24
3829
1
ก.พ. 24
1952
0
ก.ค. 24
2990
0
ก.ค. 22
60