Skip to content Skip to sidebar Skip to footer

How To Change Selection Field Automatically In Odoo

I'm working on Odoo 8. I have a view that contains a set of combo-box type fields and a selection field. I want to make a test on the combo-box fields and if there are all checked

Solution 1:

Add an onchange attribute to the casier_judiciare field and then pass all the other fields you want to check as arguments to the method like this

<groupcol='4'name="doss_grp"string="Dossier de Soumission"colspan="4" ><fieldname="casier_judiciare"on_change="onchange_casier_judiciare(casier_judiciare, certificat_qual, extrait_role, reference_pro)"/><fieldname="certificat_qual"/><fieldname="extrait_role"/><fieldname="reference_pro"/><fieldname="statut_entre"style="width:20%%"/><fieldname="etat_dos"/></group>

In your model file define the method like this and use an if statement to check if they're all True (That means they have all been checked), if so then you can return a dictionary with any value you want for the selection field, in this case etat_dos will change to Dossier Complet

defonchange_casier_judiciare(self, cr, uid, ids, casier_judiciare, certificat_qual, extrait_role, reference_pro, context=None):
    if casier_judiciare and certificat_qual and extrait_role and reference_pro: # if they're all True (that means they're all checked):
        values = {'value': {'etat_dos': 'complet'}} #set the value of etat_dos fieldreturn values

Note that the onchange is only triggered on the casier_judiciare field but you can also set onchange on other fields and it should work just fine

Post a Comment for "How To Change Selection Field Automatically In Odoo"