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

How To Change Field Value According To Selection Field Openerp?

By
Ali Abdelmonem Mustafa Amer
on 11/27/13, 3:26 AM 2,628 views

Hi Guys I Need To Change Value Of Field According To Selection Field Changed So What The Best Way To Do It

Like (When I Chose The Employee Automatically Get His Wage in Another Field )

Thanks A lot

0
Ayyappan
On 11/27/13, 3:29 AM

Use on_change function.

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 Ayyappan For Answer But Please If You Have Example I W'll Can Understand It

Ali Abdelmonem Mustafa Amer
on 11/27/13, 3:31 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, 3:26 AM
Seen: 2628 times
Last updated: 3/16/15, 8:10 AM