繁体   English   中英

功能调用中的Odoo隐藏显示按钮

[英]Odoo hide show button on function call

我是odoo和python的新手。 我正在开发一个模块,我需要通过从“ .xml”文件中调用方法来隐藏按钮,函数定义和主体位于“ .py”文件中。 目前正在尝试隐藏这样的按钮

<button confirm="Are you sure you want to start the test?" name="set_to_test_inprogress" states="Invoiced" string="Start Test" type="object" class="oe_highlight"groups="oehealth.group_oeh_medical_physician,oehealth.group_oeh_medical_manager" attrs="{'invisible': [('start_button', '=', False)]}"/>

并且“ start_button”列位于“ .py”文件中,其代码如下

def _start_test_button(self, cr, uid, ids, field_name, arg, context):
    return False

_columns = {
    'start_button': fields.function(_start_test_button, type="boolean", obj="generic.request", method=True),
}

并且该python代码在名为“ OeHealthLabTests”的类中。 创建实验室时,显示错误是

Uncaught Error: Unknown field start_button in domain [["start_button","=",false],["state","not in",["Invoiced"]]]

很困惑,我还没有找到实现它的方法。 请指导我该怎么做。

谢谢

您收到错误消息是因为尚未在xml中定义字段函数。 只需在xml中定义您的字段函数即可。

<button confirm="Are you sure you want to start the test?" name="set_to_test_inprogress" states="Invoiced" string="Start Test" type="object" class="oe_highlight"groups="oehealth.group_oeh_medical_physician,oehealth.group_oeh_medical_manager" attrs="{'invisible': [('start_button', '=', False)]}"/>
<field name="start_button" invisible="1"/>

希望我的回答对您有所帮助:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM