Skip to Content
Menu
This question has been flagged
5442 Views

Hello, 
I want to make a modification on hr_holidays module to create a schedule every month to allocate 3 extra days for each employee.

By following this \tutorial I managed to create a single record for each employee which updates itself to add extra 3 days for each employee. Here's my code

class hr_holidays(models.Model):

_inherit = 'hr.holidays',

#This function is called when the scheduler goes off

def process_demo_scheduler_queue(self, cr, uid, context=None):

scheduler_line_obj = self.pool.get('hr.holidays')

#Contains all ids for the model hr.holidays

scheduler_line_ids = self.pool.get('hr.holidays').search(cr, uid, [])

#Loops over every record in the model hr.holidays

for scheduler_line_id in scheduler_line_ids :

#Contains all details from the record in the variable scheduler_line

scheduler_line =scheduler_line_obj.browse(cr, uid,scheduler_line_id ,context=context)

number_of_days_temp = scheduler_line.number_of_days_temp

state = scheduler_line.state

#Prints out the name of every record.

#Update the record

scheduler_line_obj.write(cr, uid, scheduler_line_id, {'number_of_days_temp': (number_of_days_temp +3), 'state': 'confirm'}, context=context)


cron view:


    <record id="ir_cron_scheduler_hr_holidays" model="ir.cron">

<field name="name">Leaves scheduler</field>

<field name="user_id" ref="base.user_root"/>

<field name="interval_number">1</field>

<field name="interval_type">months</field>

<field name="numbercall">-1</field>

<field eval="False" name="doall"/>

<field eval="'hr.holidays'" name="model"/>

<field eval="'process_demo_scheduler_queue'" name="function"/>

</record>

But what I need is that I want to schedule every month with a new created record ea. each employee will have 12 allocation records in a single year, not only one record which update itself every month.

How to do that?

Avatar
Discard
Related Posts Replies Views Activity
2
Aug 22
5659
4
Sep 17
23748
0
Feb 16
4458
1
Jan 16
3583
1
Mar 15
6512