1、产品模型、制造订单模型、工单模型,添加人工编程字段;2、放开工单扫描绑定Rfid的检验功能;3、bfm下单创建产品添加人工报价字段内容;4、优化CNC程序用刀检验库区是否有刀的流程;

This commit is contained in:
yuxianghui
2024-04-18 15:38:16 +08:00
parent 0a9cfd916a
commit 8dfef16b51
7 changed files with 50 additions and 26 deletions

View File

@@ -57,6 +57,8 @@ class MrpProduction(models.Model):
production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')], production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
string='上/下产线', default='待上产线') string='上/下产线', default='待上产线')
manual_quotation = fields.Boolean('人工编程', default=False)
@api.depends( @api.depends(
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state') 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state')

View File

@@ -46,6 +46,8 @@ class ResMrpWorkOrder(models.Model):
], string="工序类型") ], string="工序类型")
results = fields.Char('结果') results = fields.Char('结果')
manual_quotation = fields.Boolean('人工编程', default=False)
@api.onchange('users_ids') @api.onchange('users_ids')
def get_user_permissions(self): def get_user_permissions(self):
uid = self.env.uid 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'].browse(self.ids)
# workorder = self.env['mrp.workorder'].search( # workorder = self.env['mrp.workorder'].search(
# [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)]) # [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)])
# workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)]) workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)])
# if workorder_old: if workorder_old:
# raise UserError('该托盘已绑定工件,请先解除绑定!!!') raise UserError('该托盘已绑定工件,请先解除绑定!!!')
if workorder: if workorder:
if workorder.routing_type == '装夹预调': if workorder.routing_type == '装夹预调':
if workorder.state in ['done']: if workorder.state in ['done']:
@@ -1046,7 +1048,7 @@ class SfWorkOrderBarcodes(models.Model):
for item in workorder_rfid: for item in workorder_rfid:
if item.state == "progress": if item.state == "progress":
item.write({'rfid_code': barcode}) item.write({'rfid_code': barcode})
# raise UserError('该托盘信息不存在!!!') raise UserError('该托盘信息不存在!!!')
# stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)]) # stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)])
# if stock_move_line.product_id.categ_type == '夹具': # if stock_move_line.product_id.categ_type == '夹具':
# workorder.write({ # workorder.write({

View File

@@ -10,7 +10,6 @@ from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file from OCC.Extend.DataExchange import write_stl_file
class ResProductMo(models.Model): class ResProductMo(models.Model):
_inherit = 'product.template' _inherit = 'product.template'
@@ -616,6 +615,7 @@ class ResProductMo(models.Model):
'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']), 'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']),
'model_remark': item['remark'], 'model_remark': item['remark'],
'default_code': '%s-%s' % (order_number, i), 'default_code': '%s-%s' % (order_number, i),
'manual_quotation': item['manual_quotation'] or False,
'active': True, 'active': True,
} }
copy_product_id.sudo().write(vals) copy_product_id.sudo().write(vals)

View File

@@ -142,6 +142,12 @@ class ResaleOrderLine(models.Model):
check_status = fields.Selection(related='order_id.check_status') 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): class RePurchaseOrder(models.Model):
_inherit = 'purchase.order' _inherit = 'purchase.order'

View File

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import logging
from datetime import timedelta from datetime import timedelta
from odoo import SUPERUSER_ID from odoo import SUPERUSER_ID
from odoo import fields, models, api from odoo import fields, models, api
@@ -191,7 +193,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称',
domain="[('production_line_id', '=', production_line_id)]") domain="[('production_line_id', '=', production_line_id)]")
machine_table_name = fields.Char(string='机台号', readonly=True, related='machine_table_name_id.name') 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)]") domain="[('equipment_id', '=', machine_table_name_id)]")
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True) whether_standard_knife = fields.Boolean(string='是否标准刀', default=True)
need_knife_time = fields.Datetime(string='用刀时间', readonly=False) need_knife_time = fields.Datetime(string='用刀时间', readonly=False)
@@ -201,19 +203,20 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号',
domain=[('product_id.name', '=', '功能刀具')]) domain=[('product_id.name', '=', '功能刀具')])
functional_tool_name = fields.Char(string='功能刀具名称', compute='_compute_functional_tool_name') functional_tool_name = fields.Char(string='功能刀具名称', readonly=True)
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型',
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组') compute='_compute_tool_number', store=True)
diameter = fields.Integer(string='刀具直径(mm)', readonly=False) tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_tool_number', store=True)
tool_included_angle = fields.Float(string='尖R角(mm)', readonly=False) diameter = fields.Integer(string='具直径(mm)', compute='_compute_tool_number', store=True)
tool_loading_length = fields.Float(string='总长度(mm)', readonly=False) 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)') extension_length = fields.Float(string='伸出长(mm)')
effective_length = fields.Float(string='有效长(mm)') effective_length = fields.Float(string='有效长(mm)')
new_former = fields.Selection([('0', ''), ('1', '')], string='新/旧', readonly=False, default='0') new_former = fields.Selection([('0', ''), ('1', '')], string='新/旧', readonly=False, default='0')
coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], default='3', coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], default='3',
string='粗/中/精', readonly=False) string='粗/中/精', readonly=False)
L_D = fields.Float(string='L/D值', 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) required_cutting_time = fields.Integer(string='需切削时长', readonly=False)
process_type = fields.Char('加工类型') process_type = fields.Char('加工类型')
margin_x_y = fields.Float('余量_X/Y') margin_x_y = fields.Float('余量_X/Y')
@@ -229,15 +232,24 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
active = fields.Boolean(string='已归档', default=True) active = fields.Boolean(string='已归档', default=True)
@api.depends('diameter', 'tool_included_angle', 'tool_groups_id') @api.depends('functional_tool_name')
def _compute_functional_tool_name(self): def _compute_tool_number(self):
for obj in self: for item in self:
if obj.tool_groups_id: inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', item.functional_tool_name)])
obj.functional_tool_name = '%s-D%sR%s' % ( if inventory:
obj.tool_groups_id.name, obj.diameter, item.functional_tool_type_id = inventory.functional_cutting_tool_model_id.id
obj.tool_included_angle) 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: 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 @api.model
def _read_group_names(self, categories, domain, order): def _read_group_names(self, categories, domain, order):
@@ -311,10 +323,9 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
根据传入的工单信息查询是否有需要的功能刀具如果没有则生成CAM工单程序用刀计划 根据传入的工单信息查询是否有需要的功能刀具如果没有则生成CAM工单程序用刀计划
""" """
status = False 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( 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: if functional_tools:
for functional_tool in functional_tools: for functional_tool in functional_tools:
if functional_tool.on_tool_stock_num == 0: if functional_tool.on_tool_stock_num == 0:
@@ -327,7 +338,6 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
'name': cnc_processing.workorder_id.production_id.name, 'name': cnc_processing.workorder_id.production_id.name,
'cam_procedure_code': cnc_processing.program_name, 'cam_procedure_code': cnc_processing.program_name,
'filename': cnc_processing.cnc_id.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, 'functional_tool_name': cnc_processing.cutting_tool_name,
'cam_cutter_spacing_code': cnc_processing.cutting_tool_no, 'cam_cutter_spacing_code': cnc_processing.cutting_tool_no,
'process_type': cnc_processing.processing_type, 'process_type': cnc_processing.processing_type,
@@ -338,8 +348,11 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
'shank_model': cnc_processing.cutting_tool_handle_type, 'shank_model': cnc_processing.cutting_tool_handle_type,
'estimated_processing_time': cnc_processing.estimated_processing_time, 'estimated_processing_time': cnc_processing.estimated_processing_time,
}) })
logging.info('CAM工单程序用刀计划创建成功')
# 创建装刀请求 # 创建装刀请求
knife_plan.apply_for_tooling() knife_plan.apply_for_tooling()
else:
logging.info('功能刀具【%s】满足CNC用刀需求')
class FunctionalToolAssembly(models.Model): class FunctionalToolAssembly(models.Model):

View File

@@ -36,6 +36,7 @@ class CNCprocessing(models.Model):
obj = super(CNCprocessing, self).create(vals) obj = super(CNCprocessing, self).create(vals)
# 调用CAM工单程序用刀计划创建方法 # 调用CAM工单程序用刀计划创建方法
self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(obj) self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(obj)
logging.info('成功调用CAM工单程序用刀计划创建方法')
return obj return obj

View File

@@ -531,7 +531,7 @@ class Sf_stock_move_line(models.Model):
current_product_id = fields.Integer(compute='_compute_location_dest_id_value', store=True) current_product_id = fields.Integer(compute='_compute_location_dest_id_value', store=True)
there_is_no_sn = fields.Boolean('是否有序列号', default=False) 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') rfid_barcode = fields.Char('Rfid', compute='_compute_rfid')
@api.depends('lot_id') @api.depends('lot_id')