From 4c0f9cfb39973ab4b87dd544c02c76078a6c5a9a Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 13 May 2025 11:04:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A4=96=E5=8D=8F=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E9=9B=B6=E4=BB=B6=E5=9B=BE=E5=8F=B7=E9=9B=B6=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/purchase_order.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index 5b4a6e4b..056d822d 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -226,6 +226,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 From 8e726e1bf61a888a51fb3f4d1c9e0527ce8cbe4e Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 13 May 2025 15:01:54 +0800 Subject: [PATCH 2/3] =?UTF-8?q?sf-=E5=88=B6=E9=80=A0-=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E5=A4=96=E5=8D=8F=E7=9A=84=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E5=90=8E=EF=BC=8C=E5=A4=96=E5=8D=8F=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E6=8B=A8=E5=8D=95=E7=9A=84=E4=BD=9C=E4=B8=9A=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E7=9A=84=E9=A2=84=E7=95=99=E6=95=B0=E9=87=8F=E8=B7=9F?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=95=B0=E9=87=8F=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/stock.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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, From 3148ce5a1511b358209b95e4b95cca915887ce7d Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 13 May 2025 15:49:02 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A4=96=E5=8D=8F=E8=B0=83=E6=8B=A8?= =?UTF-8?q?=E5=8D=95=E4=B8=8D=E5=90=8C=E4=BA=A7=E5=93=81=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E6=8B=A8=E5=8D=95=E6=B7=B7=E5=90=88=E5=88=B0=E4=B8=80=E8=B5=B7?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 7 +++++++ sf_manufacturing/models/purchase_order.py | 2 ++ 2 files changed, 9 insertions(+) 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 056d822d..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: