跳至内容
菜单
此问题已终结
1 回复
4027 查看

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.

形象
丢弃
最佳答案

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)"/>
形象
丢弃
相关帖文 回复 查看 活动
1
8月 25
3624
1
10月 24
3010
2
7月 24
2201
1
9月 23
2163
0
5月 23
2391