Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4840 Vizualizări

i have custom class like this ,

.py

#for parent class

class wtc_proses_birojasa(osv.osv):
    _name = "wtc.proses.birojasa"

    _columns = {
       ================================================
        'type' : fields.selection([('reg', 'REG'), ('adv','ADV')], 'Type'),

        'proses_birojasa_line': fields.one2many('wtc.proses.birojasa.line','proses_birojasa_id',string="Table Biro Jasa"), 

       =================================================
        
    }

# for one2many

class wtc_proses_birojasa_line(osv.osv):
    _name = "wtc.proses.birojasa.line"

    _columns = {

               =============================
                'no_notice' : fields.char('No Notice'),

              ==============================
                }

===================================================================================================

i want to make 'no_notice' required when user choose 'REG' in 'type' selection, i already use this xml code but it didn't work

<field name="no_notice" attrs="{'required': [('parent.type','=','reg')]}"/>    

 

anyone know how to solve it ?

sorry for my bad english , thanks in advance

Imagine profil
Abandonează
Cel mai bun răspuns

Make type to be a related field in the wtc.proses.birojasa.line model, include it in the view, and set the attrs based on this related field.

Imagine profil
Abandonează
Autor

@ivan , so i have 2 make another 'type' fields related to parent line like this ? 'type' : fields.related('proses_birojasa_id','type',type='selection',string='Type') ?

Yes, don't forget to put in the selection= parameter in the definition.

Autor

@Ivan , i use this code 'type' : fields.related('proses_birojasa_id','type',type='selection',selection=[('reg', 'REG'),('adv', 'ADV')],string='Type', store=True) but it didn't work .. is there anything wrong ?

You need to be more elaborate on what you mean by didn't work, e.g. does it still be not required if wtc.proses.birojasa's type is 'reg'? At which point? Now, have you included the field in the view? Have you updated the attrs for no_notice field? Could you post the complete view in which you put the no_notice attrs in so that it can be examined more closely?