Odoo Help

0

how to restrict field value on change event?

By
mihir shah
on 7/9/13, 9:28 AM 1,056 views

on changes department_id i want corresponding semester_id this is the function which i am applying. But the return value is all the semester i want only those semester which related to department.

 def on_change_dep(self, cr, uid, ids,dep_id, context=None):
      vals = {}


      if dep_id:
         sem = self.pool.get('dep.semister').search(cr,uid,[('dep_id','=',dep_id)],context=None)


  if sem:   
     for dep_sem_id in sem: 
         val=self.pool.get('dep.semister').browse(cr,uid,dep_sem_id)
         if val:

            vals.update({'semester_id':val.sem_id.id}) 
         return {'value':vals}
  return True

Using on change function with return type domain and value http://help.openerp.com/question/13900/how-to-return-a-domain-on-field-on-onchange-action/

Prakash
on 7/9/13, 10:13 AM

hi prakash , using domain and value solution is not possible because semester_id and its corresponding department_id is stored in different model,where as if i use domain context then semester_id will find value from semester model where corresponding department is not stored .so if you have other solution please help me

mihir shah
on 7/9/13, 11:52 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 7/9/13, 9:28 AM
Seen: 1056 times
Last updated: 3/16/15, 8:10 AM