diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 449e22df..bc1d5eef 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -311,11 +311,9 @@ class MrpProduction(models.Model): production_programming = self.search( [('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)], limit=1, order='id asc') - logging.info('production_programming1:%s' % production_programming.programming_no) if not production_programming.programming_no: production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id])) else: - logging.info('production_programming2:%s' % production_programming.programming_no) production.write({'programming_no': production_programming.programming_no, 'programming_state': '编程中'}) # # 根据加工面板的面数及对应的工序模板生成工单 diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index f96b2ebe..79d5348a 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -667,36 +667,6 @@ class ResMrpWorkOrder(models.Model): # 'domain': [('production_id', '=', self.id)], # 'target':'new' # } - # @api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state') - # def _compute_state(self): - # for workorder in self: - # if workorder.routing_type == '装夹预调': - # cnc_workorder = self.search( - # [('production_id', '=', workorder.production_id.id), ('routing_type', '=', 'CNC加工')], - # limit=1, order='id asc') - # if not cnc_workorder: - # workorder.state = 'waiting' - # else: - # for item in cnc_workorder.cnc_ids: - # functional_cutting_tool = self.env['sf.functional.cutting.tool.entity'].search( - # [('tool_name_id.name', '=', item.cutting_tool_name)]) - # if not functional_cutting_tool: - # workorder.state = 'waiting' - # if workorder.state == 'pending': - # if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]): - # workorder.state = 'ready' if workorder.production_id.reservation_state == 'assigned' else 'waiting' - # continue - # if workorder.state not in ('waiting', 'ready'): - # continue - # if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]): - # workorder.state = 'pending' - # continue - # if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'): - # continue - # if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting': - # workorder.state = 'ready' - # elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready': - # workorder.state = 'waiting' def recreateManufacturingOrWorkerOrder(self): """ @@ -777,7 +747,7 @@ class ResMrpWorkOrder(models.Model): cnc_workorder = self.search( [('production_id', '=', self.production_id.id), ('routing_type', '=', 'CNC加工')], limit=1, order='id asc') - if not cnc_workorder: + if not cnc_workorder.cnc_ids: raise UserError(_('该制造订单还未下发CNC程序,请稍后再试')) else: for item in cnc_workorder.cnc_ids: @@ -884,31 +854,38 @@ class ResMrpWorkOrder(models.Model): ''' record.date_finished = datetime.now() if record.routing_type == '表面工艺': - if record.picking_ids[0]: + logging.info('record.picking_ids:%s' % record.picking_ids) + logging.info('record.picking_out:%s' % record.picking_ids[0]) + if record.picking_ids: + for pick_item in record.picking_ids: + if pick_item.state not in ['done']: + raise UserError( + '请先完成该工单的工艺外协再进行操作') picking_out = record.env['stock.move.line'].search( - [('picking_id', '=', record.picking_ids[0].id), ('workorder_id', '=', record.id)]) + [('picking_id', '=', record.picking_ids[0].id)]) + logging.info('picking_out:%s' % picking_out.picking_id.name) if picking_out: order_line_ids = [] - for item in picking_out.workorder_id: - server_product = self.env['product.template'].search( - [('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id), - ('detailed_type', '=', 'service')]) - if server_product: - order_line_ids.append((0, 0, { - 'product_id': server_product.product_variant_id.id, - 'product_qty': 1, - 'origin': record.production_id.name, - 'product_uom': server_product.uom_id.id - })) - else: - raise UserError( - '请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name) - if order_line_ids: + logging.info('surface_technics_parameters_id:%s' % record.surface_technics_parameters_id.name) + server_product = self.env['product.template'].search( + [('server_product_process_parameters_id', '=', record.surface_technics_parameters_id.id), + ('detailed_type', '=', 'service')]) + logging.info('server_product:%s' % server_product.name) + if server_product: + order_line_ids.append((0, 0, { + 'product_id': server_product.product_variant_id.id, + 'product_qty': 1, + 'product_uom': server_product.uom_id.id + })) self.env['purchase.order'].create({ 'partner_id': server_product.seller_ids.partner_id.id, + 'origin': record.production_id.name, 'state': 'draft', 'order_line': order_line_ids, }) + else: + raise UserError( + '请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name) tem_date_planned_finished = record.date_planned_finished logging.info('routing_type:%s' % record.routing_type) super().button_finish() diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index f6dda9f8..98c2d59e 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -73,10 +73,7 @@ class Sf_Mrs_Connect(http.Controller): workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( [('production_id', 'in', cnc_program_ids)]) if workpiece_delivery: - for item in workpiece_delivery: - item.is_cnc_program_down = True - if item.workorder_id.state == 'waiting': - item.workorder_id.state = 'ready' + workpiece_delivery.write({'is_cnc_program_down': True}) return json.JSONEncoder().encode(res) else: res = {'status': 0, 'message': '该制造订单暂未开始'} diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index 4ea4c7c7..67396d8f 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -84,7 +84,7 @@