Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
7 Odpovědi
3908 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

No you can return mutiple fields in side the value dict

Avatar
Zrušit
Nejlepší odpověď

 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
Zrušit
Autor Nejlepší odpověď

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

Avatar
Zrušit

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

Autor

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?

Related Posts Odpovědi Zobrazení Aktivita
1
říj 23
2092
2
říj 23
2338
2
srp 23
4362
4
srp 23
20700
3
říj 22
11150