diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 65be98c7..9156dc38 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -309,7 +309,8 @@ class MrpProduction(models.Model): for move in production.move_raw_ids if move.product_id): production.state = 'progress' # 新添加的状态逻辑 - if production.state in ['to_close', 'progress', 'technology_to_confirmed'] and production.schedule_state == '未排': + if production.state in ['to_close', 'progress', + 'technology_to_confirmed'] and production.schedule_state == '未排': if not production.workorder_ids or production.is_adjust is True: production.state = 'technology_to_confirmed' else: @@ -356,7 +357,6 @@ class MrpProduction(models.Model): if production.tool_state == '2': production.state = 'rework' - # 退回调整 def technology_back_adjust(self): process_parameters = [] @@ -849,15 +849,20 @@ class MrpProduction(models.Model): purchase_order = self.env['purchase.order'].search( [('state', '=', 'draft'), ('origin', '=', item.name), ('purchase_type', '=', 'consignment')]) - for line in purchase_order.order_line: - server_template = self.env['product.template'].search( - [('server_product_process_parameters_id', '=', workorder.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), ('id', '=', line.id), - ('product_qty', '=', 1)], limit=1, order='id desc') - if purchase_order_line: - line.unlink() + server_template = self.env['product.template'].search( + [('server_product_process_parameters_id', '=', + workorder.surface_technics_parameters_id.id), + ('detailed_type', '=', 'service')]) + for po in purchase_order: + for line in po.order_line: + if line.product_id == server_template.product_variant_id: + continue + if server_template.server_product_process_parameters_id != line.product_id.server_product_process_parameters_id: + purchase_order_line = self.env['purchase.order.line'].search( + [('product_id', '=', server_template.product_variant_id.id), ('id', '=', line.id), + ('product_qty', '=', 1)], limit=1, order='id desc') + if purchase_order_line: + line.unlink() def _reset_work_order_sequence(self): """ @@ -898,8 +903,6 @@ class MrpProduction(models.Model): for cw in cancel_work_ids: cw.sequence = sequence + 1 - - def _reset_work_order_sequence_1(self): """ 工单工序排序方法(旧) diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 9c0e0b09..e225c274 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -265,17 +265,20 @@ class RePurchaseOrder(models.Model): })) for purchase in purchase_order: for po in purchase.order_line: - if server_template.server_product_process_parameters_id == pp.surface_technics_parameters_id: + if po.product_id == server_template.product_variant_id: + continue + if server_template.server_product_process_parameters_id != po.product_id.server_product_process_parameters_id: purchase_order_line = self.env['purchase.order.line'].search( [('product_id', '=', server_template.product_variant_id.id), - ('product_qty', '=', 1.0), ('id', '=', po.id)], limit=1, + ('product_qty', '=', 1.0), ('id', '=', purchase.id)], limit=1, order='id desc') - if not purchase_order_line and purchase not in purchase_order: + if not purchase_order_line: server_product_process.append((0, 0, { 'product_id': server_template.product_variant_id.id, 'product_qty': 1, '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,