添加功能

This commit is contained in:
李鹏宇
2025-10-23 11:10:55 +08:00
parent 99e71b0904
commit ada0313424
4 changed files with 38 additions and 23 deletions
@@ -169,9 +169,10 @@ class YuthonVacationReports(models.Model):
is_work = 0
leave_days = 0
test_days = 0
right_days = 0
statutory_days = 0
is_abnormal = 0
actual_attendance = 0 # 实到天数 = 应到天数 - 请假总天数
right_days = 0
actual_attendance = 0 # 实到天数 = 应到天数 - 请假总天数 - 异常天数
total_leave_days = 0 # 请假工作流总天数(含小时折算)
if rec.employee_id and rec.vacation_date:
@@ -180,7 +181,7 @@ class YuthonVacationReports(models.Model):
days_in_month = calendar.monthrange(year, month)[1]
month_start = date(year, month, 1)
month_end = date(year, month, days_in_month)
leave_days = rec._create_leave_record(rec.employee_id, month_start, month_end)
leave_days, holiday_days = rec._create_leave_record(rec.employee_id, month_start, month_end)
entry_date = rec.employee_id.entry_date
if not entry_date or month_start > entry_date:
start_day = 1
@@ -220,25 +221,32 @@ class YuthonVacationReports(models.Model):
elif related_model.hours:
total_leave_days += float(related_model.hours) / 8
actual_attendance = round(max(0, leave_days - total_leave_days), 1)
actual_attendance = round(max(0, leave_days - total_leave_days - is_abnormal), 1)
month_start = date(year, month, 1)
month_end = date(year, month, calendar.monthrange(year, month)[1])
leave_days = rec._create_leave_record(rec.employee_id, month_start, month_end)
start_date = max(rec.employee_id.contract_id.date_start, month_start)
if rec.employee_id.contract_id.date_end:
end_date = min(rec.employee_id.contract_id.date_end, month_end)
else:
end_date = month_end
leave_days, statutory_days = rec._create_leave_record(rec.employee_id, start_date, end_date)
probation_contract = self.env['hr.contract'].search([
('employee_id', '=', rec.employee_id.id),
('is_probation', '=', True),
('end_date', '>=', month_start),
('end_date', '<=', month_end)
], limit=1)
if probation_contract:
test_days = rec._create_leave_record(rec.employee_id, month_start, probation_contract.end_date)
right_days = max(0.0, leave_days - test_days)
end_date = min(probation_contract.end_date, month_end)
start_date = max(probation_contract.start_date, month_start)
work_days, statutory_days = rec._create_leave_record(rec.employee_id, start_date, end_date)
test_days = work_days + statutory_days
right_days = (leave_days + statutory_days) - (work_days + statutory_days)
else:
test_days = 0
right_days = 0
rec.should_attendance = leave_days
rec.should_attendance = leave_days + statutory_days
rec.test_days = test_days
rec.right_days = right_days
rec.is_late_card = is_late
@@ -246,7 +254,7 @@ class YuthonVacationReports(models.Model):
rec.is_no_card = is_no
rec.is_work = is_work
rec.is_abnormal = is_abnormal
rec.actual_attendance = actual_attendance
rec.actual_attendance = actual_attendance + statutory_days - is_abnormal
rec.att_mount = actual_attendance
@@ -324,36 +332,43 @@ class YuthonVacationReports(models.Model):
calendar_leaves = self.env['resource.calendar.leaves'].search(
[("calendar_id.name", "=", "行政考勤工作日")])
holidays_list = []
shift_days_list = []
holidays_list = [] # 节假日列表
statutory_list = [] # 法定节假日列表
shift_days_list = [] # 调休日列表
# 提取节假日和调休日
for leave in calendar_leaves:
if leave.holidays:
holidays_list.extend(leave.holidays.split(','))
statutory_list.extend(leave.holidays.split(','))
if leave.alternate_rest_day:
holidays_list.extend(leave.alternate_rest_day.split(','))
if leave.shift_replacement_day:
shift_days_list.extend(leave.shift_replacement_day.split(','))
# 去除日期中的前导零(如"01月05日"→"1月5日")
holidays_list = [self.remove_leading_zero(date) for date in holidays_list]
shift_days_list = [self.remove_leading_zero(date) for date in shift_days_list]
statutory_list = [self.remove_leading_zero(date) for date in statutory_list]
work_days = 0 # 工作日计数
statutory_days = 0 # 法定节假日计数
current_date = actual_start_date
while current_date <= end_date:
current_date_str = current_date.strftime('%m月%d日')
current_date_str = self.remove_leading_zero(current_date_str)
is_weekend = current_date.weekday() in [5, 6]
is_statutory = current_date_str in statutory_list
is_holiday = current_date_str in holidays_list
is_shift_day = current_date_str in shift_days_list
# 判断是否为工作日
if is_shift_day or (not is_weekend and not is_holiday):
work_days += 1
if is_statutory:
statutory_days += 1
current_date += timedelta(days=1)
return work_days
return work_days, statutory_days
def remove_leading_zero(self, date_str):
month, day = date_str.split('月')
@@ -57,7 +57,7 @@
</group>
<group string="调替班信息">
<field name="alternate_shifts"/>
<field name="resource_id" domain="[('company_id', '=', company_id)]"/>
<field name="resource_id" domain="[('company_id', '=', company_id)]" options="{'no_create': True, 'no_edit':True}"/>
<field name="alternate_id" invisible="alternate_shifts != 'alternate'"/>
<field name="company_id" invisible="1"/>
<field name="users_id" invisible="1"/>
@@ -66,7 +66,7 @@
</group>
<group col="4" string="班次1">
<group>
<field name="shift_date" invisible="alternate_shifts == 'alternate'"/>
<field name="shift_date" invisible="alternate_shifts == 'alternate'" />
<field name="return_date"/>
</group>
<group>
@@ -79,11 +79,11 @@
context="{'tree_view_ref': 'yuthon_hr_attendance.view_yuthon_shift_context',
'search_view_ref': 'yuthon_hr_attendance.search_yuthon_shift_context',
'order': 'start_datetime desc',
'search_default_group_by_month': True,}"/>
'search_default_group_by_month': True,}" options="{'no_create': True, 'no_edit':True}"/>
<field name="return_id" context="{'tree_view_ref': 'yuthon_hr_attendance.view_yuthon_shift_context',
'search_view_ref': 'yuthon_hr_attendance.search_yuthon_shift_context',
'order': 'start_datetime desc',
'search_default_group_by_month': True,}"
'search_default_group_by_month': True,}" options="{'no_create': True, 'no_edit':True}"
domain="[
('resource_id', '=', resource_id),
('start_datetime', '&gt;', return_date + ' 00:00:00'),
@@ -109,11 +109,11 @@
context="{'tree_view_ref': 'yuthon_hr_attendance.view_yuthon_shift_context',
'search_view_ref': 'yuthon_hr_attendance.search_yuthon_shift_context',
'order': 'start_datetime desc',
'search_default_group_by_month': True,}"/>
'search_default_group_by_month': True,}" options="{'no_create': True, 'no_edit':True}"/>
<field name="return_two_id" context="{'tree_view_ref': 'yuthon_hr_attendance.view_yuthon_shift_context',
'search_view_ref': 'yuthon_hr_attendance.search_yuthon_shift_context',
'order': 'start_datetime desc',
'search_default_group_by_month': True,}"
'search_default_group_by_month': True,}" options="{'no_create': True, 'no_edit':True}"
domain="[
('resource_id', '=', resource_id),
('start_datetime', '&gt;', return_two_date + ' 00:00:00'),
@@ -193,7 +193,7 @@ class MeterWaterLine(models.Model):
current_read = fields.Float(string='本次读数', group_operator=None)
unit_number = fields.Char(string='单元编号/用途')
unit = fields.Float(string='当月单价', group_operator=None, digits=(16, 4))
receivables = fields.Float(string="应收", store=True, help="应收金额=本次用量*单价*(1+线损)")
receivables = fields.Float(string="应收", store=True, help="应收金额=本次用量*单价*(1+线损)", compute="_compute_receivables")
gauge_magnification = fields.Integer(string='仪表倍率', default=1)
last_reading_time = fields.Date(string="最后读数时间")
type = fields.Selection([("public", "公共"), ("fees", "收费")], string="类型")
@@ -30,7 +30,7 @@ class PropertyReconciliationWizard(models.Model):
for rec in self:
rec.amount_reconciled = rec.actual_total - rec.amount_been_reconciled - sum(line.amount for line in rec.reconciliation_line_ids)
for line in rec.reconciliation_line_ids:
if line.rent_month == line.amount and line.collection_type == 'rent':
if line.rent_month == line.amount and line.collection_type == 'rent' and line.due_date.year == rec.actual_date.year and line.due_date.month == rec.actual_date.month:
line.remake = str(rec.actual_date) + '补' + str(line.due_date)
@api.depends('reconciliation_line_ids')