Odoo Help

Welcome!

This community 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.

0

how to restrict field value on change event?

By
mihir shah
on 7/9/13, 9:28 AM 824 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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