This question has been flagged
2237 Views

Dear support:

Please, we need any help or suggestion to achieve the following:  We have a module to create the Public holidays of my country when the Leave model is installed. We need a solution that allows us when the new year starts, automatically or through an action, to write/modify to the ai.hr.public.holiday model the records as they are contained in the ai_hr_public_holiday_data.xml module and avoid entering them manually every time the year starts.

We work in Odoo 11.0

Thank you, in advance!

Best regards,

Claudio Zayas

__manifest__.py        

 

{

    'name': "Incidencias",

    'author': "aicros",

    'category': 'Human Resources',

    'sequence': 1,

    'version': '0.1',

    'depends': ['hr_ai_base'],

    'data': [

        'data/ai_hr_public_holiday_data.xml',

    ],

    'demo': [],

}

 

ai_hr_public_holiday_data.xml

<odoo>

    <data noupdate="1">

 

        <!-- Public Holiday-->

        <record id="ai_hr_public_holiday_1" model="ai.hr.public.holiday">

                                               <field name="date_from" eval="time.strftime('%Y-01-01')"/>

                                               <field name="date_to" eval="time.strftime('%Y-01-01')"/>

            <field name="type_id" ref="leave_type_9"/>

                                               <field name="note">Aniversario de la Revolución</field>

                                               <field name="mode">company</field>

                               </record>

 

                               <record id="ai_hr_public_holiday_3" model="ai.hr.public.holiday">

                                               <field name="date_from" eval="time.strftime('%Y-01-02')"/>

                                               <field name="date_to" eval="time.strftime('%Y-01-02')"/>

                                               <field name="type_id" ref="leave_type_9"/>

                                               <field name="note">Día festivo</field>

                                               <field name="mode">company</field>

                               </record>

 

                               <record id="ai_hr_public_holiday_5" model="ai.hr.public.holiday">

            <field name="date_from" eval="time.strftime('%Y-05-01')"/>

                                               <field name="date_to" eval="time.strftime('%Y-05-01')"/>

                                               <field name="type_id" ref="leave_type_9"/>

                                               <field name="note">Día Internacional de los Trabajadores</field>

                                               <field name="mode">company</field>

                               </record>

 

                               <record id="ai_hr_public_holiday_7" model="ai.hr.public.holiday">

            <field name="date_from" eval="time.strftime('%Y-07-25')"/>

                                               <field name="date_to" eval="time.strftime('%Y-07-25')"/>

            <field name="type_id" ref="leave_type_11"/>

                                               <field name="note">Día de la Rebeldía Nacional</field>

                                               <field name="mode">company</field>

                               </record>

 

                               <record id="ai_hr_public_holiday_9" model="ai.hr.public.holiday">

            <field name="date_from" eval="time.strftime('%Y-07-26')"/>

                                               <field name="date_to" eval="time.strftime('%Y-07-26')"/>

                                               <field name="type_id" ref="leave_type_9"/>

                                               <field name="note">Día de la Rebeldía Nacional</field>

                                               <field name="mode">company</field>

                               </record>

 

        <record id="ai_hr_public_holiday_10" model="ai.hr.public.holiday">

            <field name="date_from" eval="time.strftime('%Y-07-27')"/>

                                               <field name="date_to" eval="time.strftime('%Y-07-27')"/>

            <field name="type_id" ref="leave_type_11"/>

                                               <field name="note">Día de la Rebeldía Nacional</field>

                                               <field name="mode">company</field>

                               </record>

 

                               <record id="ai_hr_public_holiday_12" model="ai.hr.public.holiday">

            <field name="date_from" eval="time.strftime('%Y-10-10')"/>

                                               <field name="date_to" eval="time.strftime('%Y-10-10')"/>

                                               <field name="type_id" ref="leave_type_9"/>

                                               <field name="note">Inicio de las Guerras de Independecia</field>

                                               <field name="mode">company</field>

                               </record>

 

                               <record id="ai_hr_public_holiday_14" model="ai.hr.public.holiday">

            <field name="date_from" eval="time.strftime('%Y-12-25')"/>

                                               <field name="date_to" eval="time.strftime('%Y-12-25')"/>

                                               <field name="type_id" ref="leave_type_9"/>

                                               <field name="note">Navidad</field>

                                               <field name="mode">company</field>

                               </record>

 

                               <record id="ai_hr_public_holiday_16" model="ai.hr.public.holiday">

                                               <field name="date_from" eval="time.strftime('%Y-12-31')"/>

                                               <field name="date_to" eval="time.strftime('%Y-12-31')"/>

                                               <field name="type_id" ref="leave_type_9"/>

                                               <field name="note">Fin de año</field>

                                               <field name="mode">company</field>

                                </record>

 

    </data>

</odoo>


Avatar
Discard

Why not create a scheduler that goes off once a year to implement this logic?

To achieve that you can create automatic action which be run once at the beginning of the year:

Check the below link for how to create automatic action:

https://www.youtube.com/watch?v=_P_AVSNr6uU