Hi everyone , i want some help ;
i have 3 fields on a form
i want one field from them should be filled out due to the result of 2 another fields :
this is the field1 , which i want to fill it out due to the result of other fields:
field1 = fields.Selection('on_change_design','description', readonly = False,)
this is the method :
@fields.depends('field1', 'field2','field3')
def on_change_design(self):
if((self.field2 =="W" or self.field2 =="B" or self.field2=="W/B") and self.field3.code != "14" ):
tab1=[]
tab1.append(("-","-"))
tab1.append(("Pos1", "Pos 1A"))
tab1.append(("Pos2", "Pos 2B"))
return tab1
else:
if((self.field2 =="W" or self.field2 =="B" or self.field2=="W/B") and self.field3.code == "14" ):
tab1=[]
tab1.append(("-","-"))
tab1.append(("lw", "slPivot "))
tab1.append(("rw", "rPivot "))
tab1.append(("fw", "mltrans "))
return tab1
else:
tab =[]
tab.append((" "," "))
return tab1
i was coded the field3 , mentionned on the method like this
field3 = fields.Many2One('module_name.classA', 'process')
the class ‘module_name.classA’ was coded like this :
class design_position(ModelSQL, ModelView):
__name__ = 'module_name.classA'
code = fields.Char('Code', translate=True,
required=True)
name = fields.Char('Name', translate=True,
required=True)
def get_rec_name(self, code):
return self.code
My problem is the result was shown on the field1 don’t take on consideration the result of
"self.field3.code
" which it can be 14 or =!14
, the result shown on the field1 took just the first condition if((self.field2 =="W" or self.field2 =="B" or self.field2=="W/B")
and always the result shown was the instructions of the first condition .
any help will be appreciated , thanks .