2017-07-25 93 views
2

我在窗體上創建了兩個按鈕,當我點擊Fenced按鈕時,如果說明,分析和結論不是空的,所以狀態值應該是Fenced,否則什麼都不應該發生,當我點擊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>      

,這裏是兩個按鈕的功能:

@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"

回答

2

在odoo不要用這個空場:

self.Description != "" 

空場或空在odoo都是假的:

self.Description != False 
相關問題