Odoo Help


Why fields doesn't save auto retrieved data?

Carlos Llamacho
on 7/3/13, 12:57 PM 1,152 views


I have a form that takes data with a on_change function an show it when i select an employee but i realize that when i hit the save button and check the record i just created all the data that i acquired with the on_change function is gone... why this might be?

I am putting here my on_change function and the view, thanks in advance.

def onchange_petitioner(self, cr, uid, ids, origin_employee_id, context=None):
        hr_obj = self.pool.get('hr.employee')   
        if origin_employee_id:
            employee = hr_obj.browse(cr, uid, origin_employee_id, context=None)
            return {'value':{'origin_address':employee.company_id.partner_id.street,
            return {}

    def onchange_petitionee(self, cr, uid, ids, employee_id, context=None):
        hr_obj = self.pool.get('hr.employee')
        hr_contract_obj = self.pool.get('hr.contract')
        if employee_id:
            emp = hr_obj.browse(cr, uid, employee_id, context=None)
            hr_first_contract = hr_contract_obj.search(cr, uid, [], limit=1, context=None)
            emp_cont = hr_contract_obj.browse(cr, uid, hr_first_contract[0], context=None)
            return {'value':{'actual_employee_code':emp.employee_code,


<group string="Petitioner">
                                <field name="origin_employee_id" on_change="onchange_petitioner(origin_employee_id, context)"/>
                                <field name="origin_department_id" />
                                <field name="origin_company_id" />
                                <field name="origin_address" />
                                <field name="origin_state_id" />
                            <group string="Petitionee">
                                <field name="employee_id" on_change="onchange_petitionee(employee_id, context)"/>
                                <field name="action_requested"/>
                                <field name="effective_date"/>
                                <field name="actual_employee_code"/>
                                <field name="actual_identification_id"/>

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/3/13, 12:57 PM
Seen: 1152 times
Last updated: 3/16/15, 8:10 AM