Note that there are some explanatory texts on larger screens.

plurals
  1. POdomain restriction and clear the previously selected value of a many2one field
    text
    copied!<p>I have two many2one fields (list1 and list2) in the same class and view. I want when a user select a value from list1, the list2 to automatically update with a restriction domain value. this is done</p> <p>But I also want the 'previously' selected value of list2 to be drop so that the user is force to reselect it, in the case he has previously selected a value in list2 and then reselect in list1. Because domain restriction only update the list2 but leave the previously (now not pertinant) value of list2 and the user can pass. Thx to any help!</p> <p>this is my code where cours_id is the field name corresponding to list2 in veiw and salle_de_classe_id is the one corresponding to list1:</p> <pre><code> def on_change_salle_de_classe_id(self,cr,uid,ids,salle_de_classe_id,context=None): salle_de_classe = self.pool.get('schoolem.salle_de_classe').browse(cr,uid,salle_de_classe_id) cours_obj = self.pool.get('schoolem.cours') ids1 = cours_obj.search(cr, uid, [('niveau_id.id', '=', salle_de_classe.classe_id.niveau_id.id)]) ids2 = cours_obj.search(cr, uid, [('niveau_id.id', '=', salle_de_classe.classe_id.niveau_id.id),('specialite_id.id', '=', salle_de_classe.classe_id.specialite_id.id)]) #return {'domain':{'cours_id':[('id','in',ids1+ids2)]}} return {'domain':{'cours_id':[('id','in',ids1+ids2)]},'value':{'cours_id':False}} </code></pre> <p>This code clear the list2(cours_id field) but i got this error</p> <p>ProgrammingError: ERREUR: l'opérateur n'existe pas : integer = boolean LINE 1: ....id FROM "schoolem_cours" WHERE schoolem_cours.id IN (false)... ^ HINT: Aucun opérateur ne correspond au nom donné et aux types d'arguments. Vous devez ajouter des conversions explicites de type.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload