From 5c5606749ab5f4423ea087309f48395d30e1163c Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 15 Nov 2024 18:06:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=B6=E9=80=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 18 ++++--- sf_manufacturing/models/stock.py | 2 +- .../production_technology_re_adjust_wizard.py | 5 +- sf_sale/models/sale_order.py | 52 +++++++++---------- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 0fe1a6b2..d2374541 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -647,9 +647,11 @@ class MrpProduction(models.Model): for i in range(len(sorted_workorders) - 1): if m == 0: is_pick = False + logging.info(sorted_workorders[i].sequence) + logging.info(sorted_workorders[i + 1].sequence) + logging.info(sorted_workorders[i + 1].sequence - 1) if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \ - sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \ - sorted_workorders[i].id == sorted_workorders[i + 1].id - 1: + sorted_workorders[i].sequence == sorted_workorders[i + 1].sequence - 1: if sorted_workorders[i] not in consecutive_workorders: consecutive_workorders.append(sorted_workorders[i]) consecutive_workorders.append(sorted_workorders[i + 1]) @@ -659,7 +661,7 @@ class MrpProduction(models.Model): if m == len(consecutive_workorders) - 1 and m != 0: self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production) - self.env['purchase.order'].get_purchase_order(consecutive_process_parameters, + self.env['purchase.order'].get_purchase_order(consecutive_workorders, production, product_id_to_production_names) if sorted_workorders[i] in consecutive_workorders: @@ -670,13 +672,13 @@ class MrpProduction(models.Model): if is_pick is False: self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production) - self.env['purchase.order'].get_purchase_order(consecutive_process_parameters, + self.env['purchase.order'].get_purchase_order(sorted_workorders[i], production, product_id_to_production_names) if m == len(consecutive_workorders) - 1 and m != 0: self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production) - self.env['purchase.order'].get_purchase_order(consecutive_process_parameters, + self.env['purchase.order'].get_purchase_order(consecutive_workorders, production, product_id_to_production_names) if sorted_workorders[i] in consecutive_workorders: @@ -685,18 +687,18 @@ class MrpProduction(models.Model): m = 0 if m == len(consecutive_workorders) - 1 and m != 0: self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production) - self.env['purchase.order'].get_purchase_order(consecutive_process_parameters, + self.env['purchase.order'].get_purchase_order(consecutive_workorders, production, product_id_to_production_names) if is_pick is False and m == 0: if len(sorted_workorders) == 1: self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production) - self.env['purchase.order'].get_purchase_order(consecutive_process_parameters, + self.env['purchase.order'].get_purchase_order(sorted_workorders, production, product_id_to_production_names) else: self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production) - self.env['purchase.order'].get_purchase_order(consecutive_process_parameters, + self.env['purchase.order'].get_purchase_order(sorted_workorders[i], production, product_id_to_production_names) diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index cd06db48..5eb03ae3 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -710,7 +710,7 @@ class ReStockMove(models.Model): return { 'name': self.env['stock.picking']._get_name_Res(rescode), 'origin': item.name, - 'surface_technics_parameters_id': sorted_workorders.surface_technics_parameters_id.id, + # 'surface_technics_parameters_id': sorted_workorders.surface_technics_parameters_id.id, 'company_id': self.mapped('company_id').id, 'user_id': False, 'move_type': self.mapped('group_id').move_type or 'direct', diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index faf4143c..93cd9db1 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -96,15 +96,14 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): workorders_values.append( self.env['mrp.workorder'].json_workorder_str(special.production_id, special)) special.production_id.write({'workorder_ids': workorders_values}) - special.production_id.get_subcontract_pick() else: if len(workorder.blocked_by_workorder_ids) > 1: if workorder.sequence == 1: workorder.blocked_by_workorder_ids = None else: workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0] - special.production_id._reset_work_order_sequence() - special.production_id.get_subcontract_pick_purchase() + productions._reset_work_order_sequence() + productions.get_subcontract_pick_purchase() for item in productions: workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted( key=lambda a: a.sequence) diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index b753a5b0..0c777766 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -244,31 +244,31 @@ class RePurchaseOrder(models.Model): production_process = product_id_to_production_names.get( production.product_id.id) for pp in consecutive_process_parameters: - if pp.gain_way == '外协': - server_template = self.env['product.template'].search( - [('server_product_process_parameters_id', '=', pp.id), - ('detailed_type', '=', 'service')]) - purchase_order_line = self.env['purchase.order.line'].search( - [('product_id', '=', server_template.product_variant_id.id), - ('product_qty', '=', len(production_process))], limit=1, order='id desc') - if not purchase_order_line: - server_product_process.append((0, 0, { - 'product_id': server_template.product_variant_id.id, - 'product_qty': len(production_process), - 'product_uom': server_template.uom_id.id - })) - else: - for item in purchase_order_line: - if production.name in production_process: - purchase_order = self.env['purchase.order'].search( - [('state', '=', 'draft'), ('origin', '=', ','.join(production_process)), - ('id', '=', item.order_id.id)]) - if not purchase_order: - server_product_process.append((0, 0, { - 'product_id': server_template.product_variant_id.id, - 'product_qty': len(production_process), - 'product_uom': server_template.uom_id.id - })) + server_template = self.env['product.template'].search( + [('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id), + ('detailed_type', '=', 'service')]) + purchase_order_line = self.env['purchase.order.line'].search( + [('product_id', '=', server_template.product_variant_id.id), + ('product_qty', '=', len(production_process))], limit=1, order='id desc') + if not purchase_order_line: + server_product_process.append((0, 0, { + 'product_id': server_template.product_variant_id.id, + 'product_qty': len(production_process), + 'product_uom': server_template.uom_id.id + })) + else: + for item in purchase_order_line: + if production.name in production_process: + purchase_order = self.env['purchase.order'].search( + [('state', '=', 'draft'), ('origin', '=', ','.join(production_process)), + ('id', '=', item.order_id.id)]) + if not purchase_order: + server_product_process.append((0, 0, { + 'product_id': server_template.product_variant_id.id, + 'product_qty': len(production_process), + 'product_uom': server_template.uom_id.id + })) + if server_product_process: self.env['purchase.order'].sudo().create({ 'partner_id': server_template.seller_ids[0].partner_id.id, @@ -276,7 +276,7 @@ class RePurchaseOrder(models.Model): 'state': 'draft', 'purchase_type': 'consignment', 'order_line': server_product_process}) - # self.env.cr.commit() + # self.env.cr.commit() @api.onchange('order_line') def _onchange_order_line(self):