python - Openerp related fields in HR module hr_employee with Department, Division...etc and Location -


i have these 4 classes in openerp hr module below

res_company --->hr_department-->hr_division-->hr_section

    class company_new_registration(osv.osv):         _name = "hr.company.n.registration"         _description = "company"         _columns = {             'name': fields.char('company name', size=128, required=true),             'depts': fields.one2many('hr.dept.n.registration', 'company_id', 'dept'),          }     company_new_registration()      class dept_new_registration(osv.osv):         _name = "hr.dept.n.registration"         _description = "depts"         _columns = {             'name': fields.char('dept name', size=128, required=true),             'company_id': fields.many2one('res.company', 'company name', required=true),             'divisions': fields.one2many('hr.division.n.registration', 'dept_id', 'division'),             'resres':fields.one2many('res.users','alias_id')          }      dept_new_registration()      class division_new_registration(osv.osv):         _name = "hr.division.n.registration"         _description = "divisions"         _columns = {             'name': fields.char('division name', size=128, ),             'dept_id': fields.many2one('hr.dept.n.registration', 'dept. name', select=true, required=true),             'sections': fields.one2many('hr.section.n.registration', 'division_id', 'section'),          }      division_new_registration()      class section_new_registration(osv.osv):         _name = "hr.section.n.registration"         _description = "sections"         _columns = {             'name': fields.char('name', size=128),              'section_name': fields.char('section name', size=128, required=true),             'division_id': fields.many2one('hr.division.n.registration', 'division name', select=true, required=true),         }      section_new_registration() 

all 4 classes in one2many relationship , above classes have name field , 1 field have relationship respectively.

also there class in module named hr_location need keep above 4 classes references in order create organization structure.

my questions are:

  1. i need create field displays "company name/ department name/division name/ section name" in hr_location table when ever create new section or division or etc

  2. i need create 4 related field stored company_id, department_id, division_id , section_id in hr_employee table when ever select location above (in previous question) field.

first, need create section_new_registration computed field concatenate names of whole hierarchy in "company name/ department name/division name/ section name" need.

or can override create instead of computed field:

def create(self, cr, uid, values, context=none):      company = self.pool.get('res.company').browse(cr, uid, values['company_id'], context=context)      dept = self.pool.get('hr.dept.n.registration').browse(cr, uid, values['department_id'], context=context)      division = self.pool.get('hr.division.n.registration').browse(cr, uid, values['division_id'], context=context)       values['name'] = company.name + '/' + dept.name + '/' + division.name + '/'+ values['section_name']      return super(hr_location, self).create(cr, uid, values, context=context) 

second, need create hr_location field such

'section_id': fields.many2one('hr.section.n.registration') 

to accomplish point (1)

third, point (2) need create 5 fields follows:

'location_id': fields.many2one('hr.location') 'section_id': fields.related('location_id', 'section_id', type='many2one', relation='hr.section.n.registration', store=true) 'division_id': fields.related('location_id', 'section_id', 'division_id', type='many2one', relation='hr.division.n.registration', store=true) 'department_id': fields.related('location_id', 'section_id', 'division_id', 'dept_id', type='many2one', relation='hr.dept.n.registration', store=true) 'company_id': fields.related('location_id', 'section_id', 'division_id', 'dept_id', 'company_id', type='many2one', relation='res.company', store=true) 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -