Merge pull request !991 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2024-12-29 02:25:02 +00:00
committed by Gitee
4 changed files with 26 additions and 24 deletions
@@ -17,6 +17,7 @@ from odoo.addons.web.controllers.home import Home as WebHome
MENU_BADGE_MODEL_FUNC_ENUM = {
'base.menu_action_res_users': {'model': 'file.preview.test', 'func': 'get_menu_badge_count'},
'yuthon_notice.yuthon_notice_my_menu': {'model': 'yuthon.notice', 'func': 'get_no_read_count'},
'soong_workflow.menu_workflow_approval_request_my': {'model': 'soong.workflow.record', 'func': 'get_no_read_count'},
}
@@ -12,6 +12,9 @@ class SoongWorkflowRecord(models.Model):
_description = "工作流记录"
_order = 'write_date'
def get_no_read_count(self):
return self.search_count([('approve_state', '=', 'pending'), ('reclaim_state', '=', False), ('users_ids', 'in', [self.env.user_id])])
@api.depends("res_model", "res_id")
def compute_name(self):
for rec in self:
@@ -56,7 +56,6 @@ class HrLeaveAllocation(models.Model):
emp_dict = {}
# 员工根据社保时间创建字典
for e in employees:
# [XSK] TODO 使用实际字段 -2024/11/15 17:00
key = e.compute_month
if emp_dict.get(key):
emp_dict[key].append(e)
@@ -66,15 +65,15 @@ class HrLeaveAllocation(models.Model):
plan_level = allocation.accrual_plan_id.level_ids.sorted(key=lambda x: x.added_value, reverse=True)
for emp_int, emp_list in emp_dict.items():
for level in plan_level:
level_month = 0
if level.added_value_type == 'day':
level_month = level.added_value // 30
if level.added_value_type == 'hour':
level_month = level.added_value // (30 * 24)
# level_month = 0
# if level.added_value_type == 'day':
level_month = level.added_value // 30
# if level.added_value_type == 'hour':
# level_month = level.added_value // (30 * 24)
if emp_int != 0 and emp_int >= level_month:
info_list = [{**item, 'number_of_days': level.start_count} for item in allocation._prepare_holiday_values(emp_list)]
info_list = [{**item, 'number_of_days': level.maximum_leave} for item in allocation._prepare_holiday_values(emp_list)]
allocation_vals.extend(info_list)
break
break
else:
super()._action_validate_create_childs()
if allocation_vals:
+15 -16
View File
@@ -19,19 +19,18 @@ class ResGroups(models.Model):
def users_add(self):
self.write({'users': [(4, user.user_id.id) for user in self.employee_ids]})
def get_department_employees(department_id):
valid_user_ids = set()
employee_ids = self.env['hr.employee'].search([('department_id', '=', department_id.id)])
valid_user_ids.update([user.user_id.id for user in employee_ids if user.user_id])
child_ids = self.env['hr.department'].search([('parent_id', '=', department_id.id)])
for child in child_ids:
valid_user_ids.update(get_department_employees(child))
return valid_user_ids
for department_id in self.department_ids:
valid_user_ids = get_department_employees(department_id)
if valid_user_ids:
self.write({'users': [(4, user_id) for user_id in valid_user_ids]})
for user_role in self.user_role_ids:
user_employee_ids = self.env['hr.employee'].search(['|', ('user_role_id', '=', user_role.id), ('user_role_ids', 'in', [user_role.id])])
self.write({'users': [(4, user.user_id.id) for user in user_employee_ids]})
# def get_department_employees(department_id):
# valid_user_ids = set()
# employee_ids = self.env['hr.employee'].search([('department_id', '=', department_id.id)])
# valid_user_ids.update([user.user_id.id for user in employee_ids if user.user_id])
# child_ids = self.env['hr.department'].search([('parent_id', '=', department_id.id)])
# for child in child_ids:
# valid_user_ids.update(get_department_employees(child))
# return valid_user_ids
# for department_id in self.department_ids:
# valid_user_ids = get_department_employees(department_id)
# if valid_user_ids:
# self.write({'users': [(4, user_id) for user_id in valid_user_ids]})
# for user_role in self.user_role_ids:
# user_employee_ids = self.env['hr.employee'].search(['|', ('user_role_id', '=', user_role.id), ('user_role_ids', 'in', [user_role.id])])
# self.write({'users': [(4, user.user_id.id) for user in user_employee_ids]})