diff --git a/quality_control/models/quality.py b/quality_control/models/quality.py index 8670005d..df4a11b2 100644 --- a/quality_control/models/quality.py +++ b/quality_control/models/quality.py @@ -477,8 +477,8 @@ class QualityCheck(models.Model): if not self.report_content: raise UserError(_('当前质检单没有出厂检验报告,请先发布报告')) - if not self.part_number: - raise UserError(_('零件图号不能为空')) + if not self.product_id.model_name: + raise UserError(_('产品模型名称为空')) if not self.picking_id or not self.picking_id.origin: raise UserError(_('无法找到相关的调拨单或来源单据')) @@ -490,7 +490,7 @@ class QualityCheck(models.Model): # 准备请求数据 payload = { "order_ref": order_ref, - "part_number": self.part_number, + "model_name": self.product_id.model_name, "report_file": self.report_content.decode('utf-8') if isinstance(self.report_content, bytes) else self.report_content } @@ -541,12 +541,18 @@ class QualityCheck(models.Model): """ # 获取订单号(从调拨单的来源字段获取) order_ref = self.picking_id.retrospect_ref + + if not order_ref: + raise UserError(_('无法找到相关的调拨单或来源单据')) + if not self.product_id.model_name: + raise UserError(_('产品模型名称为空')) + try: # 准备请求数据 payload = { "order_ref": order_ref, - "part_number": self.part_number + "model_name": self.product_id.model_name } # 将Python字典转换为JSON字符串 diff --git a/quality_control/static/src/binary/出厂检验报告上传模版.xlsx b/quality_control/static/src/binary/出厂检验报告上传模版.xlsx index cd43894a..181e921f 100644 Binary files a/quality_control/static/src/binary/出厂检验报告上传模版.xlsx and b/quality_control/static/src/binary/出厂检验报告上传模版.xlsx differ diff --git a/sf_quality/models/custom_quality.py b/sf_quality/models/custom_quality.py index 9fdb2920..0049a99a 100644 --- a/sf_quality/models/custom_quality.py +++ b/sf_quality/models/custom_quality.py @@ -26,4 +26,12 @@ class SfQualityPoint(models.Model): if self.test_type_id.name == '出厂检验报告': if self.measure_on != 'product': raise ValidationError('出厂检验报告的测量对象必须为产品') + + @api.onchange('measure_on') + def _onchange_measure_on(self): + """ + 如果measure_on的值变了,则清空test_type_id的值 + """ + if self.measure_on != 'product': + self.test_type_id = False