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)