添加功能
This commit is contained in:
@@ -168,11 +168,24 @@ class HrLeave(models.Model):
|
||||
holiday.number_of_days = days
|
||||
if holiday.holiday_status_id.type_of_work == "0":
|
||||
calendar = self.env['resource.calendar'].sudo().search([("name", "=", "行政考勤工作日")], limit=1)
|
||||
day, hours = holiday._get_duration(resource_calendar=calendar)
|
||||
total_hours = (self.request_date_to - self.request_date_from).days
|
||||
days = calendar.hours_per_day/8 * total_hours + 1
|
||||
holiday.number_of_hours = hours
|
||||
holiday.number_of_days = days
|
||||
calendar_leaves = self.env['resource.calendar.leaves'].search([])
|
||||
found = False
|
||||
target_day = holiday.request_date_from
|
||||
for leaves in calendar_leaves:
|
||||
shift_days = leaves.shift_replacement_day.split(',') if leaves.shift_replacement_day else []
|
||||
for day_str in shift_days:
|
||||
day = datetime.strptime(day_str, '%m月%d日')
|
||||
if day.month == target_day.month and day.day == target_day.day:
|
||||
hours = float(holiday.request_hour_to) - float(holiday.request_hour_from) -2
|
||||
holiday.number_of_hours = hours
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
day, hours = holiday._get_duration(resource_calendar=calendar)
|
||||
total_hours = (self.request_date_to - self.request_date_from).days
|
||||
days = calendar.hours_per_day / 8 * total_hours + 1
|
||||
holiday.number_of_hours = hours
|
||||
holiday.number_of_days = days
|
||||
|
||||
def _compute_request_unit_hours(self):
|
||||
if not self.env.context.get('no_change_request_unit_hours'):
|
||||
|
||||
@@ -130,9 +130,9 @@
|
||||
<group>
|
||||
<field name="is_hour"/>
|
||||
</group>
|
||||
<group invisible="not is_hour" string=" ">
|
||||
<group invisible="not is_hour">
|
||||
<group>
|
||||
<field name="hour_leave_ids" invisible="not is_hour"
|
||||
<field name="hour_leave_ids" invisible="not is_hour" string=" "
|
||||
context="{
|
||||
'default_holiday_type': 'employee',
|
||||
'default_employee_id': employee_id,
|
||||
|
||||
@@ -659,6 +659,20 @@ class HrAttendance(models.Model):
|
||||
def update_attendance(self):
|
||||
self.browse(self._context.get('active_ids', self._context.get('active_id'))).write({'check_in': False})
|
||||
|
||||
def update_shift(self):
|
||||
attendance_ids = self.env["hr.attendance"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
for attendance_id in attendance_ids:
|
||||
if not attendance_id.shift_id:
|
||||
attendance_id.shift_name = '行政班次'
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
record = super(HrAttendance, self).create(vals)
|
||||
if not record.shift_id:
|
||||
record.shift_name = '行政班次'
|
||||
return record
|
||||
|
||||
class card_remind_form(models.Model):
|
||||
_name = 'card.remind.form'
|
||||
_description = '测试表单'
|
||||
|
||||
@@ -286,8 +286,8 @@ class HrAttendanceDetail(models.Model):
|
||||
remaining_users = total_users
|
||||
for user in user_obj:
|
||||
# 判断是否是微信用户
|
||||
if user.oauth_uid and user.employee_id.contract_id:
|
||||
_logger.info("{} id:{},总:{},剩:{},{}".format(user.name, user.id, total_users, remaining_users, user.employee_id.company_id.name))
|
||||
if user.oauth_uid and user.employee_ids.contract_id:
|
||||
_logger.info("{} id:{},总:{},剩:{},{}".format(user.name, user.id, total_users, remaining_users, user.employee_ids.company_id.name))
|
||||
remaining_users -= 1
|
||||
for current_date in self.sudo().divide_time_range_fixed(start_time, now_time):
|
||||
self.sudo()._do_save_wx_attendance_data(user, current_date)
|
||||
|
||||
@@ -91,7 +91,13 @@
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.button_batch_correct()</field>
|
||||
</record>
|
||||
|
||||
<record id="action_update_shift" model="ir.actions.server">
|
||||
<field name="name">批量更新班次</field>
|
||||
<field name="model_id" ref="yuthon_hr_attendance.model_hr_attendance"/>
|
||||
<field name="binding_model_id" ref="yuthon_hr_attendance.model_hr_attendance"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.update_shift()</field>
|
||||
</record>
|
||||
<record id="action_button_batch_card2" model="ir.actions.server">
|
||||
<field name="name">测试删除</field>
|
||||
<field name="model_id" ref="yuthon_hr_attendance.model_hr_attendance"/>
|
||||
|
||||
Reference in New Issue
Block a user