commit
ee757b10d9
|
|
@ -36,34 +36,34 @@ class HrPersonalPermission(models.Model):
|
|||
state = fields.Selection([('draft', _('Draft')), ('send', _('Waiting Direct Manager')), ('direct_manager', _('Wait HR Department')),('approve', _('Approved')), ('refused', _('Refused'))], default="draft", tracking=True)
|
||||
type_exit = fields.Selection([('early_exit', _('Early Exit')), ('late entry', _('Late Entry')), ('during work', _('During Work'))],default="early_exit")
|
||||
company_id = fields.Many2one('res.company',string="Company", default=lambda self: self.env.user.company_id)
|
||||
time_permission_from = fields.Float(string="Permission From (24h format)", help="Time in 24-hour format (e.g., 13.5 for 1:30 PM)")
|
||||
time_permission_to = fields.Float(string="Permission To (24h format)", help="Time in 24-hour format (e.g., 15.75 for 3:45 PM)")
|
||||
# time_permission_from = fields.Float(string="Permission From (24h format)", help="Time in 24-hour format (e.g., 13.5 for 1:30 PM)")
|
||||
# time_permission_to = fields.Float(string="Permission To (24h format)", help="Time in 24-hour format (e.g., 15.75 for 3:45 PM)")
|
||||
|
||||
|
||||
@api.onchange('time_permission_from', 'time_permission_to', 'date')
|
||||
def _onchange_time(self):
|
||||
for record in self:
|
||||
if (not record.time_permission_from < record.time_permission_to):
|
||||
record.time_permission_to = record.time_permission_from + 0.5
|
||||
record.time_permission_from = record.time_permission_from
|
||||
if record.date:
|
||||
date_from = self._combine_date_and_time(record.date, record.time_permission_from)
|
||||
record.date_from = date_from
|
||||
# @api.onchange('time_permission_from', 'time_permission_to', 'date')
|
||||
# def _onchange_time(self):
|
||||
# for record in self:
|
||||
# if (not record.time_permission_from < record.time_permission_to):
|
||||
# record.time_permission_to = record.time_permission_from + 0.5
|
||||
# record.time_permission_from = record.time_permission_from
|
||||
# if record.date:
|
||||
# date_from = self._combine_date_and_time(record.date, record.time_permission_from)
|
||||
# record.date_from = date_from
|
||||
|
||||
if record.date:
|
||||
date_to = self._combine_date_and_time(record.date, record.time_permission_to)
|
||||
record.date_to = date_to
|
||||
# if record.date:
|
||||
# date_to = self._combine_date_and_time(record.date, record.time_permission_to)
|
||||
# record.date_to = date_to
|
||||
|
||||
def _combine_date_and_time(self, date, time_float):
|
||||
""" Combine a date and a float time (e.g. 13.5) into a datetime object. """
|
||||
hours = int(time_float)
|
||||
minutes = int((time_float - hours) * 60)
|
||||
import pytz
|
||||
date_time = datetime.combine(date, datetime.min.time()) + timedelta(hours=hours, minutes=minutes)
|
||||
# if time_float > 0:
|
||||
date_time = fields.Datetime.to_string(pytz.timezone(self.env.context['tz']).localize(fields.Datetime.from_string(date_time), is_dst=None).astimezone(pytz.utc))
|
||||
# date_time = fields.Datetime.to_string(pytz.timezone(self.env.context['tz']).localize(fields.Datetime.from_string(date_time), is_dst=None).astimezone(pytz.utc) + timedelta(hours=24))
|
||||
return date_time
|
||||
# def _combine_date_and_time(self, date, time_float):
|
||||
# """ Combine a date and a float time (e.g. 13.5) into a datetime object. """
|
||||
# hours = int(time_float)
|
||||
# minutes = int((time_float - hours) * 60)
|
||||
# import pytz
|
||||
# date_time = datetime.combine(date, datetime.min.time()) + timedelta(hours=hours, minutes=minutes)
|
||||
# # if time_float > 0:
|
||||
# date_time = fields.Datetime.to_string(pytz.timezone(self.env.context['tz']).localize(fields.Datetime.from_string(date_time), is_dst=None).astimezone(pytz.utc))
|
||||
# # date_time = fields.Datetime.to_string(pytz.timezone(self.env.context['tz']).localize(fields.Datetime.from_string(date_time), is_dst=None).astimezone(pytz.utc) + timedelta(hours=24))
|
||||
# return date_time
|
||||
|
||||
|
||||
@api.model
|
||||
|
|
@ -97,7 +97,7 @@ class HrPersonalPermission(models.Model):
|
|||
@api.depends('date_from', 'date_to')
|
||||
def get_duration_no(self):
|
||||
for item in self:
|
||||
item._onchange_time()
|
||||
# item._onchange_time()
|
||||
if item.date_from and item.date_to:
|
||||
start_date_value = datetime.strptime(str(item.date_from), "%Y-%m-%d %H:%M:%S")
|
||||
end_date = datetime.strptime(str(item.date_to), "%Y-%m-%d %H:%M:%S")
|
||||
|
|
@ -112,7 +112,7 @@ class HrPersonalPermission(models.Model):
|
|||
@api.onchange('date_to', 'date_from', 'employee_id')
|
||||
def permission_number_decrement(self):
|
||||
for item in self:
|
||||
item._onchange_time()
|
||||
# item._onchange_time()
|
||||
if item.employee_id:
|
||||
if not item.employee_id.first_hiring_date:
|
||||
raise exceptions.Warning(
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<field name="view_mode">tree,form,calendar</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_permission_calendar">
|
||||
<record model="ir.ui.view" id="view_permission_calendar">
|
||||
<field name="name">hr.personal.permission.calendar</field>
|
||||
<field name="model">hr.personal.permission</field>
|
||||
<field name="arch" type="xml">
|
||||
|
|
@ -25,58 +25,54 @@
|
|||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<header>
|
||||
<button name="send" string="Submit" class="oe_highlight" type="object"
|
||||
states="draft" groups="base.group_user"/>
|
||||
<button name="send" string="Submit" class="oe_highlight" type="object" states="draft" groups="base.group_user"/>
|
||||
|
||||
<button name="direct_manager" string="Direct Manager Approve" class="oe_highlight" type="object"
|
||||
states="send" groups="hr_base.group_division_manager"/>
|
||||
<button name="refused" string="Refuse" class="oe_highlight" type="object"
|
||||
states="send" groups="hr_base.group_division_manager"/>
|
||||
<button name="direct_manager" string="Direct Manager Approve" class="oe_highlight" type="object" states="send" groups="hr_base.group_division_manager"/>
|
||||
<button name="refused" string="Refuse" class="oe_highlight" type="object" states="send" groups="hr_base.group_division_manager"/>
|
||||
|
||||
<button name="approve" string="HR Approve" class="oe_highlight" type="object"
|
||||
states="direct_manager" groups="hr.group_hr_user"/>
|
||||
<button name="refused" string="Refuse" class="oe_highlight" type="object"
|
||||
states="direct_manager" groups="hr.group_hr_user"/>
|
||||
<button name="draft_state" string="RE-Draft" class="oe_highlight" type="object"
|
||||
states="approve" groups="hr.group_hr_user"/>
|
||||
<button name="draft_state" string="RE-Draft" class="oe_highlight" type="object"
|
||||
states="refused" groups="hr.group_hr_user" confirm="Are you sure to Reset To Draft This Record?"/>
|
||||
<button name="approve" string="HR Approve" class="oe_highlight" type="object" states="direct_manager" groups="hr.group_hr_user"/>
|
||||
<button name="refused" string="Refuse" class="oe_highlight" type="object" states="direct_manager" groups="hr.group_hr_user"/>
|
||||
<button name="draft_state" string="RE-Draft" class="oe_highlight" type="object" states="approve" groups="hr.group_hr_user"/>
|
||||
<button name="draft_state" string="RE-Draft" class="oe_highlight" type="object" states="refused" groups="hr.group_hr_user" confirm="Are you sure to Reset To Draft This Record?"/>
|
||||
<field name="state" widget="statusbar"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<group string="Permission Info">
|
||||
<field name="date" string="Date Request"
|
||||
attrs="{'readonly':[('state','!=','draft')],'required':1}"/>
|
||||
<field name="date_from" string="Date From"
|
||||
attrs="{'readonly':[('state' , '!=' , 'draft')],'required':1}"/>
|
||||
<field name="date_to" string="Date To"
|
||||
attrs="{'readonly':[('state' , '!=' , 'draft')],'required':1}"/>
|
||||
<field name="date" string="Date Request" attrs="{'readonly':[('state','!=','draft')],'required':1}"/>
|
||||
<!-- <label for='time_permission_from' string="Time"/>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<label for='time_permission_from' string="Time from"/>
|
||||
<field name="time_permission_from" widget="float_time" attrs="{'readonly':[('state' , '!=' , 'draft')],'required':1}"/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label for='time_permission_to' string="Time To"/>
|
||||
<field name="time_permission_to" widget="float_time" attrs="{'readonly':[('state' , '!=' , 'draft')],'required':1}"/>
|
||||
</div>
|
||||
</div> -->
|
||||
<field name="date_from" string="Date From" attrs="{'readonly':[('state' , '!=' , 'draft')],'required':1}"/>
|
||||
<field name="date_to" string="Date To" attrs="{'readonly':[('state' , '!=' , 'draft')],'required':1}"/>
|
||||
<field name="duration" string="Duration" attrs="{'readonly':1}" widget="float_time"/>
|
||||
<field name="balance" string="Permission Limit" readonly="1" widget="float_time"/>
|
||||
<field name="permission_number" force_save="True" string="Permission Per Month" widget="float_time"/>
|
||||
<field name="type_exit" string="Type Exit"
|
||||
attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="type_exit" string="Type Exit" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
</group>
|
||||
<group string="Employee Info">
|
||||
<field name="company_id" groups="base.group_multi_company" readonly="1"/>
|
||||
<field name="from_hr_department" string="Another Employee"
|
||||
attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="employee_id" string="Employee"
|
||||
attrs="{'readonly': ['|',('from_hr_department','=',False),('state','!=','draft')],'required':True}"/>
|
||||
<field name="company_id" groups="base.group_multi_company" readonly="1"/>
|
||||
<field name="from_hr_department" string="Another Employee" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="employee_id" string="Employee" attrs="{'readonly': ['|',('from_hr_department','=',False),('state','!=','draft')],'required':True}"/>
|
||||
<field name="employee_no" string="Employee No" readonly="1"/>
|
||||
<field name="job_id" string="Job Title" readonly="1"/>
|
||||
<field name="department_id" string="Department" readonly="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<field name="mission_purpose" string="Reasons"
|
||||
attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="mission_purpose" string="Reasons" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
</group>
|
||||
<!--notebook>
|
||||
<page string="Attachments" name="attachments">
|
||||
<field name="attach_ids" string="Attachments"
|
||||
attrs="{'readonly':[('state','!=','draft')]}">
|
||||
<field name="attach_ids" string="Attachments" attrs="{'readonly':[('state','!=','draft')]}">
|
||||
<tree editable="bottom">
|
||||
<field name="name" string="attachment Name"/>
|
||||
<field name="datas" string="file content"/>
|
||||
|
|
@ -84,15 +80,12 @@
|
|||
</field>
|
||||
</page>
|
||||
<page string="Refusal Causes" name="refusal_causes">
|
||||
<field name="refuse_cause" placeholder="Refuse Cause .........."
|
||||
attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="refuse_cause" placeholder="Refuse Cause .........." attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
</page>
|
||||
<page string="Information" name="information">
|
||||
<group>
|
||||
<field name="approved_by" string="Approved By"
|
||||
attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="refused_by" string="Refused By"
|
||||
attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="approved_by" string="Approved By" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="refused_by" string="Refused By" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook-->
|
||||
|
|
|
|||
|
|
@ -985,14 +985,16 @@ class HRHolidays(models.Model):
|
|||
for rec in self:
|
||||
if rec.employee_id.parent_id:
|
||||
if rec.employee_id.parent_id.user_id.id == rec.env.uid or rec.env.company.hr_manager_id.user_id.id == rec.env.uid:
|
||||
rec.write({'state': 'direct_manager'})
|
||||
rec._chick_leave_balance()
|
||||
rec.write({'state': 'validate'})
|
||||
else:
|
||||
raise exceptions.Warning(_("Sorry, The Approval For The Direct Manager '%s' Only OR HR Manager!")%(rec.employee_id.parent_id.name))
|
||||
else:
|
||||
rec.write({'state': 'direct_manager'})
|
||||
rec._chick_leave_balance()
|
||||
rec.write({'state': 'validate'})
|
||||
|
||||
self._chick_leave_balance()
|
||||
self.write({'state': 'validate'})
|
||||
#self._chick_leave_balance()
|
||||
#self.write({'state': 'validate'})
|
||||
|
||||
def approved(self):
|
||||
self.check_sickness_leave_approval()
|
||||
|
|
|
|||
Loading…
Reference in New Issue