Skip to main content
 首页 » 编程设计

python之Openerp-如何删除图像上的编辑选项

2025年02月15日7soundcode

我有这个相关图像(只读)字段,一旦我单击编辑,该特定图像字段就会在表单 View 中显示编辑选项。请帮我删除它

字段:-

'emp_img':fields.related('employee_id', 'image_medium', type='char', relation='hr.employee', string='', store=True), 

在 xml 中:-

<field name="emp_img" readonly="1" widget='image' class="oe_left oe_avatar" /> 

在表单 View 编辑中显示如下:

请您参考如下方法:

您必须将 effective_readonly 参数传递给管理图像的 image 小部件。

以下应该有效:

<field name="emp_img" readonly="1" widget='image' class="oe_left oe_avatar" attrs="{'effective_readonly': True}" /> 

或者您可以在 Debug模式下将下面的属性添加到您想要的表单上:

attrs="{ &quot;effective_readonly&quot;:True}"/>