Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
7 Antwoorden
3906 Weergaven

my code . py. fields ten_nv filled but fields luong_ct did not fill. I don know I have an error.

 def onchange_ma_nv(self, cr, uid, ids, ma_nv, context = None):
         res={}
         if ma_nv:
             ma = self.pool.get('danh.sach.nv').browse(cr, uid , ma_nv, context = context)
             res= {
                   'ten_nv': ma.ten_nv,
                   'luong_ct': ma.luong_ct
                 }
         return {'value':v}

       
        
    _columns = {
                'ma_nv':fields.many2one('danh.sach.nv', 'Mã NV'),
                'ten_nv':fields.char('Tên nhân', size = 40),
                'luong_ct':fields.char( 'Lương chính thức', size =  20),
                'luong_dc':fields.char('Lương điều chỉnh', size = 20),
                'ly_do_dc': fields.char('Lý do điều chỉnh', size = 30),
                
                }

 

 

Avatar
Annuleer
Beste antwoord

What is 'v' here? You have to return 'res' as value for the key 'value'.

def onchange_ma_nv(self, cr, uid, ids, ma_nv, context = None):
         res = {}
         if ma_nv:
             ma = self.pool.get('danh.sach.nv').browse(cr, uid , ma_nv, context = context)
             res= {
                   'ten_nv': ma.ten_nv,
                   'luong_ct': ma.luong_ct
                 }
         return {'value': res}

Avatar
Annuleer
Beste antwoord

def onchange_ma_nv(self, cr, uid, ids, ma_nv, context = None):
         res = {}
         if ma_nv:
             ma = self.pool.get('danh.sach.nv').browse(cr, uid , ma_nv, context = context)
             res= {
                   'ten_nv': ma.ten_nv,
                   'luong_ct': ma.luong_ct
                 }
         return {'value': res}

Avatar
Annuleer
Beste antwoord

No you can return mutiple fields in side the value dict

Avatar
Annuleer
Beste antwoord

 def onchange_ma_nv(self, cr, uid, ids, ma_nv, context = None):
         res={}
         if ma_nv:
             ma = self.pool.get('danh.sach.nv').browse(cr, uid , ma_nv, context = context)
             res= {
                   'ten_nv': ma.ten_nv,
                   'luong_ct': ma.luong_ct
                 }
         return {'value': res}

Avatar
Annuleer
Auteur Beste antwoord

My code run. But I want to aks a question. In onchange function has limit number filed to return ??

Avatar
Annuleer

No limit in return type in onchange function. It return dictionary with no of keys (is the column name) and values.

Auteur

so when I choose 3 fields to view onchange function , I have an error : server overload. I want to aks you a question : How do I do to not have an error : server overload?

Gerelateerde posts Antwoorden Weergaven Activiteit
1
okt. 23
2090
2
okt. 23
2329
2
aug. 23
4349
4
aug. 23
20690
3
okt. 22
11140