为什么即使不满足条件,国家也会改变?

时间:2017-07-25 11:20:59

标签: openerp odoo-10

我在表单上创建了两个按钮,当我单击Fenced按钮时,如果描述,分析和结论不为空,那么状态值应该是Fenced,否则什么都不应该发生,当我点击Not yet按钮时,如果描述或分析或结论不是空的状态值应该改为进行中。

这里我的两个按钮Fenced and Not yet:



 <group name="group_tests_buttons" class="oe_button_box" col="6">
                        <button name="write_new"
                            type="object"
                            class="oe_stat_button"
                            string="Fenced">  
                        </button>
                       <button name="write_new2"
                            type="object"
                            class="oe_stat_button"
                            string="Not yet">
                        </button>                            
&#13;
&#13;
&#13;

以下是两个按钮的功能:

&#13;
&#13;
    @api.depends('Description','analyse','conclusion')
    def write_new(self):
        if self.Description != "" and self.analyse != "" and self.conclusion != "":
            self.state = "Fenced"   


    @api.depends('Description','analyse','conclusion')
    def write_new2(self): 
        if self.Description != "" or self.analyse != "" or self.conclusion != "":
            self.state = "In progress"   
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

在odoo中不要将它用于空场:

self.Description != ""

空字段或odoo中的null为False:

self.Description != False