Merge pull request !5225 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2025-09-18 09:04:10 +00:00
committed by Gitee
2 changed files with 24 additions and 1 deletions
@@ -66,6 +66,7 @@ class OvertimeApprovals(models.Model):
'domain': domain,
}
@api.onchange('users_id', 'start_time')
def _onchange_att(self):
if self.users_id and self.start_time:
@@ -110,6 +111,27 @@ class OvertimeApprovals(models.Model):
max_hours = 8.0
rec.duration = min(calculated_hours, max_hours)
employee = rec.user_id.employee_id
if not employee:
rec.duration = calculated_hours
continue
# 一个月加班时长不能超过36小时
first_day = rec.start_time.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
vacation_report = self.env['yuthon.vacation.reports'].search([
('employee_id', '=', employee.id),
('vacation_date', '==', first_day),
], limit=1)
cop_leave = vacation_report.cop_leave if vacation_report else 0.0
leave_hours = calculated_hours
if cop_leave + leave_hours > 36:
rec.duration = 0.0
message = f'本月已请假 {cop_leave} 小时,超过 36 小时上限!'
raise ValidationError(message)
else:
rec.duration = calculated_hours
@api.depends('start_time', 'end_time')
def _compute_weekday(self):
weekday_names = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
@@ -4,7 +4,7 @@
<field name="name">property.lease.contract.tree</field>
<field name="model">property.lease.contract</field>
<field name="arch" type="xml">
<tree string="合同审批" multi_edit="1">
<tree string="合同审批" multi_edit="1" >
<field name="code"/>
<field name="contract_code"/>
<field name="lessee_id"/>
@@ -370,6 +370,7 @@
<button name="button_lease_extension" type="object" class="btn-primary" string="续租"/>
<button name="button_lease_change" type="object" class="btn-primary" string="变更"/>
<button name="action_copy_record1" type="object" string="拆分" class="btn-primary"/>
<button name="unlink" string="删除" type="object" icon="fa-trash" groups="base.group_system" confirm="确定要删除选中的记录吗?"/>
</header>
<field name="property_name"/>
<field name="contract_code" decoration-danger="is_equal"/>