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

Why fields doesn't save auto retrieved data?

By
Carlos Llamacho
on 7/3/13, 12:57 PM 785 views

Hello,

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,
                        'origin_department_id':employee.department_id.id,
                        'origin_company_id':employee.company_id.id,
                        'origin_state_id':employee.company_id.partner_id.state_id.id}}
        else:
            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,
                        'actual_identifiaction_id':emp.identification_id,
                        'actual_dependency':emp.department_id.id,
                        'actual_ocupation':emp.job_id.id,
                        'actual_salary_scale_category':emp.salary_scale_category,
                        'actual_salary_scale_level':emp.salary_scale_level,
                        'actual_orderly_turn':emp.orderly_turn,
                        'actual_wage':emp_cont.wage
                        }}

View:

<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>
                            <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"/>

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

1 follower(s)

Stats

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