From aea158de4154eb87880d31f443b79603f08068c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 8 May 2025 20:32:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A8=E6=A3=80=E5=8D=95=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E7=BA=A6=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_quality/models/quality.py | 30 ++++++++++++++++++++++++- sf_quality/views/quality_check_view.xml | 4 +++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/sf_quality/models/quality.py b/sf_quality/models/quality.py index 8ef2e3a9..d05d2eaa 100644 --- a/sf_quality/models/quality.py +++ b/sf_quality/models/quality.py @@ -155,4 +155,32 @@ class QualityCheck(models.Model): qty_line = fields.Float('数量', store=True) qty_test_failed = fields.Float('不合格数') qty_to_test = fields.Float('应检', store=True) - qty_tested = fields.Float('已检') \ No newline at end of file + qty_tested = fields.Float('已检') + + @api.onchange('qty_line', 'qty_test_failed', 'qty_to_test', 'qty_tested') + def _onchage_qty(self): + for record in self: + if record.qty_line and record.qty_to_test and record.qty_to_test > record.qty_line: + record.qty_to_test = record.qty_line + return { + 'warning': { + 'title': '警告', + 'message': '待检数量不能超过总数量' + } + } + if record.qty_to_test and record.qty_tested and record.qty_tested > record.qty_to_test: + record.qty_tested = record.qty_to_test + return { + 'warning': { + 'title': '警告', + 'message': '已检数量不能超过待检数量' + } + } + if record.qty_tested and record.qty_test_failed and record.qty_test_failed > record.qty_tested: + record.qty_test_failed = record.qty_tested + return { + 'warning': { + 'title': '警告', + 'message': '不合格数量不能超过已检数量' + } + } \ No newline at end of file diff --git a/sf_quality/views/quality_check_view.xml b/sf_quality/views/quality_check_view.xml index 6deb8eb9..655cc498 100644 --- a/sf_quality/views/quality_check_view.xml +++ b/sf_quality/views/quality_check_view.xml @@ -96,6 +96,7 @@ 0 + 1 {'invisible': ['|', '&', ('move_line_id', '=', False), ('workorder_id', '=', False), '|', ('measure_on', '!=', 'move_line'), ('is_lot_tested_fractionally', '=', False)]} @@ -105,13 +106,14 @@ 0 + 1