xml - how to autofill data by selecting employee name here? -


i have data auto-fil if select emp name other fields should auto fill.
here have added tree view .py , xml file please me this,
, want 1 more filed attachment particular employee.

from openerp.osv import fields, osv  class hr_employee(osv.osv):     _inherit="hr.employee"     _columns={         'emp_line':fields.one2many('empl.line','emp_id','employee line'),     }  class empl_line(osv.osv):     _name="empl.line"     appointment_selection=[         ('0','regular'),         ('1','aditional'),         ('2','deputation'),         ('3','incharge'),     ]     _columns = {         'name':fields.selection(appointment_selection,'appointment for'),         'surname':fields.char('name'),         'doj':fields.date('date of joining'),         'dor':fields.date('date of relieving'),         'emp_id': fields.many2one('hr.employee', 'employee_id'),     }  empl_line()    <?xml version="1.0" encoding="utf-8"?>  <openerp>     <data>         <record id="hr_view_employee_form1" model="ir.ui.view">             <field name="name">hr.employee.form</field>             <field name="model">hr.employee</field>              <field name="inherit_id" ref="hr.view_employee_form"/>             <field name="arch" type="xml">                   <page string="hr settings" groups="base.group_hr_user" position="after">                       <page string="employee details">                             <field name="emp_line" >                             <form string="employee line">                             <group>                                 <field name="name"/>                                 <field name="surname"/>                                 <field name="doj"/>                                 <field name="dor"/>                              </group>                              </form>                             <tree string="employee line">                                  <field name="name"/>                                 <field name="surname"/>                                 <field name="doj"/>                                 <field name="dor"/>                               </tree>                         </field>                      </page>                  </page>              </field>           </record>          <record model="ir.ui.view" id="hr.view_employee_form2">                 <field name="name">hr.employee.form</field>                 <field name="model">hr.employee</field>                 <field name="inherit_id" ref="hr.view_employee_form" />                 <field name="arch" type="xml">                         <page string="personal information" groups="base.group_hr_user" >                             <attribute name='invisible'>1</attribute>                          </page>                 </field>             </record>      </data> </openerp> 

you can use onchange function , return values need.

to so, set on_change attribute field:

<field name="name" on_change="onchange_name(name)" /> 

and in .py file, add function model:

def onchange_name(self, cr, uid, ids, name, context=none):     # put logic here     return {         'value': {             'surname': 'this surname'         }     } 

so surname changed when changing name field.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -