From 304259c6538d63ff801fd13794fe6a5b53722601 Mon Sep 17 00:00:00 2001 From: hy <123@qq.com> Date: Tue, 26 Nov 2024 15:22:41 +0800 Subject: [PATCH 01/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A4=9A=E9=80=89=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/wizard/rework_wizard.py | 3 +-- sf_manufacturing/wizard/rework_wizard_views.xml | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py index 8a73ec57..9bb7be22 100644 --- a/sf_manufacturing/wizard/rework_wizard.py +++ b/sf_manufacturing/wizard/rework_wizard.py @@ -15,8 +15,7 @@ class ReworkWizard(models.TransientModel): production_id = fields.Many2one('mrp.production', string='制造订单号') workorder_ids = fields.Many2many('mrp.workorder', 'rework_wizard_to_work_order', string='所有工单', domain="[('production_id', '=', production_id),('state','=','done')]") - hidden_workorder_ids = fields.Many2many('mrp.workorder', 'rework_wizard_to_work_order_hidden', - string='所有工单(hidden)') + hidden_workorder_ids = fields.Char('') rework_reason = fields.Selection( [("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"), diff --git a/sf_manufacturing/wizard/rework_wizard_views.xml b/sf_manufacturing/wizard/rework_wizard_views.xml index 4482fda7..f9b9206d 100644 --- a/sf_manufacturing/wizard/rework_wizard_views.xml +++ b/sf_manufacturing/wizard/rework_wizard_views.xml @@ -12,9 +12,9 @@ - + - + From b5beaad7bf506f1ab1327ed3a788f0ce2106cd64 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 26 Nov 2024 15:37:19 +0800 Subject: [PATCH 02/24] =?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 03/24] =?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 04/24] =?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 05/24] =?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 06/24] =?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 07/24] =?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 08/24] =?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 09/24] =?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", From 6be7c054150851646e3787beccd44d9deb26176a Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 26 Nov 2024 17:05:45 +0800 Subject: [PATCH 10/24] =?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 --- .../wizard/production_technology_re_adjust_wizard.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index 6a055aed..7c4000dc 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -49,8 +49,8 @@ class ProductionTechnologyReAdjustWizard(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.id)] elif ro.panel is not False: domain += [('panel', '=', ro.panel)] td_upd = self.env['sf.technology.design'].sudo().search(domain) @@ -67,7 +67,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): if special.process_parameters_id: domain += [('surface_technics_parameters_id', '=', special.process_parameters_id.id)] else: - domain += [('name', '=', special.route_id.name)] + domain += [('technology_design_id', '=', special.id)] workorder = self.env['mrp.workorder'].search(domain) if workorder.state != 'cancel': workorder.write({'state': 'cancel'}) From d3b61f320f23568baac91375718168f1d6fff8a5 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 26 Nov 2024 18:01:02 +0800 Subject: [PATCH 11/24] =?UTF-8?q?1=E3=80=81=E8=BF=94=E5=B7=A5=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 15 ++++++++------- sf_manufacturing/wizard/rework_wizard.py | 9 ++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 58cbe7fa..794e5fe2 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -1137,13 +1137,13 @@ class MrpProduction(models.Model): if self.programming_state in ['已编程']: cloud_programming = self._cron_get_programming_state() result_ids = self.detection_result_ids.filtered(lambda dr: dr.handle_result == '待处理') - work_ids = [] + work_id_list = [] if result_ids: - for result_id in result_ids: - work_ids.append(self.workorder_ids.filtered( - lambda wk: (wk.name == result_id.routing_type - and wk.processing_panel == result_id.processing_panel - and wk.state == 'done')).id) + work_id_list = [self.workorder_ids.filtered( + lambda wk: (wk.name == result_id.routing_type and wk.processing_panel == result_id.processing_panel + and wk.state == 'done')).id + for result_id in result_ids] + return { 'name': _('返工'), 'type': 'ir.actions.act_window', @@ -1152,7 +1152,8 @@ class MrpProduction(models.Model): 'target': 'new', 'context': { 'default_production_id': self.id, - 'default_workorder_ids': work_ids, + 'default_workorder_ids': self.workorder_ids.filtered(lambda wk: wk.state == 'done').ids, + 'default_hidden_workorder_ids': ','.join(map(str, work_id_list)) if work_id_list != [] else '', 'default_reprogramming_num': cloud_programming['reprogramming_num'], 'default_programming_state': cloud_programming['programming_state'], 'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py index 9bb7be22..6304ca61 100644 --- a/sf_manufacturing/wizard/rework_wizard.py +++ b/sf_manufacturing/wizard/rework_wizard.py @@ -51,9 +51,12 @@ class ReworkWizard(models.TransientModel): 'test_report': self.workorder_id.detection_report})]}) self.workorder_id.button_finish() else: - if self.workorder_ids: - rework_workorder_ids = self.production_id.workorder_ids.filtered( - lambda ap: ap.id in self.workorder_ids.ids) + if self.hidden_workorder_ids: + hidden_workorder_list = self.hidden_workorder_ids.split(',') + rework_workorder_ids = self.workorder_ids.filtered(lambda w: str(w.id) in hidden_workorder_list) + else: + raise ValidationError('请选择返工工单!!!') + if rework_workorder_ids: clamp_workorder_ids = None if rework_workorder_ids: # 限制 From 64fdedf726e4eb87e3395acc6eca777af867ad88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 27 Nov 2024 08:37:12 +0800 Subject: [PATCH 12/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=BC=80=E5=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 9 +++++---- sf_manufacturing/models/mrp_workorder.py | 12 ++++++++---- sf_manufacturing/models/stock.py | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 112a41ff..77f73444 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -309,8 +309,7 @@ class MrpProduction(models.Model): for move in production.move_raw_ids if move.product_id): production.state = 'progress' # 新添加的状态逻辑 - if ( - production.state == 'to_close' or production.state == 'progress') 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: @@ -324,6 +323,8 @@ class MrpProduction(models.Model): production.state = 'pending_cam' elif production.state == 'confirmed' and production.is_adjust is True: production.state = 'technology_to_confirmed' + if production.state == 'confirmed' and production.schedule_state == '已排': + production.state = 'pending_cam' if production.state == 'progress': if all(wo_state not in ('progress', 'done', 'rework', 'scrap') for wo_state in production.workorder_ids.mapped('state')): @@ -650,8 +651,8 @@ class MrpProduction(models.Model): if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids: self.move_finished_ids.filtered( lambda m: m.product_id == self.product_id).move_line_ids.lot_id = self.lot_producing_id - if self.product_id.tracking == 'serial': - self._set_qty_producing() + # if self.product_id.tracking == 'serial': + # self._set_qty_producing() # 重载根据工序生成工单的程序:如果产品BOM中没有工序时, # 根据产品对应的模板类型中工序,去生成工单; diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index ccb7ed5c..51e3f6da 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1194,20 +1194,24 @@ class ResMrpWorkOrder(models.Model): # 判断是否有坯料的序列号信息 boolean = False if self.production_id.move_raw_ids: - if self.production_id.move_raw_ids[0].move_line_ids: + # 如果是原材料,不判断序列号 + if self.production_id.move_raw_ids[0].product_id.categ_type == '原材料': + boolean = True + elif self.production_id.move_raw_ids[0].move_line_ids: if self.production_id.move_raw_ids[0].move_line_ids: if self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: boolean = True if not boolean: raise UserError('制造订单【%s】缺少组件的序列号信息!' % self.production_id.name) - self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name + if self.production_id.move_raw_ids[0].product_id.categ_type == '坯料': + self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name # cnc校验 if self.production_id.production_type == '自动化产线加工': cnc_workorder = self.search( [('production_id', '=', self.production_id.id), ('routing_type', '=', 'CNC加工')], limit=1, order='id asc') - if not cnc_workorder.cnc_ids: - raise UserError(_('该制造订单还未下发CNC程序,请稍后再试')) + # if not cnc_workorder.cnc_ids: + # raise UserError(_('该制造订单还未下发CNC程序,请稍后再试')) else: if self.production_id.tool_state in ['1', '2']: if self.production_id.tool_state == '1': diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index fb42da12..ba4908a3 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -388,6 +388,7 @@ class StockRule(models.Model): i, process_parameter)) productions.technology_design_ids = technology_design_values + productions.write({'state': 'technology_to_confirmed'}) return True @@ -965,7 +966,7 @@ class ReStockMove(models.Model): 合并制造订单的完成move单据 """ res = super(ReStockMove, self)._merge_moves_fields() - if self[0].origin and self.picking_type_id.name in ['生产发料', '内部调拨']: + if self[0].origin and self.picking_type_id.name in ['生产发料', '内部调拨', '生产入库']: production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc') productions = self.env['mrp.production'].search( [('origin', '=', production.origin), ('product_id', '=', production.product_id.id)]) From 12224fc89206573e7bb908a1b41df3b01ab791a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 27 Nov 2024 09:53:17 +0800 Subject: [PATCH 13/24] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E7=BB=93=E6=9D=9F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 6 +++++- sf_manufacturing/models/mrp_workorder.py | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 77f73444..f43c7905 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -320,7 +320,11 @@ class MrpProduction(models.Model): elif production.state == 'pending_cam' and production.schedule_state == '未排': production.state = 'confirmed' elif production.state == 'to_close' and production.schedule_state == '已排': - production.state = 'pending_cam' + if all( + wo_state in ('done', 'cancel') for wo_state in production.workorder_ids.mapped('state')): + production.state = 'done' + else: + production.state = 'pending_cam' elif production.state == 'confirmed' and production.is_adjust is True: production.state = 'technology_to_confirmed' if production.state == 'confirmed' and production.schedule_state == '已排': diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 51e3f6da..8de6cef7 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1191,20 +1191,22 @@ class ResMrpWorkOrder(models.Model): }) if self.sequence == 1: + # 判断工单状态是否为等待组件 + if self.state == 'waiting': + raise UserError('制造订单【%s】缺少组件信息!' % self.production_id.name) # 判断是否有坯料的序列号信息 boolean = False if self.production_id.move_raw_ids: - # 如果是原材料,不判断序列号 - if self.production_id.move_raw_ids[0].product_id.categ_type == '原材料': - boolean = True - elif self.production_id.move_raw_ids[0].move_line_ids: + if self.production_id.move_raw_ids[0].product_id.categ_type == '坯料': if self.production_id.move_raw_ids[0].move_line_ids: - if self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: - boolean = True + if self.production_id.move_raw_ids[0].move_line_ids: + if self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: + boolean = True + else: + boolean = True if not boolean: raise UserError('制造订单【%s】缺少组件的序列号信息!' % self.production_id.name) - if self.production_id.move_raw_ids[0].product_id.categ_type == '坯料': - self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name + self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name # cnc校验 if self.production_id.production_type == '自动化产线加工': cnc_workorder = self.search( From a434227807cf55b277e30e4578cd7cdee8e07059 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Wed, 27 Nov 2024 11:01:10 +0800 Subject: [PATCH 14/24] =?UTF-8?q?1=E3=80=81=E5=B7=A5=E5=BA=8F=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=96=B9=E6=B3=95=E4=BC=98=E5=8C=96=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E8=BF=94=E5=B7=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 10 +++++++++- sf_manufacturing/wizard/rework_wizard.py | 5 +++++ sf_manufacturing/wizard/rework_wizard_views.xml | 7 ++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 794e5fe2..a28eb915 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -886,6 +886,14 @@ class MrpProduction(models.Model): and item.panel == work.processing_panel)) if td_ids: work.sequence = td_ids[0].sequence + cancel_work_ids = workorder_ids.filtered(lambda item: item.state in ('已取消', 'cancel')) + if cancel_work_ids: + sequence = max(workorder_ids.filtered(lambda item: item.state not in ('已取消', 'cancel')), + key=lambda w: w.sequence).sequence + for cw in cancel_work_ids: + cw.sequence = sequence + 1 + + def _reset_work_order_sequence_1(self): """ @@ -1152,7 +1160,7 @@ class MrpProduction(models.Model): 'target': 'new', 'context': { 'default_production_id': self.id, - 'default_workorder_ids': self.workorder_ids.filtered(lambda wk: wk.state == 'done').ids, + 'default_workorder_ids': self.workorder_ids.ids, 'default_hidden_workorder_ids': ','.join(map(str, work_id_list)) if work_id_list != [] else '', 'default_reprogramming_num': cloud_programming['reprogramming_num'], 'default_programming_state': cloud_programming['programming_state'], diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py index 6304ca61..6c723761 100644 --- a/sf_manufacturing/wizard/rework_wizard.py +++ b/sf_manufacturing/wizard/rework_wizard.py @@ -54,6 +54,11 @@ class ReworkWizard(models.TransientModel): if self.hidden_workorder_ids: hidden_workorder_list = self.hidden_workorder_ids.split(',') rework_workorder_ids = self.workorder_ids.filtered(lambda w: str(w.id) in hidden_workorder_list) + # 限制判断 + # 1、当制造订单内ZM面的工单都已完成时,返工勾选工序时只能勾选上ZM面的所有工序进行返工 + # 2、当FM工单在CNC工单进行选择返工,并将已全部完成的ZM面工序全部勾选上时,FM工单上所有的已完成的工单(装夹预调工单)也必须进行勾选 + done_panel_workorder_ids = self.workorder_ids.filtered( + lambda w: w.state == 'done' and w.processing_panel is not False) else: raise ValidationError('请选择返工工单!!!') if rework_workorder_ids: diff --git a/sf_manufacturing/wizard/rework_wizard_views.xml b/sf_manufacturing/wizard/rework_wizard_views.xml index f9b9206d..05d1cc04 100644 --- a/sf_manufacturing/wizard/rework_wizard_views.xml +++ b/sf_manufacturing/wizard/rework_wizard_views.xml @@ -14,8 +14,13 @@ - + + + From f57c95496a15f6d4dcb301075bc89ff38bd1ac2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 27 Nov 2024 11:06:05 +0800 Subject: [PATCH 15/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_sale_multiple_supply_methods/__init__.py | 4 ---- sf_manufacturing/__manifest__.py | 2 +- sf_manufacturing/migrations/1.1/post-migrate.py | 12 ++++++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 sf_manufacturing/migrations/1.1/post-migrate.py diff --git a/jikimo_sale_multiple_supply_methods/__init__.py b/jikimo_sale_multiple_supply_methods/__init__.py index 74eea1d2..b02eeb6f 100644 --- a/jikimo_sale_multiple_supply_methods/__init__.py +++ b/jikimo_sale_multiple_supply_methods/__init__.py @@ -12,10 +12,6 @@ def _data_install(cr, registry): env.ref('jikimo_sale_multiple_supply_methods.product_template_default').product_variant_id.write({'active': False, 'is_bfm': True}) env.ref('jikimo_sale_multiple_supply_methods.product_template_embryo_customer_provided').product_variant_id.write({'active': False}) env.ref('jikimo_sale_multiple_supply_methods.product_template_outsourcing').product_variant_id.write({'active': False, 'is_bfm': True}) - env.ref('sf_dlm.product_embryo_sf_self_machining').product_tmpl_id.write({'categ_type': '坯料'}) - env.ref('sf_dlm.product_template_sf').product_tmpl_id.write({'categ_type': '成品'}) - env.ref('sf_dlm.product_embryo_sf_outsource').product_tmpl_id.write({'categ_type': '坯料'}) - env.ref('sf_dlm.product_embryo_sf_purchase').product_tmpl_id.write({'categ_type': '坯料'}) # 为三步制造增加规则 warehouse = env['stock.warehouse'].search([('company_id', '=', env.company.id)], limit=1) diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 2bde02d9..35620913 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -2,7 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. { 'name': '机企猫智能工厂 制造管理', - 'version': '1.0', + 'version': '1.1', 'summary': '智能工厂制造模块', 'sequence': 1, 'description': """ diff --git a/sf_manufacturing/migrations/1.1/post-migrate.py b/sf_manufacturing/migrations/1.1/post-migrate.py new file mode 100644 index 00000000..0606049e --- /dev/null +++ b/sf_manufacturing/migrations/1.1/post-migrate.py @@ -0,0 +1,12 @@ +# migrations/1.1.0/post-migrate.py +from odoo import api, SUPERUSER_ID + +def migrate(cr, version): + # 获取环境 + env = api.Environment(cr, SUPERUSER_ID, {}) + + # 示例:添加新字段 + env.ref('sf_dlm.product_embryo_sf_self_machining').product_tmpl_id.write({'categ_type': '坯料'}) + env.ref('sf_dlm.product_template_sf').product_tmpl_id.write({'categ_type': '成品'}) + env.ref('sf_dlm.product_embryo_sf_outsource').product_tmpl_id.write({'categ_type': '坯料'}) + env.ref('sf_dlm.product_embryo_sf_purchase').product_tmpl_id.write({'categ_type': '坯料'}) \ No newline at end of file From 56cfeac2140336ab48375807b70ba5e5d9ba2973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 27 Nov 2024 11:16:11 +0800 Subject: [PATCH 16/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9D=AF=E6=96=99?= =?UTF-8?q?=E5=86=97=E4=BD=99=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/model_type.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/models/model_type.py b/sf_manufacturing/models/model_type.py index 0dd272bd..1fe36b90 100644 --- a/sf_manufacturing/models/model_type.py +++ b/sf_manufacturing/models/model_type.py @@ -7,7 +7,7 @@ class ModelType(models.Model): name = fields.Char('名称') # embryo_tolerance = fields.Char('坯料容余') - embryo_tolerance_id = fields.Many2one('sf.embryo.redundancy', string='坯料容余') + embryo_tolerance_id = fields.Many2one('sf.embryo.redundancy', string='坯料冗余') product_routing_tmpl_ids = fields.One2many('sf.product.model.type.routing.sort', 'product_model_type_id', '成品工序模板(自动化产线加工') embryo_routing_tmpl_ids = fields.One2many('sf.embryo.model.type.routing.sort', 'embryo_model_type_id', From acb24d69e3813b3923910ec7c0a843ff8742db75 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Wed, 27 Nov 2024 14:42:41 +0800 Subject: [PATCH 17/24] =?UTF-8?q?=E6=8E=92=E7=A8=8B=20=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E5=8D=95=E6=9D=A1=E4=BB=B6=E5=88=A4=E6=96=AD?= 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 37b87906..d50b1df2 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1128,7 +1128,7 @@ class ResMrpWorkOrder(models.Model): if ( line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id and line.product_qty == len(production_no_remanufacture)): - if purchase_orders.state == 'purchase': + if all(pur_order.state == 'purchase' for pur_order in purchase_orders): workorder.state = 'ready' else: workorder.state = 'waiting' From df146a4b58c60ca73d6ee413b48a0710cc947b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 27 Nov 2024 15:02:42 +0800 Subject: [PATCH 18/24] =?UTF-8?q?=E6=88=90=E5=93=81=E5=A7=94=E5=A4=96?= =?UTF-8?q?=EF=BC=8C=E5=9D=AF=E6=96=99=E8=87=AA=E5=8A=A0=E5=B7=A5=E7=9A=84?= =?UTF-8?q?=E5=88=B6=E9=80=A0=E6=8E=92=E7=A8=8B=E5=8D=95=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 2 +- sf_manufacturing/models/stock.py | 22 ++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index f5f685aa..6e211f09 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -884,7 +884,7 @@ class ResProductMo(models.Model): 'model_process_parameters_ids': [(6, 0, [])] if not item.get( 'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']), 'model_remark': item['remark'], - 'single_manufacturing': True, + 'single_manufacturing': False, 'default_code': '%s-%s' % (order_number, i), 'manual_quotation': item['manual_quotation'] or False, 'part_number': item.get('part_number') or '', diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index ba4908a3..20e740f3 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -288,18 +288,18 @@ class StockRule(models.Model): sale_order = self.env['sale.order'].sudo().search([('name', '=', mrp_production.origin)]) else: mrp_production = production - if sale_order: + # if sale_order: # sale_order.write({'schedule_status': 'to schedule'}) - self.env['sf.production.plan'].sudo().with_company(company_id).create({ - 'name': production.name, - 'order_deadline': sale_order.deadline_of_delivery, - 'production_id': production.id, - 'date_planned_start': production.date_planned_start, - 'origin': mrp_production.origin, - 'product_qty': production.product_qty, - 'product_id': production.product_id.id, - 'state': 'draft', - }) + self.env['sf.production.plan'].sudo().with_company(company_id).create({ + 'name': production.name, + 'order_deadline': sale_order.deadline_of_delivery, + 'production_id': production.id, + 'date_planned_start': production.date_planned_start, + 'origin': mrp_production.origin, + 'product_qty': production.product_qty, + 'product_id': production.product_id.id, + 'state': 'draft', + }) technology_design_values = [] all_production = productions grouped_product_ids = {k: list(g) for k, g in groupby(all_production, key=lambda x: x.product_id.id)} From d6c194eaa8ad5bca3af54631571c966f38ed03c1 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Wed, 27 Nov 2024 16:18:18 +0800 Subject: [PATCH 19/24] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=88=B6=E9=80=A0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=8A=B6=E6=80=81=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/wizard/rework_wizard.py | 11 ++++++++++- sf_tool_management/models/mrp_workorder.py | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py index 6c723761..bb787c11 100644 --- a/sf_manufacturing/wizard/rework_wizard.py +++ b/sf_manufacturing/wizard/rework_wizard.py @@ -57,8 +57,17 @@ class ReworkWizard(models.TransientModel): # 限制判断 # 1、当制造订单内ZM面的工单都已完成时,返工勾选工序时只能勾选上ZM面的所有工序进行返工 # 2、当FM工单在CNC工单进行选择返工,并将已全部完成的ZM面工序全部勾选上时,FM工单上所有的已完成的工单(装夹预调工单)也必须进行勾选 - done_panel_workorder_ids = self.workorder_ids.filtered( + # 获取已完成的标准工单 + done_normative_workorder_ids = self.workorder_ids.filtered( lambda w: w.state == 'done' and w.processing_panel is not False) + # 获取需要返工的标准工单 + rework_normative_workorder_ids = rework_workorder_ids.filtered( + lambda w: w.processing_panel is not False) + if rework_normative_workorder_ids: + for rw in rework_normative_workorder_ids: + if len(done_normative_workorder_ids.filtered( + lambda w: w.processing_panel == rw.processing_panel)) == 3: + pass else: raise ValidationError('请选择返工工单!!!') if rework_workorder_ids: diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py index 8fe9748e..25ccc460 100644 --- a/sf_tool_management/models/mrp_workorder.py +++ b/sf_tool_management/models/mrp_workorder.py @@ -221,5 +221,6 @@ class MrpProduction(models.Model): logging.info('调用CAM工单程序用刀计划创建方法!!!') self.env['sf.cam.work.order.program.knife.plan'].sudo().create_cam_work_plan(cnc_ids) if not invalid_tool and not missing_tool_1: + self.sudo().write({'tool_state': '0'}) logging.info('校验cnc用刀正常!!!') logging.info('工单cnc程序用刀校验完成!!!') From c169c0a80b18aa69152d9bfbfcb85df58e5f68a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 27 Nov 2024 17:40:35 +0800 Subject: [PATCH 20/24] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 6 +----- sf_manufacturing/models/mrp_workorder.py | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index f43c7905..77f73444 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -320,11 +320,7 @@ class MrpProduction(models.Model): elif production.state == 'pending_cam' and production.schedule_state == '未排': production.state = 'confirmed' elif production.state == 'to_close' and production.schedule_state == '已排': - if all( - wo_state in ('done', 'cancel') for wo_state in production.workorder_ids.mapped('state')): - production.state = 'done' - else: - production.state = 'pending_cam' + production.state = 'pending_cam' elif production.state == 'confirmed' and production.is_adjust is True: production.state = 'technology_to_confirmed' if production.state == 'confirmed' and production.schedule_state == '已排': diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 8de6cef7..4e94044a 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1361,7 +1361,7 @@ class ResMrpWorkOrder(models.Model): # record.recreateManufacturingOrWorkerOrder() is_production_id = False rework_workorder = record.production_id.workorder_ids.filtered(lambda p: p.state == 'rework') - done_workorder = record.production_id.workorder_ids.filtered(lambda p1: p1.state == 'done') + done_workorder = record.production_id.workorder_ids.filtered(lambda p1: p1.state in ['done']) if (len(rework_workorder) + len(done_workorder) == len(record.production_id.workorder_ids)) or ( len(done_workorder) == len(record.production_id.workorder_ids)): is_production_id = True @@ -1378,7 +1378,7 @@ class ResMrpWorkOrder(models.Model): # workorder.rfid_code_old = rfid_code # workorder.rfid_code = False logging.info('workorder.rfid_code:%s' % workorder.rfid_code) - if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺']: + if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺', '切割']: logging.info('product_qty:%s' % record.production_id.product_qty) for move_raw_id in record.production_id.move_raw_ids: move_raw_id.quantity_done = move_raw_id.product_uom_qty From ecf683e66363e0ffff22e2a189cc112fa641bde4 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 27 Nov 2024 17:54:31 +0800 Subject: [PATCH 21/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=87=E8=B4=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 9 ++++----- sf_manufacturing/models/mrp_routing_workcenter.py | 7 +++++-- sf_manufacturing/models/product_template.py | 4 ++-- sf_manufacturing/models/sf_production_common.py | 10 ++++++++-- .../views/mrp_production_addional_change.xml | 3 ++- sf_mrs_connect/controllers/controllers.py | 6 ++++++ sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- 8 files changed, 31 insertions(+), 16 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 58cbe7fa..9eee5fe1 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -1310,11 +1310,10 @@ class MrpProduction(models.Model): move = self.env['stock.move'].search([('origin', '=', productions.name)], order='id desc') for mo in move: domain = [] - if mo.procure_method == 'make_to_order' and mo.name != productions.name: - if mo.name == '/': - domain = [('barcode', '=', 'WH-PC'), ('sequence_code', '=', 'PC')] - elif mo.name == '拉': - domain = [('barcode', '=', 'WH-INTERNAL'), ('sequence_code', '=', 'INT')] + if mo.location_id.barcode == 'WH-POSTPRODUCTION' and mo.rule_id.picking_type_id.barcode == 'PC': + domain = [('barcode', '=', 'WH-PC'), ('sequence_code', '=', 'PC')] + elif mo.location_id.barcode == 'PL' and mo.rule_id.picking_type_id.barcode == 'INT': + domain = [('barcode', '=', 'WH-INTERNAL'), ('sequence_code', '=', 'INT')] if domain: picking_type = self.env['stock.picking.type'].search(domain) mo.write({'picking_type_id': picking_type.id}) diff --git a/sf_manufacturing/models/mrp_routing_workcenter.py b/sf_manufacturing/models/mrp_routing_workcenter.py index 537c6fd5..e28bd091 100644 --- a/sf_manufacturing/models/mrp_routing_workcenter.py +++ b/sf_manufacturing/models/mrp_routing_workcenter.py @@ -86,9 +86,12 @@ class ResMrpRoutingWorkcenter(models.Model): @api.model def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): if self._context.get('production_id'): + route_ids = [] technology_design = self.env['sf.technology.design'].search( [('production_id', '=', self._context.get('production_id'))]) - route_ids = [t.route_id.id for t in technology_design] - domain = [('id', 'not in', route_ids)] + for t in technology_design.filtered(lambda a: a.routing_tag == 'special'): + if not t.process_parameters_id: + route_ids.append(t.route_id.surface_technics_id.id) + domain = [('id', 'not in', route_ids), ('routing_tag', '=', 'special')] return self._search(domain, limit=limit, access_rights_uid=name_get_uid) return super()._name_search(name, args, operator, limit, name_get_uid) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index f5f685aa..ebbf5bd2 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_manufacturing/models/sf_production_common.py b/sf_manufacturing/models/sf_production_common.py index dc9ff2a3..113858c1 100644 --- a/sf_manufacturing/models/sf_production_common.py +++ b/sf_manufacturing/models/sf_production_common.py @@ -10,8 +10,14 @@ class SfProductionProcessParameter(models.Model): @api.model def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): if self._context.get('route_id'): + parameter = [] routing = self.env['mrp.routing.workcenter'].search([('id', '=', self._context.get('route_id'))]) - domain = [('process_id', '=', routing.surface_technics_id.id)] + technology_design = self.env['sf.technology.design'].search( + [('production_id', '=', self._context.get('production_id')), ('routing_tag', '=', 'special'), + ('route_id', '=', self._context.get('route_id'))]) + for t in technology_design: + if t.process_parameters_id: + parameter.append(t.process_parameters_id.id) + domain = [('process_id', '=', routing.surface_technics_id.id), ('id', 'not in', parameter)] return self._search(domain, limit=limit, access_rights_uid=name_get_uid) return super()._name_search(name, args, operator, limit, name_get_uid) - diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 783f39dd..8a99a6d1 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -368,7 +368,8 @@ attrs="{'readonly': [('id', '!=', False)]}" options="{'no_create': True}"/> + string="参数" context="{'route_id':route_id,'production_id': production_id}" + options="{'no_create': True}"/> Date: Thu, 28 Nov 2024 09:59:01 +0800 Subject: [PATCH 22/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=87=87=E8=B4=AD?= =?UTF-8?q?=EF=BC=9A=E4=B8=80=E4=B8=AA=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E4=B8=80=E4=B8=AA=E9=87=87=E8=B4=AD=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 4 +- sf_manufacturing/models/mrp_workorder.py | 60 ++++++++++--------- sf_manufacturing/models/product_template.py | 4 +- sf_manufacturing/models/stock.py | 11 +++- .../production_technology_re_adjust_wizard.py | 6 +- .../wizard/production_technology_wizard.py | 2 +- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- sf_sale/models/sale_order.py | 37 ++++++------ 9 files changed, 71 insertions(+), 61 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 9eee5fe1..02113cd5 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -842,7 +842,7 @@ class MrpProduction(models.Model): # workorder.picking_ids.move_ids = False workorder.picking_ids = False purchase_order = self.env['purchase.order'].search( - [('state', '=', 'draft'), ('origin', '=', ','.join(production_process)), + [('state', '=', 'draft'), ('origin', '=', item.name), ('purchase_type', '=', 'consignment')]) for line in purchase_order.order_line: server_template = self.env['product.template'].search( @@ -850,7 +850,7 @@ class MrpProduction(models.Model): ('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', '=', len(production_process))], limit=1, order='id desc') + ('product_qty', '=', 1)], limit=1, order='id desc') if purchase_order_line: line.unlink() diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 1600f9f7..f37aae72 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -241,9 +241,9 @@ class ResMrpWorkOrder(models.Model): ('production_id', '=', workorder.production_id.id)]) if previous_workorder: if previous_workorder.supplier_id != workorder.supplier_id: - process_product = self.env['product.template']._get_process_parameters_product( - previous_workorder.surface_technics_parameters_id) - domain += [('partner_id', '=', process_product.partner_id.id)] + # process_product = self.env['product.template']._get_process_parameters_product( + # previous_workorder.surface_technics_parameters_id) + domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_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') @@ -270,55 +270,57 @@ class ResMrpWorkOrder(models.Model): def _compute_surface_technics_purchase_ids(self): for order in self: if order.routing_type == '表面工艺': - if order.production_id.production_type == '自动化产线加工': - domain = [('programming_no', '=', order.production_id.programming_no)] - else: - domain = [('origin', '=', order.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) + # if order.production_id.production_type == '自动化产线加工': + # domain = [('programming_no', '=', order.production_id.programming_no)] + # else: + # domain = [('origin', '=', order.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', '=', order.surface_technics_parameters_id.id), # ('production_id', '=', order.production_id.id)]) # if technology_design.is_auto is False: # domain = [('origin', '=', order.production_id.name)] # else: - domain = [('purchase_type', '=', 'consignment'), ('origin', '=', ','.join(production_list))] + domain = [('purchase_type', '=', 'consignment'), ('origin', '=', order.production_id.name)] 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 + for po in purchase: + for line in po.order_line: + if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id: + if line.product_qty == 1: + purchase_num += 1 + order.surface_technics_purchase_count = purchase_num else: order.surface_technics_purchase_count = 0 def action_view_surface_technics_purchase(self): self.ensure_one() - if self.routing_type == '表面工艺': - if self.production_id.production_type == '自动化产线加工': - domain = [('programming_no', '=', self.production_id.programming_no)] - else: - 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) + # if self.routing_type == '表面工艺': + # if self.production_id.production_type == '自动化产线加工': + # domain = [('programming_no', '=', self.production_id.programming_no)] + # else: + # 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)]) # if technology_design.is_auto is False: # domain = [('origin', '=', self.production_id.name)] # else: - domain = [('origin', '=', ','.join(production_list)), ('purchase_type', '=', 'consignment')] + domain = [('origin', '=', self.production_id.name), ('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 + for po in purchase_orders: + for line in po.order_line: + if line.product_id.server_product_process_parameters_id == self.surface_technics_parameters_id: + if line.product_qty == 1: + purchase_orders_id = line.order_id.id result = { "type": "ir.actions.act_window", "res_model": "purchase.order", diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index ebbf5bd2..f5f685aa 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError from odoo.modules import get_resource_path -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index fb42da12..a5205640 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -283,7 +283,8 @@ class StockRule(models.Model): sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)]) # 如果订单为空,则获取来源制造订单的销售单 if not sale_order: - mrp_production = self.env['mrp.production'].sudo().search([('name', '=', production.origin)], limit=1) + 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: @@ -670,10 +671,14 @@ class StockPicking(models.Model): # 创建 外协出库入单 def create_outcontract_picking(self, sorted_workorders_arr, item): + domain = [('origin', '=', item.name), ('name', 'ilike', 'OCOUT')] if len(sorted_workorders_arr) > 1: sorted_workorders_arr = sorted_workorders_arr[0] - stock_picking = self.env['stock.picking'].search([('origin', '=', item.name), ('name', 'ilike', 'OCOUT')]) - if not stock_picking or sorted_workorders_arr: + else: + domain += [ + ('surface_technics_parameters_id', '=', sorted_workorders_arr[0].surface_technics_parameters_id.id)] + stock_picking = self.env['stock.picking'].search(domain) + if not stock_picking: for sorted_workorders in sorted_workorders_arr: # pick_ids = [] if not sorted_workorders.picking_ids: diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index 7c4000dc..14cebe41 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -99,7 +99,8 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): if workorder.sequence == 1: workorder.blocked_by_workorder_ids = None else: - workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0] + if workorder.blocked_by_workorder_ids: + workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0] productions._reset_work_order_sequence() if self.production_id.product_id.categ_id.type == '成品': productions._reset_subcontract_pick_purchase() @@ -109,5 +110,6 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted( key=lambda a: a.sequence) if workorders[0].state in ['pending']: - if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程': + if workorders[ + 0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程': workorders[0].state = 'waiting' diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py index 630a272e..01103746 100644 --- a/sf_manufacturing/wizard/production_technology_wizard.py +++ b/sf_manufacturing/wizard/production_technology_wizard.py @@ -65,4 +65,4 @@ class ProductionTechnologyWizard(models.TransientModel): key=lambda a: a.sequence) if workorder[0].state in ['pending']: if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程': - workorders[0].state = 'waiting' + workorder[0].state = 'waiting' diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index cb1886a1..081807a4 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -8,8 +8,8 @@ from datetime import datetime import requests from odoo import http from odoo.http import request -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file from odoo import models, fields, api from odoo.modules import get_resource_path from odoo.exceptions import ValidationError, UserError diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index d963d021..87848e3a 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -5,8 +5,8 @@ import requests import os from datetime import datetime # from OCC.Core.GProp import GProp_GProps -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file from odoo.addons.sf_base.commons.common import Common from odoo import models, fields, api from odoo.modules import get_resource_path diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index a73b0a35..9c0e0b09 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -250,35 +250,36 @@ class RePurchaseOrder(models.Model): server_product_process = [] production_process = product_id_to_production_names.get( production.product_id.id) + purchase_order = self.env['purchase.order'].search( + [('state', '=', 'draft'), ('origin', '=', production.name), + ('purchase_type', '=', 'consignment')], order='name asc') for pp in consecutive_process_parameters: 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: + if not purchase_order: server_product_process.append((0, 0, { 'product_id': server_template.product_variant_id.id, - 'product_qty': len(production_process), + 'product_qty': 1, 'product_uom': server_template.uom_id.id })) - else: - if production.name in production_process: - purchase_order = self.env['purchase.order'].search( - [('state', '=', 'draft'), ('origin', '=', ','.join(production_process)), - ('purchase_type', '=', 'consignment')]) - 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 - })) - + for purchase in purchase_order: + for po in purchase.order_line: + if server_template.server_product_process_parameters_id == pp.surface_technics_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, + order='id desc') + if not purchase_order_line and purchase not in purchase_order: + 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, - 'origin': ','.join(production_process), + 'origin': production.name, 'state': 'draft', 'purchase_type': 'consignment', 'order_line': server_product_process}) From d4ba58b55ab397b4c66534d6a617af197efb1401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 28 Nov 2024 10:17:03 +0800 Subject: [PATCH 23/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=92=E7=A8=8B?= =?UTF-8?q?=E5=8D=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 3 +- sf_plan/models/custom_plan.py | 56 +++++++++++++++--------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 4e94044a..157717bc 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1378,7 +1378,8 @@ class ResMrpWorkOrder(models.Model): # workorder.rfid_code_old = rfid_code # workorder.rfid_code = False logging.info('workorder.rfid_code:%s' % workorder.rfid_code) - if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺', '切割']: + # if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺', '切割']: + if is_production_id is True: logging.info('product_qty:%s' % record.production_id.product_qty) for move_raw_id in record.production_id.move_raw_ids: move_raw_id.quantity_done = move_raw_id.product_uom_qty diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index f0214c9a..e7785ad4 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -231,26 +231,42 @@ class sf_production_plan(models.Model): if not record.production_line_id: raise ValidationError("未选择生产线") else: - if record.production_id.workorder_ids: - last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now() - for item in record.production_id.workorder_ids: - if item.name == 'CNC加工': - # 将同一个面的所有工单筛选出来 - workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel) - routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search( - [('name', '=', 'CNC加工')], limit=1) - # 设置一个小的开始时间 - item.date_planned_start = datetime.now() - timedelta(days=100) - item.date_planned_finished = last_cnc_start + timedelta( - minutes=routing_workcenter.time_cycle) - item.date_planned_start = last_cnc_start - record.sudo().production_id.plan_start_processing_time = item.date_planned_start - item.duration_expected = routing_workcenter.time_cycle - pre_duration , next_duration = record.calculate_plan_time(item, workorder_list) - record.date_planned_finished = item.date_planned_finished - # 计算下一个cnc工单的开始时间 - last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration) - # 没有工单也能排程 + # 自动化产线加工 + if record.production_id.production_type == '自动化产线加工': + if record.production_id.workorder_ids: + last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now() + for item in record.production_id.workorder_ids: + if item.name == 'CNC加工': + # 将同一个面的所有工单筛选出来 + workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel) + routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search( + [('name', '=', 'CNC加工')], limit=1) + # 设置一个小的开始时间 + item.date_planned_start = datetime.now() - timedelta(days=100) + item.date_planned_finished = last_cnc_start + timedelta( + minutes=routing_workcenter.time_cycle) + item.date_planned_start = last_cnc_start + record.sudo().production_id.plan_start_processing_time = item.date_planned_start + item.duration_expected = routing_workcenter.time_cycle + pre_duration , next_duration = record.calculate_plan_time(item, workorder_list) + record.date_planned_finished = item.date_planned_finished + # 计算下一个cnc工单的开始时间 + last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration) + # 没有工单也能排程 + else: + # 人工线下加工只排第一张工单 + if record.production_id.workorder_ids: + item = record.production_id.workorder_ids[0] + last_wo_start = record.date_planned_start if record.date_planned_start else datetime.now() + routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search( + [('name', '=', item.routing_type)], limit=1) + item.date_planned_start = datetime.now() - timedelta(days=100) + item.date_planned_finished = last_wo_start + timedelta( + minutes=routing_workcenter.time_cycle) + item.date_planned_start = last_wo_start + record.sudo().production_id.plan_start_processing_time = item.date_planned_start + item.duration_expected = routing_workcenter.time_cycle + record.calculate_plan_time(item, item) record.state = 'done' # record.production_id.schedule_state = '已排' record.sudo().production_id.schedule_state = '已排' From a80d498eabfcea52f34fea07a2278da7cc0979c1 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 28 Nov 2024 10:40:48 +0800 Subject: [PATCH 24/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=B6=E9=80=A0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95-=E9=87=87=E8=B4=AD=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 4 +- sf_manufacturing/views/mrp_workorder_view.xml | 2 +- .../production_technology_re_adjust_wizard.py | 11 +++- .../wizard/production_technology_wizard.py | 58 ++++++++++++++++++- 4 files changed, 68 insertions(+), 7 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index f29b63db..9fc3138f 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -269,10 +269,10 @@ class ResMrpWorkOrder(models.Model): @api.depends('state', 'production_id.name') def _compute_surface_technics_purchase_ids(self): for order in self: - if order.routing_type == '表面工艺': + if order.routing_type == '表面工艺' and order.state not in ['cancel']: # if order.production_id.production_type == '自动化产线加工': # domain = [('programming_no', '=', order.production_id.programming_no)] - # else: + # else:buzhdiao # domain = [('origin', '=', order.production_id.origin)] # production_programming = self.env['mrp.production'].search(domain, order='name asc') # production_list = [production.name for production in production_programming] diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index c989faff..13fff868 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -139,7 +139,7 @@ + attrs="{'invisible': [('surface_technics_purchase_count', '=', 0)]}"> diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index 14cebe41..89ba95d0 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -62,6 +62,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): for special in special_design: workorders_values = [] if special.active is False: + is_cancel = False # 工单采购单外协出入库单皆需取消 domain = [('production_id', '=', special.production_id.id)] if special.process_parameters_id: @@ -69,7 +70,15 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): else: domain += [('technology_design_id', '=', special.id)] workorder = self.env['mrp.workorder'].search(domain) - if workorder.state != 'cancel': + previous_workorder = self.env['mrp.workorder'].search( + [('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'), + ('production_id', '=', workorder.production_id.id)]) + if previous_workorder: + if previous_workorder.supplier_id != workorder.supplier_id: + is_cancel = True + else: + is_cancel = True + if workorder.state != 'cancel' and is_cancel is True: workorder.write({'state': 'cancel'}) workorder.picking_ids.write({'state': 'cancel'}) workorder.picking_ids.move_ids.write({'state': 'cancel'}) diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py index 01103746..d81a89a0 100644 --- a/sf_manufacturing/wizard/production_technology_wizard.py +++ b/sf_manufacturing/wizard/production_technology_wizard.py @@ -53,9 +53,61 @@ class ProductionTechnologyWizard(models.TransientModel): td_upd = self.env['sf.technology.design'].sudo().search(domain) if td_upd: ro.write({'sequence': td_upd.sequence, 'active': td_upd.active}) - # special = production.technology_design_ids.filtered( - # lambda td: td.is_auto is False and td.process_parameters_id is not False) - # # if special: + special_design = self.env['sf.technology.design'].sudo().search( + [('routing_tag', '=', 'special'), ('production_id', '=', production.id), + ('is_auto', '=', False), ('active', 'in', [True, False])]) + for special in special_design: + workorders_values = [] + if special.active is False: + is_cancel = False + # 工单采购单外协出入库单皆需取消 + domain = [('production_id', '=', special.production_id.id)] + if special.process_parameters_id: + domain += [('surface_technics_parameters_id', '=', special.process_parameters_id.id)] + else: + domain += [('technology_design_id', '=', special.id)] + workorder = self.env['mrp.workorder'].search(domain) + previous_workorder = self.env['mrp.workorder'].search( + [('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'), + ('production_id', '=', workorder.production_id.id)]) + if previous_workorder: + if previous_workorder.supplier_id != workorder.supplier_id: + is_cancel = True + else: + is_cancel = True + if workorder.state != 'cancel' and is_cancel is True: + workorder.write({'state': 'cancel'}) + workorder.picking_ids.write({'state': 'cancel'}) + workorder.picking_ids.move_ids.write({'state': 'cancel'}) + purchase_order = self.env['purchase.order'].search( + [('origin', '=', workorder.production_id.origin)]) + for line in purchase_order.order_line: + if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id: + purchase_order.write({'state': 'cancel'}) + else: + if special.production_id.workorder_ids: + workorder = self.env['mrp.workorder'].search( + [('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( + [('server_product_process_parameters_id', '=', special.process_parameters_id.id)]) + workorders_values.append( + self.env[ + 'mrp.workorder']._json_workorder_surface_process_str(special.production_id, special, + product_production_process.seller_ids[ + 0].partner_id.id)) + else: + workorders_values.append( + self.env['mrp.workorder'].json_workorder_str(special.production_id, special)) + special.production_id.write({'workorder_ids': workorders_values}) + else: + if len(workorder.blocked_by_workorder_ids) > 1: + if workorder.sequence == 1: + workorder.blocked_by_workorder_ids = None + else: + if workorder.blocked_by_workorder_ids: + workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0] productions._create_workorder(False) if self.production_id.product_id.categ_id.type == '成品': productions.get_subcontract_pick_purchase()