diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 57fb443f..ffea3b36 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -754,7 +754,7 @@ class ReStockMove(models.Model): if move.product_id.categ_id.type == '成品': move.part_number = move.product_id.part_number move.part_name = move.product_id.part_name - elif move.product_id.categ_id.type == '坯料' or move.product_id.categ_id.type == '原材料': + elif move.product_id.categ_id.type == '坯料': product_name = '' match = re.search(r'(S\d{5}-\d)', move.product_id.name) # 如果匹配成功,提取结果 @@ -773,6 +773,34 @@ class ReStockMove(models.Model): lambda production: re.search(f'{product_name}$', production.product_id.name) ) + if filtered_order_line: + move.part_number = filtered_order_line.part_number + move.part_name = filtered_order_line.part_name + elif move.product_id.categ_id.type == '原材料': + production_id = move.production_id or move.raw_material_production_id + if not production_id: + if not move.origin: + continue + production_id = self.env['mrp.production'].sudo().search( + [('name', '=', move.origin)],limit=1) + product_name = '' + match = re.search(r'(S\d{5}-\d)', production_id.product_id.name) + # 如果匹配成功,提取结果 + if match: + product_name = match.group(0) + if move.picking_id.sale_order_id: + sale_order = move.picking_id.sale_order_id + else: + sale_order_name = '' + match = re.search(r'(S\d+)', production_id.product_id.name) + if match: + sale_order_name = match.group(0) + sale_order = self.env['sale.order'].sudo().search( + [('name', '=', sale_order_name)]) + filtered_order_line = sale_order.order_line.filtered( + lambda production: re.search(f'{product_name}$', production.product_id.name) + ) + if filtered_order_line: move.part_number = filtered_order_line.part_number move.part_name = filtered_order_line.part_name diff --git a/sf_quality/models/quality.py b/sf_quality/models/quality.py index a0adf70f..9d762e4e 100644 --- a/sf_quality/models/quality.py +++ b/sf_quality/models/quality.py @@ -35,8 +35,8 @@ class QualityCheck(models.Model): [("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"), ("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因") detailed_reason = fields.Text('详细原因') - machining_drawings = fields.Binary('2D加工图纸', related='workorder_id.machining_drawings') - quality_standard = fields.Binary('质检标准', related='workorder_id.quality_standard') + machining_drawings = fields.Binary('2D加工图纸', related='product_id.machining_drawings') + quality_standard = fields.Binary('质检标准', related='product_id.quality_standard') operation_id = fields.Many2one('mrp.routing.workcenter', '作业', store=True, compute='_compute_operation_id') is_inspect = fields.Boolean('需送检', related='point_id.is_inspect')