Odoo / Module Customization / Employees Module
Employees Module
-
Step 1:
1. Models
Main model: \odoo\addons\hr\models\hr_employee_base.py
2. Menu
E:\odoo\16\server\odoo\addons\hr\views\hr_views.xml
-
Work Locations:
1. Menu under Configuration
file : E:\odoo\16\server\odoo\addons\hr\views\hr_views.xml
2. Action window
hr_work_location_action is id of ir.actions.act_window in E:\odoo\16\server\odoo\addons\hr\views\hr_work_location_views.xml
Work Locations1 hr.work.location tree,form Work Locations1 is for menu title and page title3. Form view
E:\odoo\16\server\odoo\addons\hr\views\hr_work_location_views.xml
hr.work.location.view.form hr.work.location 4. tree view
E:\odoo\16\server\odoo\addons\hr\views\hr_work_location_views.xml
hr.work.location.view.tree hr.work.location 5. model
E:\odoo\16\server\odoo\addons\hr\models\hr_work_location.py
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import fields, models class WorkLocation(models.Model): _name = "hr.work.location" _description = "Work Location" _order = 'name' active = fields.Boolean(default=True) name = fields.Char(string="Work Location", required=True) company_id = fields.Many2one('res.company', required=True, default=lambda self: self.env.company) address_id = fields.Many2one('res.partner', required=True, string="Work Address", domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") location_number = fields.Char() -
Department:
1. menu
File : E:\odoo\16\server\odoo\addons\hr\views\hr_views.xml
2. action window
File: E:\odoo\16\server\odoo\addons\hr\views\hr_department_views.xml
ID: hr_department_kanban_action
Departments hr.department kanban,tree,form Create a new department
Odoo's department structure is used to manage all documents related to employees by departments: expenses, timesheets, time off, recruitments, etc.
ID: hr_department_tree_action
Departments hr.department tree,form,kanban Create a new department
Odoo's department structure is used to manage all documents related to employees by departments: expenses, timesheets, leaves, recruitments, etc.
3. form view
hr.department.form hr.department 1. oe_button_box for top buttons 'Employees' & 'Plans'
2. oe_chatter for right panel4. tree view
hr.department.tree hr.department 5. Kanban view
hr.department.kanban hr.department 6. fiter option
hr.department.search hr.department the id view_department_filter is called in window action 7. Model
from odoo import api, fields, models, _ from odoo.exceptions import ValidationError class Department(models.Model): _name = "hr.department" _description = "Department" _inherit = ['mail.thread'] _order = "name" _rec_name = 'complete_name' _parent_store = True name = fields.Char('Department Name', required=True) complete_name = fields.Char('Complete Name', compute='_compute_complete_name', recursive=True, store=True) active = fields.Boolean('Active', default=True) company_id = fields.Many2one('res.company', string='Company', index=True, default=lambda self: self.env.company) parent_id = fields.Many2one('hr.department', string='Parent Department', index=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") child_ids = fields.One2many('hr.department', 'parent_id', string='Child Departments') manager_id = fields.Many2one('hr.employee', string='Manager', tracking=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") member_ids = fields.One2many('hr.employee', 'department_id', string='Members', readonly=True) total_employee = fields.Integer(compute='_compute_total_employee', string='Total Employee') jobs_ids = fields.One2many('hr.job', 'department_id', string='Jobs') plan_ids = fields.One2many('hr.plan', 'department_id') plans_count = fields.Integer(compute='_compute_plan_count') note = fields.Text('Note') color = fields.Integer('Color Index') parent_path = fields.Char(index=True, unaccent=False) master_department_id = fields.Many2one( -
Employeement Type:
1. menu
File : E:\odoo\16\server\odoo\addons\hr\views\hr_views.xml
2. window action
E:\odoo\16\server\odoo\addons\hr\views\hr_contract_type_views.xml
Employment Types hr.contract.type tree view_mode is tree only 3. tree and form view
hr.contract.type hr.contract.type 4. model
from odoo import fields, models class ContractType(models.Model): _name = 'hr.contract.type' _description = 'Contract Type' _order = 'sequence' name = fields.Char(required=True, translate=True) sequence = fields.Integer() -
Job Positions:
1. menu
E:\odoo\16\server\odoo\addons\hr\views\hr_views.xml
2. window action
E:\odoo\16\server\odoo\addons\hr\views\hr_job_views.xml
Job Positions hr.job tree,form {"search_default_Current":1} Ready to recruit more efficiently?
Let's create a job position.
3. tree and kanban view
hr.job.tree hr.job hr.job.kanban hr.job Vacancies :4. Form view
hr.job.form hr.job notebook is for tab view 5. model
from odoo import api, fields, models, _ class Job(models.Model): _name = "hr.job" _description = "Job Position" _inherit = ['mail.thread'] _order = 'sequence' active = fields.Boolean(default=True) name = fields.Char(string='Job Position', required=True, index='trigram', translate=True) sequence = fields.Integer(default=10) expected_employees = fields.Integer(compute='_compute_employees', string='Total Forecasted Employees', store=True, help='Expected number of employees for this job position after new recruitment.') no_of_employee = fields.Integer(compute='_compute_employees', string="Current Number of Employees", store=True, help='Number of employees currently occupying this job position.') no_of_recruitment = fields.Integer(string='Target', copy=False, help='Number of new employees you expect to recruit.', default=1) no_of_hired_employee = fields.Integer(string='Hired Employees', copy=False, help='Number of hired employees for this job position during recruitment phase.') employee_ids = fields.One2many('hr.employee', 'job_id', string='Employees', groups='base.group_user') description = fields.Html(string='Job Description') requirements = fields.Text('Requirements') department_id = fields.Many2one('hr.department', string='Department', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company) contract_type_id = fields.Many2one('hr.contract.type', string='Employment Type')