diff --git a/yuthon_base/__manifest__.py b/yuthon_base/__manifest__.py index d1a2a484a..00b5706a4 100644 --- a/yuthon_base/__manifest__.py +++ b/yuthon_base/__manifest__.py @@ -8,6 +8,7 @@ 'license': 'LGPL-3', 'data': [ 'security/ir.model.access.csv', + 'data/res_users_data.xml', 'views/system_version_views.xml', 'views/system_logs_views.xml', 'views/ir_cron_act_views.xml', @@ -25,7 +26,7 @@ ] }, 'demo': [], - 'depends': ['hr', 'mail', 'base', 'survey'], + 'depends': ['hr', 'mail', 'base', 'survey', 'account'], 'installable': True, 'application': True, } diff --git a/yuthon_base/data/res_users_data.xml b/yuthon_base/data/res_users_data.xml new file mode 100644 index 000000000..aba4c936f --- /dev/null +++ b/yuthon_base/data/res_users_data.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/yuthon_base/models/__init__.py b/yuthon_base/models/__init__.py index 190142723..19457e29a 100644 --- a/yuthon_base/models/__init__.py +++ b/yuthon_base/models/__init__.py @@ -7,4 +7,6 @@ from . import yuthon_timed_tasks from . import yuthon_phone_lottery from . import res_partner from . import base_month_year -from . import system_logs \ No newline at end of file +from . import system_logs +from . import res_users +from . import mail_thread \ No newline at end of file diff --git a/yuthon_base/models/mail_thread.py b/yuthon_base/models/mail_thread.py new file mode 100644 index 000000000..d3cbfd757 --- /dev/null +++ b/yuthon_base/models/mail_thread.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +# from odoo import models +# import json +# +# +# class MailThread(models.AbstractModel): +# _inherit = "mail.thread" +# +# def _notify_by_web_push(self, message, recipients_data, msg_vals=False): +# """ +# 重写 Web Push 通知方法,强制使用异步发送方式, +# 避免同步发送导致的请求阻塞问题(如加班审批转交按钮反应慢)。 +# """ +# msg_vals = dict(msg_vals or {}) +# partner_ids = self._extract_partner_ids_for_notifications(message, msg_vals, recipients_data) +# if not partner_ids: +# return +# +# partner_devices_sudo = self.env['mail.partner.device'].sudo() +# devices = partner_devices_sudo.search([ +# ('partner_id', 'in', partner_ids) +# ]) +# if not devices: +# return +# +# ir_parameter_sudo = self.env['ir.config_parameter'].sudo() +# vapid_private_key = ir_parameter_sudo.get_param('mail.web_push_vapid_private_key') +# vapid_public_key = ir_parameter_sudo.get_param('mail.web_push_vapid_public_key') +# if not vapid_private_key or not vapid_public_key: +# return +# +# payload = self._notify_by_web_push_prepare_payload(message, msg_vals=msg_vals) +# payload = self._truncate_payload(payload) +# +# # 强制使用异步发送方式 +# # 不再同步调用 push_to_end_point,避免阻塞请求 +# self.env['mail.notification.web.push'].sudo().create([{ +# 'user_device': device.id, +# 'payload': json.dumps(payload), +# } for device in devices]) +# self.env.ref('mail.ir_cron_web_push_notification')._trigger() diff --git a/yuthon_base/models/res_users.py b/yuthon_base/models/res_users.py new file mode 100644 index 000000000..1b6258354 --- /dev/null +++ b/yuthon_base/models/res_users.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +import logging +from odoo import api, models + +_logger = logging.getLogger(__name__) + + +class ResUsers(models.Model): + _inherit = 'res.users' + + @api.model_create_multi + def create(self, vals_list): + _logger.info("====== [yuthon_base] res.users.create 被调用,准备创建 %d 个用户 ======", len(vals_list)) + users = super().create(vals_list) + # 新建用户后确保移除财务和薪资管理员权限组 + groups_to_remove = [] + group_refs = [ + 'account.group_account_manager', + 'account.group_account_invoice', + 'hr_payroll.group_hr_payroll_manager', + ] + for ref in group_refs: + group = self.env.ref(ref, raise_if_not_found=False) + if group: + groups_to_remove.append((3, group.id)) + _logger.info("====== [yuthon_base] 找到组 %s (id=%d),将移除 ======", ref, group.id) + else: + _logger.warning("====== [yuthon_base] 未找到组 %s ======", ref) + if groups_to_remove: + _logger.info("====== [yuthon_base] 对用户 %s 移除 %d 个组 ======", users.mapped('login'), len(groups_to_remove)) + users.sudo().write({'groups_id': groups_to_remove}) + _logger.info("====== [yuthon_base] res.users.create 完成 ======") + return users diff --git a/yuthon_catering/models/yuthon_catering_conf.py b/yuthon_catering/models/yuthon_catering_conf.py index 03c06d6a6..2ccbed8f3 100644 --- a/yuthon_catering/models/yuthon_catering_conf.py +++ b/yuthon_catering/models/yuthon_catering_conf.py @@ -12,6 +12,7 @@ class YuthonCateringConf(models.Model): effective_date = fields.Date(string='生效日期') expiry_date = fields.Date(string='失效日期') is_active = fields.Integer(string='是否生效', compute='_compute_is_active', store=True) + note = fields.Text(string='备注') @api.depends('employee_ids') def _compute_employee_count(self): diff --git a/yuthon_catering/views/yuthon_catering_conf.xml b/yuthon_catering/views/yuthon_catering_conf.xml index c5d514e67..2a4e32a53 100644 --- a/yuthon_catering/views/yuthon_catering_conf.xml +++ b/yuthon_catering/views/yuthon_catering_conf.xml @@ -12,6 +12,7 @@ +