diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index dff2763b..24ac58b2 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -57,6 +57,8 @@ class MrpProduction(models.Model): production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')], string='上/下产线', default='待上产线') + manual_quotation = fields.Boolean('人工编程', default=False) + @api.depends( 'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state') diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 134922d1..c9d72b79 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -46,6 +46,8 @@ class ResMrpWorkOrder(models.Model): ], string="工序类型") results = fields.Char('结果') + manual_quotation = fields.Boolean('人工编程', default=False) + @api.onchange('users_ids') def get_user_permissions(self): uid = self.env.uid @@ -984,9 +986,9 @@ class SfWorkOrderBarcodes(models.Model): workorder = self.env['mrp.workorder'].browse(self.ids) # workorder = self.env['mrp.workorder'].search( # [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)]) - # workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)]) - # if workorder_old: - # raise UserError('该托盘已绑定工件,请先解除绑定!!!') + workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)]) + if workorder_old: + raise UserError('该托盘已绑定工件,请先解除绑定!!!') if workorder: if workorder.routing_type == '装夹预调': if workorder.state in ['done']: @@ -1046,7 +1048,7 @@ class SfWorkOrderBarcodes(models.Model): for item in workorder_rfid: if item.state == "progress": item.write({'rfid_code': barcode}) - # raise UserError('该托盘信息不存在!!!') + raise UserError('该托盘信息不存在!!!') # stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)]) # if stock_move_line.product_id.categ_type == '夹具': # workorder.write({ diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index f3cba150..57ad0eaa 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -10,7 +10,6 @@ from OCC.Extend.DataExchange import read_step_file from OCC.Extend.DataExchange import write_stl_file - class ResProductMo(models.Model): _inherit = 'product.template' @@ -616,6 +615,7 @@ class ResProductMo(models.Model): 'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']), 'model_remark': item['remark'], 'default_code': '%s-%s' % (order_number, i), + 'manual_quotation': item['manual_quotation'] or False, 'active': True, } copy_product_id.sudo().write(vals) diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 05523194..379ff199 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -142,6 +142,12 @@ class ResaleOrderLine(models.Model): check_status = fields.Selection(related='order_id.check_status') +class ProductTemplate(models.Model): + _inherit = 'product.template' + + manual_quotation = fields.Boolean('人工编程', default=False) + + class RePurchaseOrder(models.Model): _inherit = 'purchase.order' diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 56391077..01c3de46 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +import logging + from datetime import timedelta from odoo import SUPERUSER_ID from odoo import fields, models, api @@ -191,7 +193,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model): machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', domain="[('production_line_id', '=', production_line_id)]") machine_table_name = fields.Char(string='机台号', readonly=True, related='machine_table_name_id.name') - cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', required=True, + cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', domain="[('equipment_id', '=', machine_table_name_id)]") whether_standard_knife = fields.Boolean(string='是否标准刀', default=True) need_knife_time = fields.Datetime(string='用刀时间', readonly=False) @@ -201,19 +203,20 @@ class CAMWorkOrderProgramKnifePlan(models.Model): barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', domain=[('product_id.name', '=', '功能刀具')]) - functional_tool_name = fields.Char(string='功能刀具名称', compute='_compute_functional_tool_name') - functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False) - tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组') - diameter = fields.Integer(string='刀具直径(mm)', readonly=False) - tool_included_angle = fields.Float(string='刀尖R角(mm)', readonly=False) - tool_loading_length = fields.Float(string='总长度(mm)', readonly=False) + functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) + functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', + compute='_compute_tool_number', store=True) + tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_tool_number', store=True) + diameter = fields.Integer(string='刀具直径(mm)', compute='_compute_tool_number', store=True) + tool_included_angle = fields.Float(string='刀尖R角(mm)', compute='_compute_tool_number', store=True) + tool_loading_length = fields.Float(string='总长度(mm)', compute='_compute_tool_number', store=True) extension_length = fields.Float(string='伸出长(mm)') effective_length = fields.Float(string='有效长(mm)') new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=False, default='0') coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], default='3', string='粗/中/精', readonly=False) L_D = fields.Float(string='L/D值', readonly=False) - clearance_length = fields.Float(string='避空长(mm)', readonly=False) + clearance_length = fields.Float(string='避空长(mm)', compute='_compute_tool_number', store=True) required_cutting_time = fields.Integer(string='需切削时长', readonly=False) process_type = fields.Char('加工类型') margin_x_y = fields.Float('余量_X/Y') @@ -229,15 +232,24 @@ class CAMWorkOrderProgramKnifePlan(models.Model): active = fields.Boolean(string='已归档', default=True) - @api.depends('diameter', 'tool_included_angle', 'tool_groups_id') - def _compute_functional_tool_name(self): - for obj in self: - if obj.tool_groups_id: - obj.functional_tool_name = '%s-D%sR%s' % ( - obj.tool_groups_id.name, obj.diameter, - obj.tool_included_angle) + @api.depends('functional_tool_name') + def _compute_tool_number(self): + for item in self: + inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', item.functional_tool_name)]) + if inventory: + item.functional_tool_type_id = inventory.functional_cutting_tool_model_id.id + item.tool_groups_id = inventory.tool_groups_id.id + item.diameter = int(inventory.diameter) + item.tool_included_angle = inventory.angle + item.tool_loading_length = inventory.tool_length + item.clearance_length = inventory.blade_length else: - obj.functional_tool_name = None + item.functional_tool_type_id = False + item.tool_groups_id = False + item.diameter = 0 + item.tool_included_angle = 0 + item.tool_loading_length = 0 + item.clearance_length = 0 @api.model def _read_group_names(self, categories, domain, order): @@ -311,10 +323,9 @@ class CAMWorkOrderProgramKnifePlan(models.Model): 根据传入的工单信息,查询是否有需要的功能刀具,如果没有则生成CAM工单程序用刀计划 """ status = False - if cnc_processing.functional_tool_type_id and cnc_processing.cutting_tool_name: + if cnc_processing.cutting_tool_name: functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search( - [('sf_cutting_tool_type_id', '=', cnc_processing.functional_tool_type_id.id), - ('name', '=', cnc_processing.cutting_tool_name)]) + [('name', '=', cnc_processing.cutting_tool_name)]) if functional_tools: for functional_tool in functional_tools: if functional_tool.on_tool_stock_num == 0: @@ -327,7 +338,6 @@ class CAMWorkOrderProgramKnifePlan(models.Model): 'name': cnc_processing.workorder_id.production_id.name, 'cam_procedure_code': cnc_processing.program_name, 'filename': cnc_processing.cnc_id.name, - 'functional_tool_type_id': cnc_processing.functional_tool_type_id.id, 'functional_tool_name': cnc_processing.cutting_tool_name, 'cam_cutter_spacing_code': cnc_processing.cutting_tool_no, 'process_type': cnc_processing.processing_type, @@ -338,8 +348,11 @@ class CAMWorkOrderProgramKnifePlan(models.Model): 'shank_model': cnc_processing.cutting_tool_handle_type, 'estimated_processing_time': cnc_processing.estimated_processing_time, }) + logging.info('CAM工单程序用刀计划创建成功!!!') # 创建装刀请求 knife_plan.apply_for_tooling() + else: + logging.info('功能刀具【%s】满足CNC用刀需求!!!') class FunctionalToolAssembly(models.Model): diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py index df9a341e..8098c5a1 100644 --- a/sf_tool_management/models/mrp_workorder.py +++ b/sf_tool_management/models/mrp_workorder.py @@ -36,6 +36,7 @@ class CNCprocessing(models.Model): obj = super(CNCprocessing, self).create(vals) # 调用CAM工单程序用刀计划创建方法 self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(obj) + logging.info('成功调用CAM工单程序用刀计划创建方法!!!') return obj diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index b4bec292..9ff18ebe 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -531,7 +531,7 @@ class Sf_stock_move_line(models.Model): current_product_id = fields.Integer(compute='_compute_location_dest_id_value', store=True) there_is_no_sn = fields.Boolean('是否有序列号', default=False) - rfid = fields.Char('Rfid', readonly=True) + rfid = fields.Char('Rfid') rfid_barcode = fields.Char('Rfid', compute='_compute_rfid') @api.depends('lot_id')