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