![](/img/trans.png)
[英]how to limit access to 'create and edit' in many2one field in odoo
[英]How to remove Create and Edit… from many2one field.?
請建議我如何從 many2one 字段中刪除“創建和編輯...”。? 該項目顯示在我使用域選項過濾的 many2one 字段中。
OpenERP 版本 7
我沒有太多想法。 也許為此您必須在網絡插件中進行更改。
但另一種解決方案是您可以進行many2one字段選擇。 在您的 xml 中添加widget="selection"
屬性。
<field name="Your_many2one_field" widget="selection">
Many2one 小部件(默認)
選項:您可以與此小部件一起使用的其他可能選項。
示例:
<field name="field_name" options="{'no_quick_create': True, 'no_create_edit' : True}"/>
你可以參考Ludwik Trammer 的帖子
它在 openerp v7.0 中進行了測試,我們可以通過下載存在於的模塊來刪除“創建和編輯”,
並添加屬性 'create':false, 'create_edit': false 像這樣
<field name="partner_id" options="{'limit': 10, 'create': false, 'create_edit': false}"/>
這里給出了一個很好的教程https://www.odoo.com/apps/7.0/web_m2x_options/
對於 Odoo 8.0 和 9.0,您應該使用 no_create 和 no_open。
no_create:
設置為 True 以禁用在下拉列表中創建新條目的選項。
no_open:
設置為 True 以禁用下拉列表右側的按鈕,該按鈕彈出一個允許編輯所選實例的窗口。
<field name="field_name" options="{'no_create': True, 'no_open': True}" />
在 xml 文件中輸入:
<field name="my_field_name" options="{'no_create' : True}"/>
我希望這有效!
在 XML 文件中:
請將options="{'no_create': True}" 添加到您的字段中,這將刪除創建按鈕
對於那些不想要“選擇”小部件(它功能較弱,不提供搜索功能)的人來說,這是另一種方法,已在 8 中進行了測試。
<xpath expr="//field[@name='partner_id']" position="attributes">
<attribute name="options">{'no_create': '1', 'no_create_edit': '1'}</attribute>
</xpath>
只需在選項中添加no_open 、 no_create 、 no_create_edit 即可
<field name="partner_id" options='{"no_open": True,"no_create": 1, "no_create_edit": 1}'/>
我試過了,它工作正常。
在你的 XML 文件中
<field name="your_field_name" options="{'no_quick_create':True,'no_create_edit':True,'no_open': True,}"/>
odoo 的解決方案,適用於 many2one 關系字段。
適用於下面列出的官方 odoo 版本,默認功能。
<field name="patient_id" options="{'no_quick_create': true, 'no_create_edit': false}"/>
筆記:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.