Odoo Help

0

How to create scheduler

By
youta
on 2/14/16, 7:32 AM 560 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?

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 2/14/16, 7:32 AM
Seen: 560 times
Last updated: 2/14/16, 7:51 AM