From b5beaad7bf506f1ab1327ed3a788f0ce2106cd64 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 26 Nov 2024 15:37:19 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E9=9D=A2?= =?UTF-8?q?=E5=B7=A5=E8=89=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 11 +++++++---- sf_manufacturing/models/mrp_workorder.py | 16 +++++++++++++--- .../production_technology_re_adjust_wizard.py | 6 +----- .../wizard/production_technology_wizard.py | 4 ++-- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 112a41ff..58cbe7fa 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -691,7 +691,7 @@ class MrpProduction(models.Model): # # 根据工序设计生成工单 for route in production.technology_design_ids: workorder_has = self.env['mrp.workorder'].search( - [('name', '=', route.route_id.name), ('production_id', '=', production.id)]) + [('technology_design_id', '=', route.id), ('production_id', '=', production.id)]) if not workorder_has: if route.route_id.routing_type not in ['表面工艺']: workorders_values.append( @@ -1469,10 +1469,12 @@ class MrpProduction(models.Model): def action_view_purchase_orders(self): self.ensure_one() if self.product_id.product_tmpl_id.single_manufacturing == True: - production = self.env['mrp.production'].search([('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc') + production = self.env['mrp.production'].search( + [('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc') else: - production = self - purchase_order_ids = (production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids + production = self + purchase_order_ids = ( + production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids action = { 'res_model': 'purchase.order', 'type': 'ir.actions.act_window', @@ -1490,6 +1492,7 @@ class MrpProduction(models.Model): }) return action + class sf_detection_result(models.Model): _name = 'sf.detection.result' _description = "检测结果" diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index ccb7ed5c..7121d7c0 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -235,7 +235,7 @@ class ResMrpWorkOrder(models.Model): for workorder in self: if workorder.routing_type == '表面工艺': domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel']), - ('partner_id', '!=', False)] + ('partner_id', '=', workorder.supplier_id.id)] previous_workorder = self.env['mrp.workorder'].search( [('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'), ('production_id', '=', workorder.production_id.id)]) @@ -244,6 +244,8 @@ class ResMrpWorkOrder(models.Model): process_product = self.env['product.template']._get_process_parameters_product( previous_workorder.surface_technics_parameters_id) domain += [('partner_id', '=', process_product.partner_id.id)] + else: + domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)] picking_ids = self.env['stock.picking'].search(domain, order='id asc') workorder.surface_technics_picking_count = len(picking_ids) workorder.picking_ids = picking_ids.ids @@ -283,12 +285,14 @@ class ResMrpWorkOrder(models.Model): # else: domain = [('purchase_type', '=', 'consignment'), ('origin', '=', ','.join(production_list))] purchase = self.env['purchase.order'].search(domain) + purchase_num = 0 if not purchase: order.surface_technics_purchase_count = 0 for line in purchase.order_line: if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id: if line.product_qty == len(production_no_remanufacture): - order.surface_technics_purchase_count = len(purchase) + purchase_num += 1 + order.surface_technics_purchase_count = purchase_num else: order.surface_technics_purchase_count = 0 @@ -309,10 +313,16 @@ class ResMrpWorkOrder(models.Model): # else: domain = [('origin', '=', ','.join(production_list)), ('purchase_type', '=', 'consignment')] purchase_orders = self.env['purchase.order'].search(domain) + purchase_orders_id = None + for line in purchase_orders.order_line: + if line.product_id.server_product_process_parameters_id == self.surface_technics_parameters_id: + if line.product_qty == len(production_no_remanufacture): + purchase_orders_id = line.order_id.id + order.surface_technics_purchase_count = purchase_num result = { "type": "ir.actions.act_window", "res_model": "purchase.order", - "res_id": purchase_orders.id, + "res_id": purchase_orders_id, # "domain": [['id', 'in', self.purchase_id]], "name": _("Purchase Orders"), 'view_mode': 'form', diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index 746c953e..6a055aed 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -79,12 +79,8 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id: purchase_order.write({'state': 'cancel'}) else: - if special.route_id.routing_type == '表面工艺': - display_name = special.process_parameters_id.display_name - else: - display_name = special.route_id.display_name workorder = self.env['mrp.workorder'].search( - [('name', '=', display_name), ('production_id', '=', special.production_id.id)]) + [('technology_design_id', '=', special.id), ('production_id', '=', special.production_id.id)]) if not workorder: if special.route_id.routing_type == '表面工艺': product_production_process = self.env['product.template'].search( diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py index 04f8f12a..6f7fa277 100644 --- a/sf_manufacturing/wizard/production_technology_wizard.py +++ b/sf_manufacturing/wizard/production_technology_wizard.py @@ -46,8 +46,8 @@ class ProductionTechnologyWizard(models.TransientModel): if ro.route_id.routing_type == '表面工艺': domain += [('process_parameters_id', '=', ro.process_parameters_id.id)] elif ro.route_id.routing_tag == 'special' and ro.is_auto is False: - display_name = ro.route_id.display_name - domain += [('name', 'ilike', display_name)] + # display_name = ro.route_id.display_name + domain += [('id', '=', ro.route_id.id)] elif ro.panel is not False: domain += [('panel', '=', ro.panel)] td_upd = self.env['sf.technology.design'].sudo().search(domain) From 33db91f7995658412e7e9337001c9ee6a137bc0a Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 26 Nov 2024 15:56:22 +0800 Subject: [PATCH 2/8] =?UTF-8?q?Revert=20"=E4=BF=AE=E5=A4=8D=E8=A1=A8?= =?UTF-8?q?=E9=9D=A2=E5=B7=A5=E8=89=BA"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b5beaad7bf506f1ab1327ed3a788f0ce2106cd64. --- sf_manufacturing/models/mrp_production.py | 11 ++++------- sf_manufacturing/models/mrp_workorder.py | 16 +++------------- .../production_technology_re_adjust_wizard.py | 6 +++++- .../wizard/production_technology_wizard.py | 4 ++-- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 58cbe7fa..112a41ff 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -691,7 +691,7 @@ class MrpProduction(models.Model): # # 根据工序设计生成工单 for route in production.technology_design_ids: workorder_has = self.env['mrp.workorder'].search( - [('technology_design_id', '=', route.id), ('production_id', '=', production.id)]) + [('name', '=', route.route_id.name), ('production_id', '=', production.id)]) if not workorder_has: if route.route_id.routing_type not in ['表面工艺']: workorders_values.append( @@ -1469,12 +1469,10 @@ class MrpProduction(models.Model): def action_view_purchase_orders(self): self.ensure_one() if self.product_id.product_tmpl_id.single_manufacturing == True: - production = self.env['mrp.production'].search( - [('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc') + production = self.env['mrp.production'].search([('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc') else: - production = self - purchase_order_ids = ( - production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids + production = self + purchase_order_ids = (production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids action = { 'res_model': 'purchase.order', 'type': 'ir.actions.act_window', @@ -1492,7 +1490,6 @@ class MrpProduction(models.Model): }) return action - class sf_detection_result(models.Model): _name = 'sf.detection.result' _description = "检测结果" diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 7121d7c0..ccb7ed5c 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -235,7 +235,7 @@ class ResMrpWorkOrder(models.Model): for workorder in self: if workorder.routing_type == '表面工艺': domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel']), - ('partner_id', '=', workorder.supplier_id.id)] + ('partner_id', '!=', False)] previous_workorder = self.env['mrp.workorder'].search( [('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'), ('production_id', '=', workorder.production_id.id)]) @@ -244,8 +244,6 @@ class ResMrpWorkOrder(models.Model): process_product = self.env['product.template']._get_process_parameters_product( previous_workorder.surface_technics_parameters_id) domain += [('partner_id', '=', process_product.partner_id.id)] - else: - domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)] picking_ids = self.env['stock.picking'].search(domain, order='id asc') workorder.surface_technics_picking_count = len(picking_ids) workorder.picking_ids = picking_ids.ids @@ -285,14 +283,12 @@ class ResMrpWorkOrder(models.Model): # else: domain = [('purchase_type', '=', 'consignment'), ('origin', '=', ','.join(production_list))] purchase = self.env['purchase.order'].search(domain) - purchase_num = 0 if not purchase: order.surface_technics_purchase_count = 0 for line in purchase.order_line: if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id: if line.product_qty == len(production_no_remanufacture): - purchase_num += 1 - order.surface_technics_purchase_count = purchase_num + order.surface_technics_purchase_count = len(purchase) else: order.surface_technics_purchase_count = 0 @@ -313,16 +309,10 @@ class ResMrpWorkOrder(models.Model): # else: domain = [('origin', '=', ','.join(production_list)), ('purchase_type', '=', 'consignment')] purchase_orders = self.env['purchase.order'].search(domain) - purchase_orders_id = None - for line in purchase_orders.order_line: - if line.product_id.server_product_process_parameters_id == self.surface_technics_parameters_id: - if line.product_qty == len(production_no_remanufacture): - purchase_orders_id = line.order_id.id - order.surface_technics_purchase_count = purchase_num result = { "type": "ir.actions.act_window", "res_model": "purchase.order", - "res_id": purchase_orders_id, + "res_id": purchase_orders.id, # "domain": [['id', 'in', self.purchase_id]], "name": _("Purchase Orders"), 'view_mode': 'form', diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index 6a055aed..746c953e 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -79,8 +79,12 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id: purchase_order.write({'state': 'cancel'}) else: + if special.route_id.routing_type == '表面工艺': + display_name = special.process_parameters_id.display_name + else: + display_name = special.route_id.display_name workorder = self.env['mrp.workorder'].search( - [('technology_design_id', '=', special.id), ('production_id', '=', special.production_id.id)]) + [('name', '=', display_name), ('production_id', '=', special.production_id.id)]) if not workorder: if special.route_id.routing_type == '表面工艺': product_production_process = self.env['product.template'].search( diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py index 6f7fa277..04f8f12a 100644 --- a/sf_manufacturing/wizard/production_technology_wizard.py +++ b/sf_manufacturing/wizard/production_technology_wizard.py @@ -46,8 +46,8 @@ class ProductionTechnologyWizard(models.TransientModel): if ro.route_id.routing_type == '表面工艺': domain += [('process_parameters_id', '=', ro.process_parameters_id.id)] elif ro.route_id.routing_tag == 'special' and ro.is_auto is False: - # display_name = ro.route_id.display_name - domain += [('id', '=', ro.route_id.id)] + display_name = ro.route_id.display_name + domain += [('name', 'ilike', display_name)] elif ro.panel is not False: domain += [('panel', '=', ro.panel)] td_upd = self.env['sf.technology.design'].sudo().search(domain) From 6edd124556594732a1288fa8e9a9c22e72403b6d Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 26 Nov 2024 16:01:20 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wizard/production_technology_re_adjust_wizard.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index 746c953e..0bf3a0fa 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -21,6 +21,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): technology_designs = self.env['sf.technology.design'].sudo().search( [('production_id', '=', self.production_id.id), ('active', 'in', [True, False])]) productions = self.env['mrp.production'].search(domain) + for production_item in productions: # 该制造订单的其他同一销售订单的制造订单的工艺设计处理 if production_item != self.production_id: From 34353e36149f07e84fd747470820d4fb178ca392 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 26 Nov 2024 16:05:23 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E9=9D=A2?= =?UTF-8?q?=E5=B7=A5=E8=89=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/WorkCenterBarcodes.xml | 1 + sf_manufacturing/models/mrp_production.py | 11 ++++------- sf_manufacturing/models/mrp_workorder.py | 18 ++++-------------- sf_manufacturing/models/stock.py | 4 +++- sf_manufacturing/views/mrp_workorder_view.xml | 1 + .../production_technology_re_adjust_wizard.py | 7 ++++++- .../wizard/production_technology_wizard.py | 4 ++-- sf_manufacturing/wizard/rework_wizard.py | 2 ++ .../wizard/rework_wizard_views.xml | 1 + sf_plan/models/custom_plan.py | 8 ++++---- 10 files changed, 28 insertions(+), 29 deletions(-) diff --git a/sf_machine_connect/views/WorkCenterBarcodes.xml b/sf_machine_connect/views/WorkCenterBarcodes.xml index 90058b59..a1a5a5ea 100644 --- a/sf_machine_connect/views/WorkCenterBarcodes.xml +++ b/sf_machine_connect/views/WorkCenterBarcodes.xml @@ -12,6 +12,7 @@ + diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 58cbe7fa..112a41ff 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -691,7 +691,7 @@ class MrpProduction(models.Model): # # 根据工序设计生成工单 for route in production.technology_design_ids: workorder_has = self.env['mrp.workorder'].search( - [('technology_design_id', '=', route.id), ('production_id', '=', production.id)]) + [('name', '=', route.route_id.name), ('production_id', '=', production.id)]) if not workorder_has: if route.route_id.routing_type not in ['表面工艺']: workorders_values.append( @@ -1469,12 +1469,10 @@ class MrpProduction(models.Model): def action_view_purchase_orders(self): self.ensure_one() if self.product_id.product_tmpl_id.single_manufacturing == True: - production = self.env['mrp.production'].search( - [('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc') + production = self.env['mrp.production'].search([('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc') else: - production = self - purchase_order_ids = ( - production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids + production = self + purchase_order_ids = (production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids action = { 'res_model': 'purchase.order', 'type': 'ir.actions.act_window', @@ -1492,7 +1490,6 @@ class MrpProduction(models.Model): }) return action - class sf_detection_result(models.Model): _name = 'sf.detection.result' _description = "检测结果" diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 7121d7c0..e00aa1d3 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -141,8 +141,8 @@ class ResMrpWorkOrder(models.Model): # 是否绑定托盘 is_trayed = fields.Boolean(string='是否绑定托盘', default=False) - tag_type = fields.Selection([("重新加工", "重新加工")], string="标签", tracking=True) + technology_design_id = fields.Many2one('sf.technology.design') def _compute_default_construction_period_status(self): @@ -235,7 +235,7 @@ class ResMrpWorkOrder(models.Model): for workorder in self: if workorder.routing_type == '表面工艺': domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel']), - ('partner_id', '=', workorder.supplier_id.id)] + ('partner_id', '!=', False)] previous_workorder = self.env['mrp.workorder'].search( [('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'), ('production_id', '=', workorder.production_id.id)]) @@ -244,8 +244,6 @@ class ResMrpWorkOrder(models.Model): process_product = self.env['product.template']._get_process_parameters_product( previous_workorder.surface_technics_parameters_id) domain += [('partner_id', '=', process_product.partner_id.id)] - else: - domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)] picking_ids = self.env['stock.picking'].search(domain, order='id asc') workorder.surface_technics_picking_count = len(picking_ids) workorder.picking_ids = picking_ids.ids @@ -285,14 +283,12 @@ class ResMrpWorkOrder(models.Model): # else: domain = [('purchase_type', '=', 'consignment'), ('origin', '=', ','.join(production_list))] purchase = self.env['purchase.order'].search(domain) - purchase_num = 0 if not purchase: order.surface_technics_purchase_count = 0 for line in purchase.order_line: if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id: if line.product_qty == len(production_no_remanufacture): - purchase_num += 1 - order.surface_technics_purchase_count = purchase_num + order.surface_technics_purchase_count = len(purchase) else: order.surface_technics_purchase_count = 0 @@ -313,16 +309,10 @@ class ResMrpWorkOrder(models.Model): # else: domain = [('origin', '=', ','.join(production_list)), ('purchase_type', '=', 'consignment')] purchase_orders = self.env['purchase.order'].search(domain) - purchase_orders_id = None - for line in purchase_orders.order_line: - if line.product_id.server_product_process_parameters_id == self.surface_technics_parameters_id: - if line.product_qty == len(production_no_remanufacture): - purchase_orders_id = line.order_id.id - order.surface_technics_purchase_count = purchase_num result = { "type": "ir.actions.act_window", "res_model": "purchase.order", - "res_id": purchase_orders_id, + "res_id": purchase_orders.id, # "domain": [['id', 'in', self.purchase_id]], "name": _("Purchase Orders"), 'view_mode': 'form', diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 031672b8..fb42da12 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -286,6 +286,8 @@ class StockRule(models.Model): mrp_production = self.env['mrp.production'].sudo().search([('name', '=', production.origin)], limit=1) if mrp_production: sale_order = self.env['sale.order'].sudo().search([('name', '=', mrp_production.origin)]) + else: + mrp_production = production if sale_order: # sale_order.write({'schedule_status': 'to schedule'}) self.env['sf.production.plan'].sudo().with_company(company_id).create({ @@ -293,7 +295,7 @@ class StockRule(models.Model): 'order_deadline': sale_order.deadline_of_delivery, 'production_id': production.id, 'date_planned_start': production.date_planned_start, - 'origin': production.origin, + 'origin': mrp_production.origin, 'product_qty': production.product_qty, 'product_id': production.product_id.id, 'state': 'draft', diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 53134cc4..c989faff 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -32,6 +32,7 @@ + + diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index e357f93e..f0214c9a 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -259,10 +259,10 @@ class sf_production_plan(models.Model): # sale_obj = self.env['sale.order'].search([('name', '=', record.origin)]) # if 'S' in sale_obj.name: # sale_obj.schedule_status = 'to process' - mrp_production_ids = record.production_id._get_children().ids - print('mrp_production_ids', mrp_production_ids) - for i in mrp_production_ids: - record.env['mrp.production'].sudo().browse(i).schedule_state = '已排' + # mrp_production_ids = record.production_id._get_children().ids + # print('mrp_production_ids', mrp_production_ids) + # for i in mrp_production_ids: + # record.env['mrp.production'].sudo().browse(i).schedule_state = '已排' # record.production_id.date_planned_start = record.date_planned_start # record.production_id.date_planned_finished = record.date_planned_finished record.sudo().production_id.production_line_id = record.production_line_id.id From 0e763c2ca6928c399f1345b8851acb3c56e0a5b8 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 26 Nov 2024 16:05:37 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wizard/production_technology_re_adjust_wizard.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index 0bf3a0fa..746c953e 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -21,7 +21,6 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): technology_designs = self.env['sf.technology.design'].sudo().search( [('production_id', '=', self.production_id.id), ('active', 'in', [True, False])]) productions = self.env['mrp.production'].search(domain) - for production_item in productions: # 该制造订单的其他同一销售订单的制造订单的工艺设计处理 if production_item != self.production_id: From 43ee2d1836d2300a59feed44bc5f9c2f66d52b31 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 26 Nov 2024 16:08:30 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=9B=9E=E6=BB=9A=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 11 +++++++---- sf_manufacturing/models/mrp_workorder.py | 18 ++++++++++++++---- .../production_technology_re_adjust_wizard.py | 7 +------ .../wizard/production_technology_wizard.py | 4 ++-- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 112a41ff..58cbe7fa 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -691,7 +691,7 @@ class MrpProduction(models.Model): # # 根据工序设计生成工单 for route in production.technology_design_ids: workorder_has = self.env['mrp.workorder'].search( - [('name', '=', route.route_id.name), ('production_id', '=', production.id)]) + [('technology_design_id', '=', route.id), ('production_id', '=', production.id)]) if not workorder_has: if route.route_id.routing_type not in ['表面工艺']: workorders_values.append( @@ -1469,10 +1469,12 @@ class MrpProduction(models.Model): def action_view_purchase_orders(self): self.ensure_one() if self.product_id.product_tmpl_id.single_manufacturing == True: - production = self.env['mrp.production'].search([('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc') + production = self.env['mrp.production'].search( + [('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc') else: - production = self - purchase_order_ids = (production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids + production = self + purchase_order_ids = ( + production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids action = { 'res_model': 'purchase.order', 'type': 'ir.actions.act_window', @@ -1490,6 +1492,7 @@ class MrpProduction(models.Model): }) return action + class sf_detection_result(models.Model): _name = 'sf.detection.result' _description = "检测结果" diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index e00aa1d3..7121d7c0 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -141,8 +141,8 @@ class ResMrpWorkOrder(models.Model): # 是否绑定托盘 is_trayed = fields.Boolean(string='是否绑定托盘', default=False) - tag_type = fields.Selection([("重新加工", "重新加工")], string="标签", tracking=True) + tag_type = fields.Selection([("重新加工", "重新加工")], string="标签", tracking=True) technology_design_id = fields.Many2one('sf.technology.design') def _compute_default_construction_period_status(self): @@ -235,7 +235,7 @@ class ResMrpWorkOrder(models.Model): for workorder in self: if workorder.routing_type == '表面工艺': domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel']), - ('partner_id', '!=', False)] + ('partner_id', '=', workorder.supplier_id.id)] previous_workorder = self.env['mrp.workorder'].search( [('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'), ('production_id', '=', workorder.production_id.id)]) @@ -244,6 +244,8 @@ class ResMrpWorkOrder(models.Model): process_product = self.env['product.template']._get_process_parameters_product( previous_workorder.surface_technics_parameters_id) domain += [('partner_id', '=', process_product.partner_id.id)] + else: + domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)] picking_ids = self.env['stock.picking'].search(domain, order='id asc') workorder.surface_technics_picking_count = len(picking_ids) workorder.picking_ids = picking_ids.ids @@ -283,12 +285,14 @@ class ResMrpWorkOrder(models.Model): # else: domain = [('purchase_type', '=', 'consignment'), ('origin', '=', ','.join(production_list))] purchase = self.env['purchase.order'].search(domain) + purchase_num = 0 if not purchase: order.surface_technics_purchase_count = 0 for line in purchase.order_line: if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id: if line.product_qty == len(production_no_remanufacture): - order.surface_technics_purchase_count = len(purchase) + purchase_num += 1 + order.surface_technics_purchase_count = purchase_num else: order.surface_technics_purchase_count = 0 @@ -309,10 +313,16 @@ class ResMrpWorkOrder(models.Model): # else: domain = [('origin', '=', ','.join(production_list)), ('purchase_type', '=', 'consignment')] purchase_orders = self.env['purchase.order'].search(domain) + purchase_orders_id = None + for line in purchase_orders.order_line: + if line.product_id.server_product_process_parameters_id == self.surface_technics_parameters_id: + if line.product_qty == len(production_no_remanufacture): + purchase_orders_id = line.order_id.id + order.surface_technics_purchase_count = purchase_num result = { "type": "ir.actions.act_window", "res_model": "purchase.order", - "res_id": purchase_orders.id, + "res_id": purchase_orders_id, # "domain": [['id', 'in', self.purchase_id]], "name": _("Purchase Orders"), 'view_mode': 'form', diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index 0bf3a0fa..6a055aed 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -21,7 +21,6 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): technology_designs = self.env['sf.technology.design'].sudo().search( [('production_id', '=', self.production_id.id), ('active', 'in', [True, False])]) productions = self.env['mrp.production'].search(domain) - for production_item in productions: # 该制造订单的其他同一销售订单的制造订单的工艺设计处理 if production_item != self.production_id: @@ -80,12 +79,8 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id: purchase_order.write({'state': 'cancel'}) else: - if special.route_id.routing_type == '表面工艺': - display_name = special.process_parameters_id.display_name - else: - display_name = special.route_id.display_name workorder = self.env['mrp.workorder'].search( - [('name', '=', display_name), ('production_id', '=', special.production_id.id)]) + [('technology_design_id', '=', special.id), ('production_id', '=', special.production_id.id)]) if not workorder: if special.route_id.routing_type == '表面工艺': product_production_process = self.env['product.template'].search( diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py index 04f8f12a..6f7fa277 100644 --- a/sf_manufacturing/wizard/production_technology_wizard.py +++ b/sf_manufacturing/wizard/production_technology_wizard.py @@ -46,8 +46,8 @@ class ProductionTechnologyWizard(models.TransientModel): if ro.route_id.routing_type == '表面工艺': domain += [('process_parameters_id', '=', ro.process_parameters_id.id)] elif ro.route_id.routing_tag == 'special' and ro.is_auto is False: - display_name = ro.route_id.display_name - domain += [('name', 'ilike', display_name)] + # display_name = ro.route_id.display_name + domain += [('id', '=', ro.route_id.id)] elif ro.panel is not False: domain += [('panel', '=', ro.panel)] td_upd = self.env['sf.technology.design'].sudo().search(domain) From e6eb41ad248cbf6915d1234cd4bc81d0cc92ffcb Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 26 Nov 2024 16:15:50 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/wizard/production_technology_wizard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py index 6f7fa277..630a272e 100644 --- a/sf_manufacturing/wizard/production_technology_wizard.py +++ b/sf_manufacturing/wizard/production_technology_wizard.py @@ -47,7 +47,7 @@ class ProductionTechnologyWizard(models.TransientModel): domain += [('process_parameters_id', '=', ro.process_parameters_id.id)] elif ro.route_id.routing_tag == 'special' and ro.is_auto is False: # display_name = ro.route_id.display_name - domain += [('id', '=', ro.route_id.id)] + domain += [('id', '=', ro.id)] elif ro.panel is not False: domain += [('panel', '=', ro.panel)] td_upd = self.env['sf.technology.design'].sudo().search(domain) From ea914be4c7ce460434c5b4badbff4bafd7efc64c Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 26 Nov 2024 16:21:17 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 7121d7c0..1600f9f7 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -305,6 +305,7 @@ class ResMrpWorkOrder(models.Model): domain = [('origin', '=', self.production_id.origin)] production_programming = self.env['mrp.production'].search(domain, order='name asc') production_list = [production.name for production in production_programming] + production_no_remanufacture = production_programming.filtered(lambda a: a.is_remanufacture is False) # technology_design = self.env['sf.technology.design'].search( # [('process_parameters_id', '=', self.surface_technics_parameters_id.id), # ('production_id', '=', self.production_id.id)]) @@ -318,7 +319,6 @@ class ResMrpWorkOrder(models.Model): if line.product_id.server_product_process_parameters_id == self.surface_technics_parameters_id: if line.product_qty == len(production_no_remanufacture): purchase_orders_id = line.order_id.id - order.surface_technics_purchase_count = purchase_num result = { "type": "ir.actions.act_window", "res_model": "purchase.order",