콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
6821 화면

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?

아바타
취소
관련 게시물 답글 화면 활동
2
8월 22
7010
4
9월 17
25632
0
2월 16
5631
1
1월 16
4702
1
3월 15
8230