fix cron
This commit is contained in:
parent
7918b28611
commit
fd850354d6
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
'security/hr_holidays_public_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'data/crons.xml',
|
||||
|
||||
'views/hr_holidays_public_view.xml',
|
||||
'views/hr_holidays_status_views.xml',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record forcecreate="True" id="cron_download_data" model="ir.cron">
|
||||
<field name="name"> Set Delegation Access</field>
|
||||
<field eval="True" name="active"/>
|
||||
<field name="user_id" ref="base.user_admin"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="model_id" ref="hr_holidays_public.model_hr_holidays"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model._process_delegation_access()</field>
|
||||
<!-- <field name="nextcall" eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 23:00:00')" />-->
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -1839,6 +1839,7 @@ class HRHolidays(models.Model):
|
|||
|
||||
def delegate_access(self):
|
||||
for rec in self:
|
||||
print("entered hereeeeeee")
|
||||
if not rec.employee_id.user_id: raise exceptions.Warning(
|
||||
_('Kindly set a user for employee %s') % (rec.employee_id.name))
|
||||
if not rec.replace_by.user_id: raise exceptions.Warning(
|
||||
|
|
@ -1880,6 +1881,21 @@ class HRHolidays(models.Model):
|
|||
holiday.replace_by.user_id.sudo().write({'company_ids': [(3, c) for c in companies]})
|
||||
holiday.delegated_company_ids = [(3, c) for c in companies]
|
||||
|
||||
def _process_delegation_access(self):
|
||||
"""cron for Handling Delegation Access Process"""
|
||||
holiday = self.env['hr.holidays']
|
||||
start_day_holiday = holiday.search([('delegate_acc', '=', True),
|
||||
('date_from', '=', fields.Date.today()),
|
||||
('state', '=', 'validate1')])
|
||||
end_day_holiday = holiday.search([('delegate_acc', '=', True),
|
||||
('date_to', '=', fields.Date.today()),
|
||||
('state', '=', 'validate1')])
|
||||
print("start_day_holiday",start_day_holiday)
|
||||
if start_day_holiday:
|
||||
start_day_holiday.delegate_access()
|
||||
if end_day_holiday:
|
||||
end_day_holiday.remove_delegated_access()
|
||||
|
||||
|
||||
class HRINVERSHolidays(models.Model):
|
||||
_name = 'hr.inverse.holidays'
|
||||
|
|
|
|||
Loading…
Reference in New Issue