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

Error On Change Method

By
Ali Abdelmonem Mustafa Amer
on 11/27/13, 4:46 AM 1,282 views

Hi Guys

I Got Error (TypeError: 'int' object is not iterable)

My Code : (python :) def on_change_emp(self,cr,uid,ids,emp_id,context=None): vs = cr.execute('SELECT wage FROM hr_contract WHERE (id=%s)',(tuple(emp_id))).fetchone() if vs is not None: raise osv.except_osv((vs[0]),('Employee Wage')) else: pass

(XML :) <field name="emp_id" attrs="{'invisible':[('item_emp','!=',True)]}" on_change="on_change_emp(emp_id)"/>

Hello Ali, you also have passed wrong "id" value in query. You are passing employee id in query and matching with contract "id". It will give wrong wage value too.

Ayyappan
on 11/27/13, 5:05 AM
0
Ayyappan
On 11/27/13, 5:03 AM

Use below code to get wage: In PYTHON file:

_columns = {
    'name': fields.many2one('hr.employee', "Employee", required=True),
    'wage_amt': fields.float('Wage', digits=(16,2), required=True, help="Basic Salary of the employee"),
}

def onchange_employee_id(self, cr, uid, ids, employee_id, context=None):
    v = {}
    if employee_id:
        contract_sr = self.pool.get('hr.contract').search(cr, uid, [('employee_id','=',employee_id)], context=context)
        if contract_sr:
                contract_br = self.pool.get('hr.contract').browse(cr, uid, contract_sr, context=context)[0]
                v['wage_amt'] = contract_br.wage

    return {'value': v}

In XML file:

<field name="name" on_change="onchange_employee_id(name)"/>
<field name="wage_amt"/>

Thanks a Lot It's Working My Friend

Ali Abdelmonem Mustafa Amer
on 11/27/13, 6:38 AM
0

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 11/27/13, 5:01 AM

Hello Ali,

I guess problem is in your query.

Try this:

cr.execute('SELECT wage FROM hr_contract WHERE id in %s', (tuple(emp_id),))
cr.fetchone()

Thanks,

Serpent Consulting Services.

thanks for answer my friend but still give me that (TypeError: 'int' object is not iterable )

Ali Abdelmonem Mustafa Amer
on 11/27/13, 5:12 AM

Did you try it after restart the server?

Serpent Consulting Services Pvt. Ltd.
on 11/27/13, 5:32 AM

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

0 follower(s)

Stats

Asked: 11/27/13, 4:46 AM
Seen: 1282 times
Last updated: 3/16/15, 8:10 AM