python - Change a field value within an If statement in Odoo 8 -


i have been using odoo 8 ubuntu 14.04. have onchange function , under if statement in trying change field value not change . need assign null value or 0.0 field failed. python code below:

def _proposed_total(self):     print self.emp_propose_allowance     self.emp_propose_total = self.emp_propose_basic + self.emp_propose_allowance     cr=self._cr     uid=self._uid     ids=self._ids      val=int(self.employee_name)     if(val):        cr.execute("select max_salary,min_salary hr_job id in (select job_id hr_employee id='"+str(val)+"')")        res=cr.fetchall()        data in res:                max_sal=data[0]                min_sal=data[1]            if(self.emp_propose_total>max_sal):                raise osv.except_osv('out of range','proposed total must in between "'+str(max_sal)+'" "'+str(min_sal)+'"')                           self.emp_propose_basic=0.0               self.emp_propose_allowance=0.0             elif(self.emp_propose_total<min_sal):               raise osv.except_osv('out of range','proposed total must in between "'+str(max_sal)+'" "'+str(min_sal)+'"')               self.emp_propose_basic=0               self.emp_propose_allowance=0           else:            cr.execute("select wage hr_contract employee_id=0")  

i want change self.emp_propose_basic , self.emp_propose_allowance . not sure doing wrong here. plz guide me or point me mistake achieve this

if raise exception previous statements uncommit rolled back. value not set fields if raise method.

choose either raise or set default value there, should return warning if want, not break execution.

for returning warning check onchange method of price list in sale order.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -