Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

fields function onchange .filled fields 1 but not filled fields 2

By
huongcute
on 8/13/14, 5:38 AM 898 views

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

 

 

0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 8/13/14, 5:50 AM

 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}

4

Janeesh

--Janeesh--
1641
| 4 3 4
Cochin, India
--Janeesh--

Odoo Developer

Janeesh
On 8/13/14, 9:32 AM

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}

0
Deviprasad V
On 8/19/14, 5:21 AM

No you can return mutiple fields in side the value dict

0
huongcute
On 8/19/14, 4:31 AM

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.

Prakash
on 8/19/14, 5:01 AM

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?

huongcute
on 8/19/14, 10:48 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/13/14, 5:38 AM
Seen: 898 times
Last updated: 3/16/15, 8:10 AM