Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4013 Lượt xem

I added a function to check work_phone field or 10 charecters but I get the error again and again.

my function in hr_employee class :

def onchange_work_phone(self, cr, uid, ids, work_phone, context=None):
    res = {'value':{}}
    if not work_phone:
        return res
    if len(work_phone) != 10:
        res['value']['work_phone'] = ''
        res['warning'] = {'title':'Error', 'messagge':'Insert 10 chars!'}
    return res

xml field line :

<field name="work_phone" on_change="onchange_work_phone(work_phone,context)"/>

Help me find my mistake here as I am new to openerp.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

try to use this

  <field name="work_phone" on_change="onchange_work_phone(work_phone)"/>

rather than this:

 <field name="work_phone" on_change="onchange_work_phone(work_phone,context)"/>
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 25
3584
1
thg 10 24
2807
2
thg 7 24
2171
1
thg 9 23
2156
0
thg 5 23
2360