diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index f8475338..ee1c0c75 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -502,6 +502,7 @@ class ResMrpWorkOrder(models.Model): # if technology_design.is_auto is False: # domain = [('origin', '=', self.production_id.name)] # else: + purchase_orders_id = self._get_surface_technics_purchase_ids() result = { "type": "ir.actions.act_window", @@ -1297,6 +1298,8 @@ class ResMrpWorkOrder(models.Model): move_out = picking_id.move_ids # move_out = workorder.move_subcontract_workorder_ids[1] for mo in move_out: + if workorder.production_id.bom_id.bom_line_ids.product_id.id != move_out.product_id: + continue if mo.state != 'done': mo.write({'state': 'assigned', 'production_id': False}) if not mo.move_line_ids: @@ -1338,6 +1341,8 @@ class ResMrpWorkOrder(models.Model): wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区') move_out = picking_id.move_ids for mo in move_out: + if workorder.production_id.bom_id.bom_line_ids.product_id.id != move_out.product_id: + continue if mo.state != 'done': mo.write({'state': 'assigned', 'production_id': False}) if not mo.move_line_ids: @@ -1421,6 +1426,8 @@ class ResMrpWorkOrder(models.Model): # [('barcode', 'ilike', 'VL-SPOC')]).id), # ('origin', '=', self.production_id.name), ('state', 'not in', ['cancel', 'done'])]) for mo in move_out: + if self.production_id.bom_id.bom_line_ids.product_id.id != move_out.product_id: + continue if mo.state != 'done': mo.write({'state': 'assigned', 'production_id': False}) if not mo.move_line_ids: diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index 5b4a6e4b..d0d716d4 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -131,6 +131,8 @@ class PurchaseOrder(models.Model): lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区') move_out = picking_id.move_ids for mo in move_out: + if production_id.bom_id.bom_line_ids.product_id.id != move_out.product_id: + continue if mo.state != 'done': mo.write({'state': 'assigned', 'production_id': False}) if not mo.move_line_ids: @@ -226,6 +228,24 @@ class PurchaseOrderLine(models.Model): ) record.part_number = filtered_order_line.product_id.part_number record.part_name = filtered_order_line.product_id.part_name + elif record.order_id.purchase_type == 'consignment': + product_name = '' + match = re.search(r'(S\d{5}-\d)', record.related_product.name) + # 如果匹配成功,提取结果 + if match: + product_name = match.group(0) + sale_order_name = '' + match_sale = re.search(r'S(\d+)', record.related_product.name) + if match_sale: + sale_order_name = match_sale.group(0) + sale_order = self.env['sale.order'].sudo().search( + [('name', '=', sale_order_name)]) + if sale_order: + filtered_order_line = sale_order.order_line.filtered( + lambda order_line: re.search(f'{product_name}$', order_line.product_id.name) + ) + record.part_number = filtered_order_line.product_id.part_number + record.part_name = filtered_order_line.product_id.part_name else: record.part_number = record.product_id.part_number record.part_name = record.product_id.part_name diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 1b60e68a..1b7f4e42 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -930,6 +930,8 @@ class ReStockMove(models.Model): } def get_move_line(self, production_id, sorted_workorders): + # if not self.move_ids[0].product_id.single_manufacturing and self.move_ids[0].product_id.tracking == 'none': + qty = production_id.product_qty return { 'move_id': self.id, 'product_id': self.product_id.id, @@ -937,7 +939,7 @@ class ReStockMove(models.Model): 'location_id': self.picking_id.location_id.id, 'location_dest_id': self.picking_id.location_dest_id.id, 'picking_id': self.picking_id.id, - 'reserved_uom_qty': 1.0, + 'reserved_uom_qty': qty, 'lot_id': production_id.move_line_raw_ids.lot_id.id, 'company_id': self.env.company.id, # 'workorder_id': '' if not sorted_workorders else sorted_workorders.id,