From d07e1e4917882cff6a02972611041a582cd7e6d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Tue, 2 Jun 2026 16:06:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A4=90=E9=A5=AE=E4=BA=BA=E5=91=98=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_ai_agent/models/ai_token_usage.py | 4 ++++ yuthon_catering/wizard/catering_conf_change_wizard.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/yuthon_ai_agent/models/ai_token_usage.py b/yuthon_ai_agent/models/ai_token_usage.py index 173968fdb..45f36b434 100644 --- a/yuthon_ai_agent/models/ai_token_usage.py +++ b/yuthon_ai_agent/models/ai_token_usage.py @@ -43,6 +43,10 @@ class AiTokenUsageSummary(models.Model): total_tokens = fields.Integer(string='总 Token', readonly=True) def init(self): + from odoo.tools import table_exists + # 依赖表 ai_token_usage 可能尚未创建,跳过 + if not table_exists(self.env.cr, 'ai_token_usage'): + return self.env.cr.execute(""" DROP VIEW IF EXISTS ai_token_usage_summary; CREATE OR REPLACE VIEW ai_token_usage_summary AS ( diff --git a/yuthon_catering/wizard/catering_conf_change_wizard.py b/yuthon_catering/wizard/catering_conf_change_wizard.py index 525adb1af..be72e311b 100644 --- a/yuthon_catering/wizard/catering_conf_change_wizard.py +++ b/yuthon_catering/wizard/catering_conf_change_wizard.py @@ -39,6 +39,11 @@ class CateringConfChangeWizard(models.TransientModel): def action_confirm(self): """确认:旧记录加失效日期,生成新记录""" + # 检查员工列表是否有变化,无变化则不允许生成新记录 + if set(self.conf_id.employee_ids.ids) == set(self.employee_ids.ids): + from odoo.exceptions import ValidationError + raise ValidationError('员工列表未发生变化,无需生成新记录。\n' + '如需放弃操作,请点击下方"取消"按钮。') today = fields.Date.today() note = self._compute_change_note() from odoo.models import Model