diff --git a/yuthon_holiday/models/inherit_hr_leave_allocation.py b/yuthon_holiday/models/inherit_hr_leave_allocation.py index 79bad322a..42e40b6b7 100644 --- a/yuthon_holiday/models/inherit_hr_leave_allocation.py +++ b/yuthon_holiday/models/inherit_hr_leave_allocation.py @@ -218,30 +218,51 @@ class HrLeaveAllocation(models.Model): result = super(HrLeaveAllocation, self).action_validate() for leave in self: - if leave.holiday_status_id.name != '年假': - continue + if leave.holiday_status_id.name == '年假': + vacation_date = leave.date_from.replace(day=1) if leave.date_from else fields.Date.today().replace(day=1) + + reports_id = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', leave.employee_id.id), + ('vacation_date', '=', vacation_date) + ], limit=1) + + if reports_id: + leave_hours = leave.number_of_days_display * 8 + reports_id.write({ + 'valid_date': leave.date_to, + 'leave_ids': [(0, 0, { + 'vacation_id': reports_id.id, + 'update_type': 'add', + 'update_date': fields.Datetime.now(), + 'valid_date': leave.date_from, + 'update_lines': leave_hours, + 'text': '年假分配' + })] + }) + reports_id.update_line() - vacation_date = leave.date_from.replace(day=1) if leave.date_from else fields.Date.today().replace(day=1) - - reports_id = self.env['yuthon.vacation.reports'].search([ - ('employee_id', '=', leave.employee_id.id), - ('vacation_date', '=', vacation_date) - ], limit=1) - - if reports_id: - leave_hours = leave.number_of_days_display * 8 - reports_id.write({ - 'valid_date': leave.date_to, - 'leave_ids': [(0, 0, { - 'vacation_id': reports_id.id, - 'update_type': 'add', - 'update_date': fields.Datetime.now(), - 'valid_date': leave.date_from, - 'update_lines': leave_hours, - 'text': '年假分配' - })] - }) - reports_id.update_line() + elif leave.holiday_status_id.name == '补休': + vacation_date = leave.date_from.replace(day=1) if leave.date_from else fields.Date.today().replace(day=1) + + reports_id = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', leave.employee_id.id), + ('vacation_date', '=', vacation_date) + ], limit=1) + + if reports_id: + rest_hours = leave.number_of_days_display * 8 + reports_id.write({ + 'valid_date1': leave.date_to, + 'overtime_ids': [(0, 0, { + 'vacation_id': reports_id.id, + 'update_type': 'add', + 'update_date': fields.Datetime.now(), + 'valid_date': leave.date_to, + 'workday': rest_hours, + 'text': leave.name or '补休分配' + })] + }) + reports_id.update_line() return result diff --git a/yuthon_property_approval/__manifest__.py b/yuthon_property_approval/__manifest__.py index 8523f90bf..30db0c254 100644 --- a/yuthon_property_approval/__manifest__.py +++ b/yuthon_property_approval/__manifest__.py @@ -114,7 +114,9 @@ 'views/property_menu_all.xml', 'report/property_lease_contract_print_report.xml', 'report/property_lease_contract_print_templates.xml', - + 'report/property_supervising_approval_print_report.xml', + 'report/property_supervising_approval_print_templates.xml' + ], 'assets': { diff --git a/yuthon_property_approval/models/property_supervising_approval.py b/yuthon_property_approval/models/property_supervising_approval.py index 5f4307a4f..ec4503b78 100644 --- a/yuthon_property_approval/models/property_supervising_approval.py +++ b/yuthon_property_approval/models/property_supervising_approval.py @@ -58,6 +58,13 @@ class PropertySupervisingApproval(models.Model): } } + def action_print_property_supervising_approval(self): + """打印建设工程委托监理合同审批""" + self.ensure_one() + report_ref = self.env.ref('yuthon_property_approval.action_property_supervising_approval_print_report') + return report_ref.sudo().report_action(self) + + class SupervisingWayLine(models.Model): _name = 'supervising.way.line' _description = '施工支付方式' diff --git a/yuthon_property_approval/report/property_supervising_approval_print_report.xml b/yuthon_property_approval/report/property_supervising_approval_print_report.xml new file mode 100644 index 000000000..b88ebd74e --- /dev/null +++ b/yuthon_property_approval/report/property_supervising_approval_print_report.xml @@ -0,0 +1,22 @@ + + + + + Property Supervising Approval A4 + A4 + 5 + Portrait + + + + 建设工程委托监理合同审批 + + property.supervising.approval + qweb-pdf + yuthon_property_approval.property_supervising_approval_print_template + yuthon_property_approval.property_supervising_approval_print_template + '建设工程委托监理合同审批%s_%s_%s' % (object.display_name or object.code or '', object.users_id.name or '', ((object.log_ids.filtered(lambda l: l.name == '归档')[-1].lase_click_date or object.log_ids.filtered(lambda l: l.name == '归档')[-1].date_create).strftime('%Y-%m-%d') if object.log_ids.filtered(lambda l: l.name == '归档') else '')) + + report + + diff --git a/yuthon_property_approval/report/property_supervising_approval_print_templates.xml b/yuthon_property_approval/report/property_supervising_approval_print_templates.xml new file mode 100644 index 000000000..6ca3b1944 --- /dev/null +++ b/yuthon_property_approval/report/property_supervising_approval_print_templates.xml @@ -0,0 +1,148 @@ + + + + diff --git a/yuthon_property_approval/views/property_supervising_approval_views.xml b/yuthon_property_approval/views/property_supervising_approval_views.xml index 8a7b76613..4d13df750 100644 --- a/yuthon_property_approval/views/property_supervising_approval_views.xml +++ b/yuthon_property_approval/views/property_supervising_approval_views.xml @@ -18,6 +18,12 @@ property.supervising.approval
+
+