diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard.py b/soong_workflow/wizard/soong_workflow_comment_wizard.py index 2c2086d4b..2a0078dda 100644 --- a/soong_workflow/wizard/soong_workflow_comment_wizard.py +++ b/soong_workflow/wizard/soong_workflow_comment_wizard.py @@ -124,11 +124,10 @@ class SoongWorkflowCommentWizard(models.TransientModel): self.ensure_one() cx = self.env.context.copy() or {} record_id = self.env[self.res_model].search([('id', '=', self.res_id)]) - menu_id = self.env['ir.ui.menu'].search([('name', '=', record_id._description)]) for employee in self.employee_ids: action_id = self.env['ir.actions.act_window'].search([('res_model', '=', self.res_model)])[0] # url = f'https://oa.thtzjt.com/web?oauth_access_token={employee.user_id.oauth_access_token}&oauth_uid={employee.wecom_userid}#id={record_id.id}&cids=2&action={menu_id.action.id}&model={record_id._name}&view_type=form' - url = f'https://oa.thtzjt.com/web#id={record_id.id}&cids=2&action={menu_id.action.id}&model={record_id._name}&view_type=form&menu_id={menu_id.id}'# &menu_id={menu_id.id} + url = f'https://oa.thtzjt.com/web#id={record_id.id}&cids=2&action={action_id.id}&model={record_id._name}&view_type=form'# &menu_id={menu_id.id} self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id=employee.wecom_userid, title=record_id._description, diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index 334cfa813..2cb0b4110 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -316,6 +316,7 @@ class HolidaysRequestBatch(models.Model): name = fields.Char(string='标题') create_date = fields.Date(string='创建日期', default=fields.Datetime.today()) employee_id = fields.Many2one(related='users_id.employee_id', string="员工", store=True) + company_id = fields.Many2one(related='users_id.employee_id.company_id', string="公司", store=True) users_id = fields.Many2one('res.users', string="请假人", default=lambda self: self.env.user.id) department_id = fields.Many2one(related='users_id.employee_id.department_id', string="部门") user_role_id = fields.Many2one(related='users_id.employee_id.user_role_id', string="角色") @@ -365,29 +366,10 @@ class HolidaysRequestBatch(models.Model): self.leave_ids.action_validate() self.hour_leave_ids.action_validate() - @api.model_create_multi - def create(self, vals_list): - for vals in vals_list: - number_hours = 0 - company_id = vals.get('company_id') - if company_id: - company = self.env['res.company'].browse(company_id) - company.name = '天河物管' - if company.name == '天河物管': - if 'hour_leave_ids' in vals: - for leave_info in vals.get('hour_leave_ids', []): - hours_text = leave_info[2]['number_of_hours_text'] - match = re.search(r'\d+', hours_text) - if match: - number_hours += float(match.group()) - valid_hours = [2, 4, 6, 8] - if number_hours not in valid_hours: - raise ValidationError("休假时长必须为 2、4、6 或 8 小时才可以保存!") - return super(HolidaysRequestBatch, self).create(vals_list) - @api.constrains('hour_leave_ids') def _check_hour_leave_hours(self): """检查小时请假记录的小时数是否为0""" + number_hours = 0 for record in self: if record.hour_leave_ids and not record.leave_ids: for line in record.hour_leave_ids: @@ -396,6 +378,12 @@ class HolidaysRequestBatch(models.Model): match = re.search(r'(\d+(?:\.\d+)?)', line.number_of_hours_text or '') if match and float(match.group(1)) == 0: raise ValidationError(_("请假小时数不能为0!")) + if record.company_id.name == '天河物管': + match = re.search(r'(\d+(?:\.\d+)?)', line.number_of_hours_text or '') + number_hours += float(match.group(1)) + valid_hours = [2, 4, 6, 8] + if number_hours not in valid_hours: + raise ValidationError("休假时长必须为 2、4、6 或 8 小时才可以保存!") @api.onchange('leave_ids', 'hour_leave_ids', 'employee_id') def _onchange_leave_dates(self): @@ -422,11 +410,14 @@ class HolidaysRequestBatch(models.Model): if self.hour_leave_ids and not self.leave_ids: # 只按小时请假的情况 first_hour_leave = self.hour_leave_ids[0] - date_str = first_hour_leave.request_date_from.strftime('%Y%-m%-%d') - start_time = first_hour_leave.request_hour_from - end_time = first_hour_leave.request_hour_to + date_str = first_hour_leave.request_date_from.strftime('%Y-%m-%d') + time_options = dict(self._fields['request_hour_from_real'].selection) + start_time_key = first_hour_leave.request_hour_from + end_time_key = first_hour_leave.request_hour_to + start_time_formatted = time_options.get(start_time_key, start_time_key) + end_time_formatted = time_options.get(end_time_key, end_time_key) hours = first_hour_leave.number_of_hours_text if first_hour_leave.number_of_hours_text else 0 - title = f"{self.employee_id.name}的请假 {date_str},{start_time}~{end_time}" + title = f"{self.employee_id.name}的请假 {date_str},{start_time_formatted}~{end_time_formatted}" if hours: title += f",{hours}" self.name = title diff --git a/yuthon_hr_employee/views/yuthon_hr_department_views.xml b/yuthon_hr_employee/views/yuthon_hr_department_views.xml index ef7b6f3bb..1a55872d5 100644 --- a/yuthon_hr_employee/views/yuthon_hr_department_views.xml +++ b/yuthon_hr_employee/views/yuthon_hr_department_views.xml @@ -14,9 +14,9 @@ 20 True - - - + +