From ab5b4c477f6f71e361154c15acc0e35fdad170cb Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 30 Dec 2024 09:33:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=9B=B6=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E7=A7=B0,=E9=9B=B6=E4=BB=B6=E5=9B=BE=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quality_control/models/quality.py | 41 +++++++++++++++++++++++++ quality_control/views/quality_views.xml | 10 ++++++ 2 files changed, 51 insertions(+) diff --git a/quality_control/models/quality.py b/quality_control/models/quality.py index ebe73384..7356590a 100644 --- a/quality_control/models/quality.py +++ b/quality_control/models/quality.py @@ -152,6 +152,34 @@ class QualityCheck(models.Model): is_lot_tested_fractionally = fields.Boolean(related='point_id.is_lot_tested_fractionally') testing_percentage_within_lot = fields.Float(related="point_id.testing_percentage_within_lot") product_tracking = fields.Selection(related='product_id.tracking') + quality_check_type = fields.Selection([ + ('采购入库检', '采购入库检'), + ('客供料入库检', '客供料入库检'), + ('退货入库检', '退货入库检'), + ('生产入库检', '生产入库检'), + ('外协入库检', '外协入库检'), + ('成品发货检', '成品发货检'), + ('工序外协发货检', '工序外协发货检'), + ('委外坯料发货检', '委外坯料发货检')], string='类型', compute='_compute_quality_check_type', store=True) + + @api.depends('picking_id') + def _compute_quality_check_type(self): + for check in self: + if check.picking_id: + picking_type = check.picking_id.picking_type_id.sequence_code + type_mapping = { + 'IN': '采购入库检', + 'DL': '客供料入库检', + 'RET': '退货入库检', + 'SFP': '生产入库检', + 'OCIN': '外协入库检', + 'OUT': '成品发货检', + 'OCOUT': '工序外协发货检', + 'RES': '委外坯料发货检', + } + check.quality_check_type = type_mapping.get(picking_type, False) + else: + check.quality_check_type = False @api.depends('measure_success') def _compute_warning_message(self): @@ -294,6 +322,19 @@ class QualityAlert(models.Model): _inherit = "quality.alert" title = fields.Char('Title') + part_number = fields.Char(string='零件图号', compute='_compute_part_info', store=True) + part_name = fields.Char(string='零件名称', compute='_compute_part_info', store=True) + + @api.depends('product_id', 'picking_id') + def _compute_part_info(self): + for alert in self: + if alert.product_tmpl_id.categ_id.name == '成品': + alert.part_number = alert.product_id.part_number + alert.part_name = alert.product_id.part_name + elif alert.product_id.categ_id.name == '坯料': + if alert.picking_id.move_ids_without_package: + alert.part_number = alert.picking_id.move_ids_without_package[0].part_number + alert.part_name = alert.picking_id.move_ids_without_package[0].part_name def action_see_check(self): return { diff --git a/quality_control/views/quality_views.xml b/quality_control/views/quality_views.xml index 8e5af75a..3c483a9f 100644 --- a/quality_control/views/quality_views.xml +++ b/quality_control/views/quality_views.xml @@ -90,6 +90,8 @@ + + @@ -150,6 +152,10 @@ + + + + @@ -446,6 +452,10 @@ + + + +