From ce0ead4da6a995342e3615b07ed717a6d297b7d6 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 12 May 2025 17:13:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?sf-=E5=B7=A5=E5=BA=8F-=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=B7=A5=E8=89=BA=E5=8F=AF=E9=80=89=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=8F=8A=E4=BA=A7=E5=93=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/sf_production_common.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/sf_manufacturing/models/sf_production_common.py b/sf_manufacturing/models/sf_production_common.py index 3c4ad8cf..8db07b53 100644 --- a/sf_manufacturing/models/sf_production_common.py +++ b/sf_manufacturing/models/sf_production_common.py @@ -9,7 +9,7 @@ class SfProductionProcessParameter(models.Model): _inherit = 'sf.production.process.parameter' service_products = fields.Many2one( 'product.template', - string='外协服务产品',compute='_compute_service_products',inverse='_inverse_service_products', + string='外协服务产品',compute='_compute_service_products', store=True ) outsourced_service_products = fields.One2many( @@ -25,15 +25,8 @@ class SfProductionProcessParameter(models.Model): def _compute_service_products(self): for record in self: # 假设取第一条作为主明细 - record.service_products = record.outsourced_service_products.ids if record.outsourced_service_products else False + record.service_products = record.outsourced_service_products[0].id if record.outsourced_service_products else False - def _inverse_service_products(self): - for record in self: - if record.service_products: - # 确保关联关系正确 - record.outsourced_service_products = record.service_products.ids if record.service_products else False - else: - record.outsourced_service_products = False def name_get(self): result = [] for record in self: From 750183263782a3ee08131a2bc202d4a24bc45e30 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 13 May 2025 10:01:58 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B0=83=E6=8B=A8=E5=8D=95=E5=B0=B1?= =?UTF-8?q?=E7=BB=AA=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/purchase_order.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index 7d5d6161..5b4a6e4b 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -121,16 +121,21 @@ class PurchaseOrder(models.Model): if not is_available: raise UserError('请先完成坯料入库') for production_id in productions: - picking_id = production_id.picking_ids.filtered( + work_ids = production_id.workorder_ids.filtered( + lambda wk: wk.state not in ['done', 'rework', 'cancel']) + if not work_ids: + continue + min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence) + if min_sequence_wk.is_subcontract: + picking_id = production_id.picking_ids.filtered( lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区') - move_out = picking_id.move_ids - for mo in move_out: - if mo.state != 'done': - mo.write({'state': 'assigned', 'production_id': False}) - if not mo.move_line_ids: - self.env['stock.move.line'].create( - mo.get_move_line(production_id,False)) - + move_out = picking_id.move_ids + for mo in move_out: + if mo.state != 'done': + mo.write({'state': 'assigned', 'production_id': False}) + if not mo.move_line_ids: + self.env['stock.move.line'].create( + mo.get_move_line(production_id, min_sequence_wk)) # product = self.env['mrp.production'].search([('product_id', '=', product_id)], limit=1) # match = re.search(r'(S\d{5}-\d)',product.name) # pass From a8e4c7d9a0f96bde61a5b9bd7aaba53481b704d5 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 13 May 2025 10:24:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=B0=83=E6=8B=A8=E5=8D=95=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index df303c9c..f8475338 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1553,7 +1553,8 @@ class ResMrpWorkOrder(models.Model): lambda wo: wo.is_subcontract == True and wo.state != 'cancel').sorted('sequence') if self == subcontract_workorders[-1]: # 给下一个库存移动就绪 - self.move_subcontract_workorder_ids[0].move_dest_ids._action_done() + if self.move_subcontract_workorder_ids: + self.move_subcontract_workorder_ids[0].move_dest_ids._action_done() # self.production_id.button_mark_done() tem_date_planned_finished = record.date_planned_finished tem_date_finished = record.date_finished