Step-by-step guide to create an Odoo module for an HRMS system Advance

  • This topic is empty.
  • Post
    Weekend Wiki
    Keymaster
    Certainly! I’ll provide you with a step-by-step guide to create an Odoo module for an HRMS system with employee functions like applying for vacations, time off, overtime requests, advance cash requests, and emergency leave. Here are the files and their respective paths you’ll need to create:

    1. Create a directory for your module. Let’s call it hrms_module.
    2. Inside the hrms_module directory, create a new file named __manifest__.py. This file is the manifest file for your module and provides information about the module.

    Path: hrms_module/__manifest__.py

    {
        'name': 'HRMS Module',
        'summary': 'Human Resource Management System',
        'description': 'A comprehensive HRMS module for managing employees, leaves, and attendance.',
        'version': '1.0',
        'category': 'Human Resources',
        'author': 'Your Name',
        'depends': ['base', 'hr'],
        'data': [
            'security/ir.model.access.csv',
            'views/employee_views.xml',
            'views/vacation_views.xml',
            'views/time_off_views.xml',
            'views/overtime_request_views.xml',
            'views/advance_cash_request_views.xml',
            'views/emergency_leave_views.xml',
            'views/menu.xml',
        ],
        'installable': True,
        'application': True,
        'auto_install': False,
    }
    
    1. Create a directory named security inside the hrms_module directory. This directory will contain security-related files.

    Path: hrms_module/security/

    1. Inside the security directory, create a new file named ir.model.access.csv. This file defines access control rules for your module.

    Path: hrms_module/security/ir.model.access.csv

    id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
    access_hrms_module_manager,HRMS Manager,model_hr_employee,base.group_hr_manager,1,1,1,1
    access_hrms_module_user,HRMS User,model_hr_employee,,1,1,1,0
    access_hrms_vacation_manager,Vacation Manager,model_hr_vacation,base.group_hr_manager,1,1,1,1
    access_hrms_time_off_manager,Time Off Manager,model_hr_time_off,base.group_hr_manager,1,1,1,1
    access_hrms_overtime_request_manager,Overtime Request Manager,model_hr_overtime_request,base.group_hr_manager,1,1,1,1
    access_hrms_advance_cash_request_manager,Advance Cash Request Manager,model_hr_advance_cash_request,base.group_hr_manager,1,1,1,1
    access_hrms_emergency_leave_manager,Emergency Leave Manager,model_hr_emergency_leave,base.group_hr_manager,1,1,1,1
    
    1. Create a directory named views inside the hrms_module directory. This directory will contain the XML views for your module.

    Path: hrms_module/views/

    1. Inside the views directory, create a new file named employee_views.xml. This file defines the views for managing employees.

    Path: hrms_module/views/employee_views.xml

    <odoo>
        <data>
            <record model="ir.ui.view" id="view_employee_form">
                <field name="name">hr.employee.form</field>
                <field name="model">hr.employee</field>
                <field name="arch" type="xml">
                    <!-- Define your employee form view here -->
                </field>
            </record>
        </data>
    </odoo>
    
    1. Similarly, create vacation_views.xml, time_off_views.xml, overtime_request_views.xml, advance_cash_request_views.xml, and emergency_leave_views.xml inside the views directory to define views for managing vacations, time off, overtime requests, advance cash requests, and emergency leave, respectively.

    Path: hrms_module/views/vacation_views.xml

    <odoo>
        <data>
            <record model="ir.ui.view" id="view_vacation_form">
                <field name="name">hr.vacation.form</field>
                <field name="model">hr.vacation</field>
                <field name="arch" type="xml">
                    <!-- Define your vacation form view here -->
                </field>
            </record>
        </data>
    </odoo>
    

    Path: hrms_module/views/time_off_views.xml

    <odoo>
        <data>
            <record model="ir.ui.view" id="view_time_off_form">
                <field name="name">hr.time_off.form</field>
                <field name="model">hr.time_off</field>
                <field name="arch" type="xml">
                    <!-- Define your time off form view here -->
                </field>
            </record>
        </data>
    </odoo>
    

    Path: hrms_module/views/overtime_request_views.xml

    <odoo>
        <data>
            <record model="ir.ui.view" id="view_overtime_request_form">
                <field name="name">hr.overtime_request.form</field>
                <field name="model">hr.overtime_request</field>
                <field name="arch" type="xml">
                    <!-- Define your overtime request form view here -->
                </field>
            </record>
        </data>
    </odoo>
    

    Path: hrms_module/views/advance_cash_request_views.xml

    <odoo>
        <data>
            <record model="ir.ui.view" id="view_advance_cash_request_form">
                <field name="name">hr.advance_cash_request.form</field>
                <field name="model">hr.advance_cash_request</field>
                <field name="arch" type="xml">
                    <!-- Define your advance cash request form view here -->
                </field>
            </record>
        </data>
    </odoo>
    

    Path: hrms_module/views/emergency_leave_views.xml

    <odoo>
        <data>
            <record model="ir.ui.view" id="view_emergency_leave_form">
                <field name="name">hr.emergency_leave.form</field>
                <field name="model">hr.emergency_leave</field>
                <field name="arch" type="xml">
                    <!-- Define your emergency leave form view here -->
                </field>
            </record>
        </data>
    </odoo>
    
    1. hrms_module/views/menu.xml
    <odoo>
        <data>
            <record model="ir.ui.menu" id="menu_hrms_main">
                <field name="name">HRMS</field>
                <field name="sequence" eval="10"/>
                <field name="action" ref="action_hrms_dashboard"/>
            </record>
            <menuitem id="menu_hrms_configuration" name="Configuration" parent="menu_hrms_main" sequence="10"/>
            <menuitem id="menu_hrms_employee" name="Employees" parent="menu_hrms_main" sequence="20" action="action_hr_employee"/>
            <menuitem id="menu_hrms_vacation" name="Vacations" parent="menu
    

    Here’s an updated version of the code with additional functions for vacation application, time off, overtime request, advance cash request, and emergency leave in the HRMS module. Please note that you will need to define the actual form views and models according to your specific requirements.

    1. hrms_module/views/vacation_views.xml
    <odoo>
        <data>
            <record model="ir.ui.view" id="view_vacation_form">
                <field name="name">hr.vacation.form</field>
                <field name="model">hr.vacation</field>
                <field name="arch" type="xml">
                    <!-- Define your vacation form view here -->
                </field>
            </record>
        </data>
    </odoo>
    
    1. hrms_module/views/time_off_views.xml
    <odoo>
        <data>
            <record model="ir.ui.view" id="view_time_off_form">
                <field name="name">hr.time_off.form</field>
                <field name="model">hr.time_off</field>
                <field name="arch" type="xml">
                    <!-- Define your time off form view here -->
                </field>
            </record>
        </data>
    </odoo>
    
    1. hrms_module/views/overtime_request_views.xml
    <odoo>
        <data>
            <record model="ir.ui.view" id="view_overtime_request_form">
                <field name="name">hr.overtime_request.form</field>
                <field name="model">hr.overtime_request</field>
                <field name="arch" type="xml">
                    <!-- Define your overtime request form view here -->
                </field>
            </record>
        </data>
    </odoo>
    
    1. hrms_module/views/advance_cash_request_views.xml
    <odoo>
        <data>
            <record model="ir.ui.view" id="view_advance_cash_request_form">
                <field name="name">hr.advance_cash_request.form</field>
                <field name="model">hr.advance_cash_request</field>
                <field name="arch" type="xml">
                    <!-- Define your advance cash request form view here -->
                </field>
            </record>
        </data>
    </odoo>
    
    1. hrms_module/views/emergency_leave_views.xml
    <odoo>
        <data>
            <record model="ir.ui.view" id="view_emergency_leave_form">
                <field name="name">hr.emergency_leave.form</field>
                <field name="model">hr.emergency_leave</field>
                <field name="arch" type="xml">
                    <!-- Define your emergency leave form view here -->
                </field>
            </record>
        </data>
    </odoo>
    
    1. hrms_module/views/menu.xml
    <odoo>
        <data>
            <record model="ir.ui.menu" id="menu_hrms_main">
                <field name="name">HRMS</field>
                <field name="sequence" eval="10"/>
                <field name="action" ref="action_hrms_dashboard"/>
            </record>
            <menuitem id="menu_hrms_configuration" name="Configuration" parent="menu_hrms_main" sequence="10"/>
            <menuitem id="menu_hrms_employee" name="Employees" parent="menu_hrms_main" sequence="20" action="action_hr_employee"/>
            <menuitem id="menu_hrms_vacation" name="Vacations" parent="menu_hrms_main" sequence="30" action="action_hr_vacation"/>
            <menuitem id="menu_hrms_time_off" name="Time Off" parent="menu_hrms_main" sequence="40" action="action_hr_time_off"/>
            <menuitem id="menu_hrms_overtime_request" name="Overtime Requests" parent="menu_hrms_main" sequence="50" action="action_hr_overtime_request"/>
            <menuitem id="menu_hrms_advance_cash_request" name="Advance Cash Requests" parent="menu_hrms_main" sequence="60" action="action_hr_advance_cash_request"/>
            <menuitem id="menu_hrms_emergency_leave" name="Emergency Leave" parent="menu_hrms_main" sequence="70" action="action_hr_emergency_leave"/>
        </data>
    </odoo>
    

    Please note that the code snippets above include placeholders for the actual form views. You need to define the views according to your specific requirements inside the respective XML files.

  • You must be logged in to reply to this topic.
en_USEnglish