From ba5f564ce6d814d997909bc73501a5360fe3fdea Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Sat, 24 May 2025 17:43:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_issue/models/issue_approval.py | 12 ++-- yuthon_notice/controllers/__init__.py | 23 ------- .../controllers/excel_report_designer.py | 60 ------------------- yuthon_trade/models/yuthon_task_approval.py | 6 +- yuthon_trade/models/yuthon_task_setting.py | 4 ++ .../views/yuthon_task_setting_views.xml | 3 + 6 files changed, 16 insertions(+), 92 deletions(-) delete mode 100644 yuthon_notice/controllers/__init__.py delete mode 100644 yuthon_notice/controllers/excel_report_designer.py diff --git a/yuthon_issue/models/issue_approval.py b/yuthon_issue/models/issue_approval.py index 894a9f149..8ff6244de 100644 --- a/yuthon_issue/models/issue_approval.py +++ b/yuthon_issue/models/issue_approval.py @@ -35,12 +35,12 @@ class IssueApproval(models.Model): name_title = fields.Char(default=_get_default_name_title) - @api.onchange('issue_approval_ids') - def _onchange_issue_approval_ids(self): - if self.issue_approval_ids: - self.issue_display = '\n'.join([issue_library.name for issue_library in self.issue_approval_ids]) - self.decision_display = '\n'.join([issue_library.approval_decision_sequence for issue_library in self.issue_approval_ids]) - + @api.constrains("issue_approval_ids") + def _check_issue_approval_ids(self): + for rec in self: + if rec.issue_approval_ids: + self.issue_display ='\n'.join([issue_library.issue_library_id.name for issue_library in self.issue_approval_ids]) + self.decision_display ='\n'.join([issue_library.approval_decision_sequence for issue_library in self.issue_approval_ids]) class IssueApprovalLine(models.Model): _name = 'issue.approval.line' diff --git a/yuthon_notice/controllers/__init__.py b/yuthon_notice/controllers/__init__.py deleted file mode 100644 index de2224d4a..000000000 --- a/yuthon_notice/controllers/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -################################################################################ -# -# Cybrosys Technologies Pvt. Ltd. -# -# Copyright (C) 2024-TODAY Cybrosys Technologies (). -# Author: Cybrosys Techno Solutions () -# -# This program is free software: you can modify -# it under the terms of the GNU Affero General Public License (AGPL) as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -################################################################################ -from . import excel_report_designer diff --git a/yuthon_notice/controllers/excel_report_designer.py b/yuthon_notice/controllers/excel_report_designer.py deleted file mode 100644 index 6ae719f16..000000000 --- a/yuthon_notice/controllers/excel_report_designer.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -################################################################################ -# -# Cybrosys Technologies Pvt. Ltd. -# -# Copyright (C) 2024-TODAY Cybrosys Technologies (). -# Author: Cybrosys Techno Solutions () -# -# This program is free software: you can modify -# it under the terms of the GNU Affero General Public License (AGPL) as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -################################################################################ -import json -from odoo import http -from odoo.http import content_disposition, request -from odoo.tools import html_escape - - -class ReportPrintController(http.Controller): - - @http.route('/print_notice_report', type='http', auth='user') - def print_notice_report(self): - """ - 控制器方法,用于触发打印通知公告报表 - """ - # 获取 report.generator 模型的对象(假设存在该模型) - report_generator = request.env['report.generator'].sudo().create({}) - # 调用 print_fixed_report 方法 - action = report_generator.print_fixed_report() - # 提取报表数据 - report_data = action.get('data', {}) - options = json.loads(report_data.get('options', '{}')) - report_model_name = report_data.get('model') - output_format = report_data.get('output_format') - report_name = report_data.get('report_name') - - # 获取报表模型 - report_model = request.env[report_model_name] - # 创建响应对象 - response = request.make_response( - None, - headers=[ - ('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' if output_format == 'xlsx' else 'application/pdf'), - ('Content-Disposition', f'attachment; filename="{report_name}.{output_format}"') - ] - ) - # 调用报表模型的生成报表方法 - if hasattr(report_model, 'get_xlsx_report'): - report_model.get_xlsx_report(options, response) - return response \ No newline at end of file diff --git a/yuthon_trade/models/yuthon_task_approval.py b/yuthon_trade/models/yuthon_task_approval.py index be807edb9..8c390989e 100644 --- a/yuthon_trade/models/yuthon_task_approval.py +++ b/yuthon_trade/models/yuthon_task_approval.py @@ -26,9 +26,9 @@ class YuthonTaskApproval(models.Model): active = fields.Boolean('Active', default=True, tracking=True) work_end = fields.Boolean(string="结束") duration = fields.Float(string="时长", store=True, compute='_compute_duration') - concentration = fields.Float(string="浓度") - warning_value = fields.Float(string="警戒值") - number = fields.Integer(string="数量") + concentration = fields.Float(related="task_id.concentration", string="浓度") + warning_value = fields.Float(related="task_id.warning_value", string="警戒值") + number = fields.Integer(related="task_id.number", string="数量") def _get_default_name_title(self): diff --git a/yuthon_trade/models/yuthon_task_setting.py b/yuthon_trade/models/yuthon_task_setting.py index e941d72f9..f346ccb72 100644 --- a/yuthon_trade/models/yuthon_task_setting.py +++ b/yuthon_trade/models/yuthon_task_setting.py @@ -11,6 +11,10 @@ class YuthonTaskSetting(models.Model): standard = fields.Text(string='标准') inspector = fields.Text(string='工作要求') scope = fields.Char(string='发放范围') + concentration = fields.Float(string="浓度") + warning_value = fields.Float(string="警戒值") + number = fields.Integer(string="数量") + class YuthonStackPosition(models.Model): _name = 'yuthon.stack.position' diff --git a/yuthon_trade/views/yuthon_task_setting_views.xml b/yuthon_trade/views/yuthon_task_setting_views.xml index db228c1ec..1ac0e580f 100644 --- a/yuthon_trade/views/yuthon_task_setting_views.xml +++ b/yuthon_trade/views/yuthon_task_setting_views.xml @@ -9,6 +9,9 @@ + + +