跳至內容
選單
此問題已被標幟
7 回覆
3933 瀏覽次數

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),
                
                }

 

 

頭像
捨棄
最佳答案

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}

頭像
捨棄
最佳答案

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}

頭像
捨棄
最佳答案

No you can return mutiple fields in side the value dict

頭像
捨棄
最佳答案

 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}

頭像
捨棄
作者 最佳答案

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

頭像
捨棄

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

作者

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?

相關帖文 回覆 瀏覽次數 活動
1
10月 23
2109
2
10月 23
2357
2
8月 23
4392
4
8月 23
20741
3
10月 22
11167