@@ -10,6 +10,7 @@ class HrLeave(models.Model):
|
||||
_inherit = 'hr.leave'
|
||||
|
||||
batch_id = fields.Many2one(string='批量', comodel_name='hr.leave.batch', required=True, ondelete='cascade')
|
||||
selection_day = fields.Selection([('first_day', '上半天'), ('second_day', '下半天')], string="选择半天")
|
||||
|
||||
|
||||
class HolidaysRequestBatch(models.Model):
|
||||
@@ -31,9 +32,10 @@ class HolidaysRequestBatch(models.Model):
|
||||
days = fields.Float(string='天数')
|
||||
hours = fields.Float(string='小时')
|
||||
text = fields.Html(string='申请事由')
|
||||
is_day = fields.Boolean(string='按天请假')
|
||||
is_hour = fields.Boolean(string='按小时请假')
|
||||
leave_ids = fields.One2many(string='详情', comodel_name='hr.leave', inverse_name='batch_id')
|
||||
leave_line_ids = fields.One2many('hr.leave.line', 'leave_batch_id', string="关联请假详情明细行")
|
||||
|
||||
is_issues = fields.Boolean(string='是否上会')
|
||||
leave_by_hour = fields.Boolean(string='请假单位(小时)', default=False)
|
||||
leave_by_day = fields.Boolean(string='请假单位(天)', default=True)
|
||||
|
||||
@@ -34,31 +34,52 @@
|
||||
<field name="text"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="is_day"/>
|
||||
<field name="is_hour"/>
|
||||
<field name="is_issues" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="请假详情"/>
|
||||
<button name="action_submit" string="提交"/>
|
||||
<!-- context="{'form_view_ref': 'hr_holidays.hr_leave_view_form_dashboard_new_time_off'}"-->
|
||||
<field name="leave_ids">
|
||||
<field name="leave_ids" invisible="not is_day">
|
||||
<tree editable="bottom">
|
||||
<field name="state" column_invisible="True"/>
|
||||
<field name="employee_company_id" column_invisible="True"/>
|
||||
<field name="name" column_invisible="True"/>
|
||||
<field name="holiday_type" column_invisible="True"/>
|
||||
<field name="user_id" column_invisible="True"/>
|
||||
<field name="batch_id" class="list_width"/>
|
||||
<field name="request_hour_from" column_invisible="True"/>
|
||||
<field name="request_unit_hours" column_invisible="True"/>
|
||||
<field name="holiday_status_id" class="list_width"/>
|
||||
<field name="request_date_from" class="list_width"/>
|
||||
<field name="request_date_to" class="list_width"/>
|
||||
<field name="request_hour_to" column_invisible="True"/>
|
||||
<field name="number_of_days_display"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="leave_ids" invisible="not is_hour">
|
||||
<tree editable="bottom">
|
||||
<field name="state" column_invisible="True"/>
|
||||
<field name="employee_company_id" column_invisible="True"/>
|
||||
<field name="name" column_invisible="True"/>
|
||||
<field name="holiday_type" column_invisible="True"/>
|
||||
<field name="user_id" column_invisible="True"/>
|
||||
<field name="batch_id"/>
|
||||
<field name="request_unit_hours"/>
|
||||
<field name="request_date_from" column_invisible="True"/>
|
||||
<field name="request_unit_hours" column_invisible="True"/>
|
||||
<field name="holiday_status_id"/>
|
||||
<field name="request_date_from"/>
|
||||
<field name="selection_day"/>
|
||||
<field name="request_date_to" column_invisible="True"/>
|
||||
<field name="request_hour_from"/>
|
||||
<field name="request_date_to"/>
|
||||
<field name="request_hour_to"/>
|
||||
<field name="number_of_days_display"/>
|
||||
<field name="number_of_hours_text"/>
|
||||
<field name="number_of_hours_text" column_invisible="True"/>
|
||||
<field name="number_of_days_display" column_invisible="True"/>
|
||||
</tree>
|
||||
</field>
|
||||
<div>
|
||||
<field name="leave_line_ids" nolabel="1" context="{'default_leave_unit': 'hour'}">
|
||||
<field name="leave_line_ids" nolabel="1" context="{'default_leave_unit': 'hour'}" invisible="1">
|
||||
<tree editable="bottom">
|
||||
<field name="leave_batch_id" column_invisible="1"/>
|
||||
<field name="employee_id" column_invisible="1"/>
|
||||
@@ -69,10 +90,11 @@
|
||||
context="{'employee_id': employee_id, 'default_date_from': start_time, 'default_date_to': end_time}"
|
||||
options="{'no_create': True, 'no_open': True, 'request_type': 'leave'}"
|
||||
/>
|
||||
<field name="duration_leave"/>
|
||||
<field name="duration_leave_hour"/>
|
||||
<field name="start_time" class="list_width"/>
|
||||
<field name="end_time" class="list_width" readonly="1"/>
|
||||
<field name="duration_leave" column_invisible="1"/>
|
||||
<field name="duration_leave_hour" column_invisible="1"/>
|
||||
<field name="start_time" class="list_width" column_invisible="1"/>
|
||||
<field name="end_time" class="list_width" readonly="1" column_invisible="1"/>
|
||||
<!-- <field name=""-->
|
||||
<field name="leave_documents_ids" widget="preview_many2many" options="{'preview_type': 'button', 'preview_string': '查看详情'}"/>
|
||||
<field name="custom_document_ids" widget="preview_many2many" options="{'show_select_btn': false}"/>
|
||||
</tree>
|
||||
|
||||
@@ -21,8 +21,9 @@ class GoApprovals(models.Model):
|
||||
department_id = fields.Many2one(related='users_id.employee_id.department_id', string="部门")
|
||||
reason_application = fields.Char(string="事由")
|
||||
is_issues = fields.Boolean(string='是否上会')
|
||||
employee_ids = fields.Many2many('hr.employee', string="外出人", default=lambda self: self.env['hr.employee'].search([('user_id', '=', self.env.uid)]))
|
||||
employee_ids = fields.Many2many('hr.employee', string="外出人", default=lambda self: self.env['hr.employee'].search([('user_id', '=', self.env.uid)]))
|
||||
documents_ids = fields.Many2many('ir.attachment', string="附件")
|
||||
details = fields.Text(string="外出说明", default="1.可通过填写天数和小时,直接获得结束时间\n 2.一份外出单,可同时选择多人一次审批")
|
||||
related_issues_id = fields.Many2one('issue.library', string="关联议题")
|
||||
date_start = fields.Datetime(string="开始时间", default=fields.Datetime.now)
|
||||
date_end = fields.Datetime(string="结束时间")
|
||||
|
||||
@@ -260,30 +260,16 @@ class HrAttendance(models.Model):
|
||||
('start_datetime', '>=', today.strftime('%Y-%m-%d 00:00:00')),
|
||||
('start_datetime', '<', tomorrow.strftime('%Y-%m-%d 00:00:00')),
|
||||
])
|
||||
for slot in today_slots_id:
|
||||
name = slot.template_id.planning_name
|
||||
now = datetime.now()+timedelta(hours=8)
|
||||
department_id_name = slot.template_id.department_id.name
|
||||
resource = self.env['resource.resource'].browse(resource_id)
|
||||
if department_id_name == '工程部' and name in ('白班', '中值夜班'):
|
||||
if now <= slot.start_datetime + timedelta(hours=8):
|
||||
self.card_in_comment(resource.employee_id)
|
||||
elif now >= slot.end_datetime + timedelta(hours=8):
|
||||
self.card_out_comment(resource.employee_id)
|
||||
elif department_id_name == '保安部' and name in ('白班', '中班', '夜班'):
|
||||
_logger.info("判断前now:{}---start:{}".format(now+ timedelta(hours=8), slot.start_datetime + timedelta(hours=8)))
|
||||
if now <= slot.start_datetime + timedelta(hours=8):
|
||||
_logger.info("判断后now:{}---start:{}".format(now+ timedelta(hours=8), slot.start_datetime + timedelta(hours=8)))
|
||||
self.card_in_comment(resource.employee_id)
|
||||
elif now >= slot.end_datetime + timedelta(hours=8):
|
||||
self.card_out_comment(resource.employee_id)
|
||||
elif department_id_name == '联安粮库' and name in ('粮库白班', '粮库值班'):
|
||||
_logger.info("判断前now:{}---start:{}".format(now, slot.start_datetime + timedelta(hours=8)))
|
||||
if now <= slot.start_datetime + timedelta(hours=8):
|
||||
_logger.info("判断后now:{}---start:{}".format(now, slot.start_datetime + timedelta(hours=8)))
|
||||
self.card_in_comment(resource.employee_id)
|
||||
elif now >= slot.end_datetime + timedelta(hours=8):
|
||||
self.card_out_comment(resource.employee_id)
|
||||
now = datetime.now()+timedelta(hours=8)
|
||||
strat_time = today_slots_id.start_datetime + timedelta(hours=8)
|
||||
end_time = today_slots_id.end_datetime + timedelta(hours=8)
|
||||
resource = self.env['resource.resource'].browse(resource_id)
|
||||
_logger.info("判断前now:{}---start:{}".format(now + timedelta(hours=8),today_slots_id.start_datetime + timedelta(hours=8)))
|
||||
if now <= strat_time:
|
||||
_logger.info("判断后now:{}---start:{}".format(now + timedelta(hours=8),today_slots_id.start_datetime + timedelta(hours=8)))
|
||||
self.card_in_comment(resource.employee_id)
|
||||
elif now >= end_time:
|
||||
self.card_out_comment(resource.employee_id)
|
||||
|
||||
def card_in_comment(self, employee_id):
|
||||
data = "您还有10分钟上班,记得打卡"
|
||||
|
||||
@@ -26,7 +26,6 @@ class OvertimeApprovals(models.Model):
|
||||
overtime_hours = fields.Float(string="本月加班时长")
|
||||
start_time = fields.Datetime(string="开始时间")
|
||||
end_time = fields.Datetime(string="结束时间")
|
||||
hours = fields.Float(string="加班时长", compute="_compute_hours")
|
||||
type_overtime = fields.Selection([('work', '工作日加班'), ('weekend', '周末加班'), ('holiday', '节假日加班')],
|
||||
string="加班类型", compute="_compute_overtime_type")
|
||||
|
||||
@@ -113,15 +112,6 @@ class OvertimeApprovals(models.Model):
|
||||
else:
|
||||
rec.name = f"{rec.users_id.name}加班{rec.duration}小时"
|
||||
|
||||
@api.depends('start_time', 'end_time')
|
||||
def _compute_hours(self):
|
||||
for record in self:
|
||||
if record.start_time and record.end_time:
|
||||
delta = record.end_time - record.start_time
|
||||
record.hours = delta.total_seconds() / 3600
|
||||
else:
|
||||
record.hours = 0
|
||||
|
||||
@api.depends('start_time', 'end_time')
|
||||
def _compute_overtime_type(self):
|
||||
for record in self:
|
||||
|
||||
@@ -32,9 +32,10 @@
|
||||
<field name="date_end" required="1"/>
|
||||
<field name="days"/>
|
||||
<field name="hours"/>
|
||||
<field name="employee_ids" widget="many2many_tags"/>
|
||||
<field name="details"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="employee_ids" widget="many2many_tags"/>
|
||||
<field name="code"/>
|
||||
<field name="department_id" invisible="1"/>
|
||||
</group>
|
||||
|
||||
@@ -30,19 +30,17 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="users_id"/>
|
||||
<field name="yuthon_company" invisible="1"/>
|
||||
<field name="code"/>
|
||||
<field name="start_time"/>
|
||||
<field name="end_time"/>
|
||||
<field name="duration"/>
|
||||
<field name="yuthon_company" invisible="1"/>
|
||||
<field name="type_overtime"/>
|
||||
<field name="overtime_hours"/>
|
||||
<field name="details"/>
|
||||
<field name="details"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="employee_ids" widget="many2many_tags"/>
|
||||
<field name="department_id" invisible="1"/>
|
||||
<field name="start_time"/>
|
||||
<field name="end_time"/>
|
||||
<field name="hours"/>
|
||||
<field name="overtime_hours"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<group string="审批事项">
|
||||
<group>
|
||||
<field name="name" placeholder="请输入标题"/>
|
||||
<field name="code"/>
|
||||
<field name="code" invisible="1"/>
|
||||
<field name="reason_application"/>
|
||||
<field name="documents_ids" widget="preview_many2many"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user