Skip to Content
Menu
This question has been flagged

I have a customized model that inherits from hr.applicant and hr.employee. I was already able to customize the web form to automatically fill up my applicant form. What I need is once I "create and employee" from this applicant the data will automatically copy/sync to employee form?

Is this on_change or inherit. Its only one way as once data is copied from applicant to employee I don't need to update applicant information anymore even when changed directly from employee files.

This is my inherit class for recruitment:

class hrRecruitment(models.Model):
    _inherit = 'hr.applicant'
    
    #gender = fields.Char(string = 'Gender')
    gender = fields.Selection(selection= [('male', 'MALE'),
                                          ('female', 'FEMALE')],
                                  string = 'Gender', default = 'male')
    birthdate = fields.Date('Birthdate')
    birthplace = fields.Char(string='Birthplace')
    height = fields.Char(string='Height', size = 5)
    weight = fields.Char(string='Weight', size = 3)
    religion = fields.Char(string='Religion')
    civil_status = fields.Selection(selection=[('married', 'Married'),
                                               ('single','Single')],
                                        string='Civil Status', default= 'single')

This is the xml for inherit recruitment:

	<!-- inherit hr.applicant -->
        <record id="hr_applicant_data_inherit" model="ir.ui.view">
            <field name="name">hr.applicant.data.inherit</field>
            <field name="model">hr.applicant</field>
            <field name="inherit_id" ref="hr_recruitment.crm_case_form_view_job" />
            <field name="arch" type="xml">
                <field name ="partner_mobile" position="after">
                	<field name ="gender" />
                	<field name ="birthdate" />
                	<field name ="birthplace" />
                	<field name ="height" />
                	<field name ="weight" />
                	<field name ="religion" />
                	<field name ="civil_status" />
                	<field name ="father_name" />
                	<field name ="mother_name" />	
                	<field name ="dependents" />
                	<field name ="facebook" />
                	<field name ="complete_address" />
                	<field name ="other_number" />
                	<field name ="other_email" />
                	<field name ="emer_contact_name" />
                	<field name ="emer_contact_number" />
                </field>

This works fine for recruitment to applicant.

Now I need to get this filled up data to the employee form on creation of an employee.

I tried below code:

<!-- inherit data to hr.employee from hr.applicant -->
        <record id="hr_applicant_data_inherit" model="ir.ui.view">
            <field name="name">hr.applicant.data.inherit</field>
            <field name="model">hr.applicant</field>
            <field name="inherit_id" ref="hr_contract.hr_hr_employee_view_form2" /> This is from the hr.employee view
            <field name="arch" type="xml">
                <field name ="partner_mobile" position="after">
                	<field name ="gender" />
                	<field name ="birthdate" />
                	<field name ="birthplace" />
                	<field name ="height" />
                	<field name ="weight" />
                	<field name ="religion" />
                	<field name ="civil_status" />
                	<field name ="father_name" />
                	<field name ="mother_name" />	
                	<field name ="dependents" />
                	<field name ="facebook" />
                	<field name ="complete_address" />
                	<field name ="other_number" />
                	<field name ="other_email" />
                	<field name ="emer_contact_name" />
                	<field name ="emer_contact_number" />
                </field>

Am using Odoo 8 and the error I get is address_id not found, but there is no address_id field anywhere that I can see.

Anyway, I think i am applying it wrong.  Need help to push in right direction Tks.











Avatar
Discard
Related Posts Replies Views Activity
0
Jul 18
3506
0
Oct 17
5514
7
Nov 20
23124
11
Jan 19
8473
1
Jun 24
212