Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/刀具产品调取Cloud刀具标准库(10.11)
This commit is contained in:
@@ -12,8 +12,10 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
_name = 'sf.functional.cutting.tool.entity'
|
||||
_description = '功能刀具列表'
|
||||
|
||||
code = fields.Char('编码')
|
||||
name = fields.Char('名称', required=True, size=20)
|
||||
# code = fields.Char('序列号')
|
||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
|
||||
name = fields.Char(related='barcode_id.name')
|
||||
functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True)
|
||||
mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='刀具型号')
|
||||
mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型',
|
||||
group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True)
|
||||
@@ -93,53 +95,6 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
return [(6, 0, functional_tool_model_ids)]
|
||||
|
||||
|
||||
class FunctionalCuttingToolEntityCache(models.Model):
|
||||
_name = 'sf.functional.cutting.tool.entity.cache'
|
||||
_description = '功能刀具列表缓存'
|
||||
|
||||
code = fields.Char('编码')
|
||||
name = fields.Char('名称')
|
||||
mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
|
||||
mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='刀具型号')
|
||||
|
||||
# 整体式刀具型号
|
||||
cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True,
|
||||
domain=[('cutting_tool_material_id', '=', '整体式刀具')])
|
||||
|
||||
# 刀片型号
|
||||
cutting_tool_blade_model_id = fields.Many2one('product.product', string='刀片型号', readonly=True,
|
||||
domain=[('cutting_tool_material_id', '=', '刀片')])
|
||||
|
||||
# 刀杆型号
|
||||
cutting_tool_cutterbar_model_id = fields.Many2one('product.product', string='刀杆型号', readonly=True,
|
||||
domain=[('cutting_tool_material_id', '=', '刀杆')])
|
||||
|
||||
# 刀盘型号
|
||||
cutting_tool_cutterpad_model_id = fields.Many2one('product.product', string='刀盘型号', readonly=True,
|
||||
domain=[('cutting_tool_material_id', '=', '刀盘')])
|
||||
|
||||
# 刀柄型号
|
||||
cutting_tool_cutterhandle_model_id = fields.Many2one('product.product', string='刀柄型号', readonly=True,
|
||||
domain=[('cutting_tool_material_id', '=', '刀柄')])
|
||||
|
||||
# 夹头型号
|
||||
cutting_tool_cutterhead_model_id = fields.Many2one('product.product', string='夹头型号', readonly=True,
|
||||
domain=[('cutting_tool_material_id', '=', '夹头')])
|
||||
|
||||
diameter = fields.Float('直径(mm)')
|
||||
tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')],
|
||||
string='刀具等级')
|
||||
machining_accuracy = fields.Float('加工精度(mm)')
|
||||
tool_length = fields.Float('装刀长(mm)')
|
||||
blade_number = fields.Integer('刃数')
|
||||
integral_blade_length = fields.Float('整体刃长(mm)')
|
||||
effective_blade_length = fields.Float('有效刃长(mm)')
|
||||
max_life = fields.Float('最大寿命值')
|
||||
is_standard = fields.Selection([('1', '是'), ('0', '否')], '是否标准刀')
|
||||
applicable_range = fields.Char('适用范围')
|
||||
image = fields.Binary('图片')
|
||||
|
||||
|
||||
class FunctionalToolWarning(models.Model):
|
||||
_name = 'sf.functional.tool.warning'
|
||||
_description = '功能刀具预警'
|
||||
@@ -147,8 +102,12 @@ class FunctionalToolWarning(models.Model):
|
||||
functional_cutting_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', readonly=True)
|
||||
functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True)
|
||||
|
||||
code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code')
|
||||
# code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code')
|
||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True,
|
||||
related='functional_cutting_tool_id.barcode_id')
|
||||
name = fields.Char('名称', invisible=True, readonly=True, related='functional_cutting_tool_id.name')
|
||||
functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True,
|
||||
related='functional_cutting_tool_id.functional_tool_name_id')
|
||||
mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True,
|
||||
related='functional_cutting_tool_id.mrs_cutting_tool_type_id')
|
||||
|
||||
@@ -261,8 +220,12 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
|
||||
if record:
|
||||
record.mrs_cutting_tool_type_id = record.functional_cutting_tool_id.mrs_cutting_tool_type_id.id
|
||||
|
||||
code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code')
|
||||
# code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code')
|
||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True,
|
||||
related='functional_cutting_tool_id.barcode_id')
|
||||
name = fields.Char('名称', invisible=True, readonly=True, related='functional_cutting_tool_id.name')
|
||||
functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True,
|
||||
related='functional_cutting_tool_id.functional_tool_name_id')
|
||||
# mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True,
|
||||
# related='functional_cutting_tool_id.mrs_cutting_tool_type_id')
|
||||
|
||||
@@ -371,8 +334,12 @@ class InboundAndOutboundRecordsOfFunctionalTools(models.Model):
|
||||
if record:
|
||||
record.mrs_cutting_tool_type_id = record.functional_cutting_tool_id.mrs_cutting_tool_type_id.id
|
||||
|
||||
code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code')
|
||||
# code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code')
|
||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True,
|
||||
related='functional_cutting_tool_id.barcode_id')
|
||||
name = fields.Char('名称', invisible=True, readonly=True, related='functional_cutting_tool_id.name')
|
||||
functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True,
|
||||
related='functional_cutting_tool_id.functional_tool_name_id')
|
||||
|
||||
# 整体式刀具型号
|
||||
cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True,
|
||||
@@ -470,35 +437,28 @@ class MachineTableToolChangingApply(models.Model):
|
||||
_name = 'sf.machine.table.tool.changing.apply'
|
||||
_description = '机床换刀申请'
|
||||
|
||||
# apply_to_tool_change_ids = fields.One2many(
|
||||
# 'sf.tool.change.requirement.information',
|
||||
# 'tool_change_to_apply_id',
|
||||
# string='换刀需求信息',
|
||||
# attrs="{'invisible': 1}")
|
||||
|
||||
name = fields.Many2one('maintenance.equipment', string='CNC机床', required=True, readonly=False,
|
||||
group_expand='_read_group_names')
|
||||
machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型', readonly=True,
|
||||
compute='_compute_machine_table_type_id')
|
||||
machine_tool_code = fields.Char(string='机台号', invisible=True, readonly=True, compute='_compute_machine_tool_code')
|
||||
machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True)
|
||||
cutter_spacing_code = fields.Char(string='刀位号', readonly=False, required=True)
|
||||
|
||||
@api.depends('name')
|
||||
def _compute_machine_table_type_id(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.machine_table_type_id = record.name.category_id.id
|
||||
|
||||
@api.depends('name')
|
||||
def _compute_machine_tool_code(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.machine_tool_code = record.name.code
|
||||
else:
|
||||
record.machine_table_type_id = None
|
||||
record.machine_tool_code = None
|
||||
|
||||
cutter_spacing_code = fields.Char(string='刀位号', readonly=False)
|
||||
functional_tool_code = fields.Char(string='功能刀具编码', readonly=True, compute='_compute_functional_tool_name_id')
|
||||
functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=False)
|
||||
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True,
|
||||
compute='_compute_functional_tool_name_id')
|
||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号',
|
||||
domain=[('product_id.name', '=', '功能刀具')])
|
||||
functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称',
|
||||
domain=[('name', '=', '功能刀具')])
|
||||
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
|
||||
|
||||
diameter = fields.Char(string='直径(mm)', readonly=False)
|
||||
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False)
|
||||
@@ -510,8 +470,9 @@ class MachineTableToolChangingApply(models.Model):
|
||||
functional_tool_status = fields.Selection([('正常', '正常'), ('异常', '异常')], string='功能刀具状态',
|
||||
default='正常', readonly=False)
|
||||
|
||||
replacement_tool_code = fields.Char(string='待换功能刀具编码', readonly=True)
|
||||
replacement_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='待换功能刀具名称', readonly=True)
|
||||
# replacement_tool_code = fields.Char(string='待换功能刀具编码', readonly=True)
|
||||
assembly_order_code = fields.Char(string='组装单编码', readonly=True)
|
||||
replacement_tool_name_id = fields.Many2one('product.product', string='待换功能刀具名称', readonly=True)
|
||||
replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型',
|
||||
readonly=True)
|
||||
replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')],
|
||||
@@ -522,22 +483,15 @@ class MachineTableToolChangingApply(models.Model):
|
||||
reason_for_applying = fields.Char(string='申请原因', readonly=True)
|
||||
remark = fields.Char(string='备注说明', readonly=False)
|
||||
|
||||
status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移')], string='操作状态', default='0')
|
||||
status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移'), ('3', '已组装')], string='操作状态', default='0')
|
||||
|
||||
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装')
|
||||
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True)
|
||||
|
||||
@api.model
|
||||
def _read_group_names(self, categories, domain, order):
|
||||
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
|
||||
return categories.browse(names)
|
||||
|
||||
@api.depends('functional_tool_name_id')
|
||||
def _compute_functional_tool_name_id(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.functional_tool_code = record.functional_tool_name_id.code
|
||||
record.functional_tool_type_id = record.functional_tool_name_id.mrs_cutting_tool_type_id.id
|
||||
|
||||
@api.onchange('functional_tool_status')
|
||||
def automation_apply_for_tool_change(self):
|
||||
"""
|
||||
@@ -549,7 +503,6 @@ class MachineTableToolChangingApply(models.Model):
|
||||
if self.functional_tool_status == '异常':
|
||||
self.env['sf.machine.table.tool.changing.apply'].search([
|
||||
('name', '=', self.name.id)]).write({
|
||||
'replacement_tool_code': self.functional_tool_code,
|
||||
'replacement_tool_name_id': self.functional_tool_name_id.id,
|
||||
'replacement_tool_type_id': self.functional_tool_type_id.id,
|
||||
'replacement_tool_coarse_middle_thin': self.coarse_middle_thin,
|
||||
@@ -563,7 +516,6 @@ class MachineTableToolChangingApply(models.Model):
|
||||
|
||||
# 新建组装任务
|
||||
self.env['sf.functional.tool.assembly'].create({
|
||||
'functional_tool_code': self.functional_tool_code,
|
||||
'name': self.functional_tool_name_id,
|
||||
'functional_tool_type_id': self.functional_tool_type_id.id,
|
||||
'functional_tool_diameter': self.diameter,
|
||||
@@ -596,12 +548,11 @@ class MachineTableToolChangingApply(models.Model):
|
||||
"""
|
||||
# 撤回功能刀具组装创建的任务
|
||||
self.env['sf.functional.tool.assembly'].search(
|
||||
[('functional_tool_code', '=', self.replacement_tool_code),
|
||||
[('assembly_order_code', '=', self.assembly_order_code),
|
||||
('loading_task_source', '=', '1')]).unlink()
|
||||
|
||||
# 撤回数据更新
|
||||
self.env['sf.machine.table.tool.changing.apply'].search([('name', '=', self.name.id)]).write({
|
||||
'replacement_tool_code': None,
|
||||
'replacement_tool_name_id': None,
|
||||
'replacement_tool_type_id': None,
|
||||
'replacement_tool_coarse_middle_thin': None,
|
||||
@@ -624,16 +575,6 @@ class MachineTableToolChangingApply(models.Model):
|
||||
'status': '0'
|
||||
})
|
||||
|
||||
def open_sf_functional_tool_assembly(self):
|
||||
"""
|
||||
跳转到功能刀具组装界面按键功能
|
||||
:return:
|
||||
"""
|
||||
action = self.env.ref('sf_tool_management.sf_functional_tool_assembly_view_act')
|
||||
result = action.read()[0]
|
||||
result['domain'] = [('sf_machine_table_tool_changing_apply_id', '=', self.id)]
|
||||
return result
|
||||
|
||||
|
||||
class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
_name = 'sf.cam.work.order.program.knife.plan'
|
||||
@@ -642,8 +583,10 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
name = fields.Char(string='工单任务编号', readonly=False)
|
||||
cam_procedure_code = fields.Char(string='CAM程序编号', readonly=False)
|
||||
cam_cutter_spacing_code = fields.Char(string='CAM刀位号', readonly=False)
|
||||
functional_tool_code = fields.Char(string='功能刀具编码', readonly=False)
|
||||
functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=False)
|
||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号',
|
||||
domain=[('product_id.name', '=', '功能刀具')])
|
||||
functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称',
|
||||
domain=[('name', '=', '功能刀具')])
|
||||
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False)
|
||||
machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=False,
|
||||
group_expand='_read_group_machine_table_name_ids')
|
||||
@@ -671,7 +614,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
reason_for_applying = fields.Char(string='申请原因', readonly=False)
|
||||
remark = fields.Char(string='备注说明', readonly=False)
|
||||
|
||||
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装')
|
||||
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True)
|
||||
|
||||
def apply_for_tooling(self):
|
||||
"""
|
||||
@@ -679,8 +622,8 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
:return:
|
||||
"""
|
||||
record = self.env['sf.functional.tool.assembly'].create({
|
||||
'functional_tool_code': self.functional_tool_code,
|
||||
'name': self.functional_tool_name_id.id,
|
||||
'barcode_id': self.barcode_id.id,
|
||||
'functional_tool_name_id': self.functional_tool_name_id.id,
|
||||
'functional_tool_type_id': self.functional_tool_type_id.id,
|
||||
'functional_tool_diameter': self.diameter,
|
||||
'functional_tool_length': self.tool_loading_length,
|
||||
@@ -699,7 +642,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
|
||||
# 将计划执行状态改为执行中
|
||||
self.env['sf.cam.work.order.program.knife.plan'].search(
|
||||
[('functional_tool_code', '=', self.functional_tool_code)]).write({
|
||||
[('barcode_id', '=', self.barcode_id.id)]).write({
|
||||
'plan_execute_status': '1',
|
||||
'applicant': self.env.user.name})
|
||||
|
||||
@@ -709,35 +652,27 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
:return:
|
||||
"""
|
||||
self.env['sf.functional.tool.assembly'].search(
|
||||
[('functional_tool_code', '=', self.functional_tool_code),
|
||||
[('barcode_id', '=', self.barcode_id.id),
|
||||
('loading_task_source', '=', '0')]).unlink()
|
||||
|
||||
# 将计划执行状态改为待执行,同时清除申请人、功能刀具组装字段数据
|
||||
self.env['sf.cam.work.order.program.knife.plan'].search(
|
||||
[('functional_tool_code', '=', self.functional_tool_code)]).write({
|
||||
[('barcode_id', '=', self.barcode_id.id)]).write({
|
||||
'plan_execute_status': '0',
|
||||
'applicant': None,
|
||||
'sf_functional_tool_assembly_id': None,
|
||||
})
|
||||
|
||||
def open_sf_functional_tool_assembly(self):
|
||||
"""
|
||||
跳转到功能刀具组装界面按键功能
|
||||
:return:
|
||||
"""
|
||||
action = self.env.ref('sf_tool_management.sf_functional_tool_assembly_view_act')
|
||||
result = action.read()[0]
|
||||
result['domain'] = [('sf_cam_work_order_program_knife_plan_id', '=', self.id)]
|
||||
return result
|
||||
|
||||
|
||||
class FunctionalToolAssembly(models.Model):
|
||||
_name = 'sf.functional.tool.assembly'
|
||||
_description = '功能刀具组装'
|
||||
_description = '功能刀具组装单'
|
||||
_order = 'use_tool_time asc'
|
||||
|
||||
functional_tool_code = fields.Char(string='功能刀具编码', readonly=True)
|
||||
name = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=True)
|
||||
assembly_order_code = fields.Char(string='编码', readonly=True)
|
||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
|
||||
functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True)
|
||||
name = fields.Char(string='名称', readonly=True)
|
||||
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True,
|
||||
group_expand='_read_group_functional_tool_type_ids')
|
||||
|
||||
@@ -787,6 +722,58 @@ class FunctionalToolAssembly(models.Model):
|
||||
chuck_name = fields.Char('夹头名称', readonly=True)
|
||||
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True)
|
||||
|
||||
@api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id')
|
||||
def _compute_auto_fill(self):
|
||||
for record in self:
|
||||
if record.integral_code_id:
|
||||
record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_material_id.id
|
||||
record.integral_name = record.integral_code_id.product_id.name
|
||||
record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_integral_model_id = None
|
||||
record.integral_name = None
|
||||
record.sf_tool_brand_id_1 = None
|
||||
if record.blade_code_id:
|
||||
record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_material_id.id
|
||||
record.blade_name = record.blade_code_id.product_id.name
|
||||
record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_blade_model_id = None
|
||||
record.blade_name = None
|
||||
record.sf_tool_brand_id_2 = None
|
||||
if record.bar_code_id:
|
||||
record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_material_id.id
|
||||
record.bar_name = record.bar_code_id.product_id.name
|
||||
record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_cutterbar_model_id = None
|
||||
record.bar_name = None
|
||||
record.sf_tool_brand_id_3 = None
|
||||
if record.pad_code_id:
|
||||
record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_material_id.id
|
||||
record.pad_name = record.pad_code_id.product_id.name
|
||||
record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_cutterpad_model_id = None
|
||||
record.pad_name = None
|
||||
record.sf_tool_brand_id_4 = None
|
||||
if record.handle_code_id:
|
||||
record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_material_id.id
|
||||
record.handle_name = record.handle_code_id.product_id.name
|
||||
record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_cutterhandle_model_id = None
|
||||
record.handle_name = None
|
||||
record.sf_tool_brand_id_5 = None
|
||||
if record.chuck_code_id:
|
||||
record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_material_id.id
|
||||
record.chuck_name = record.chuck_code_id.product_id.name
|
||||
record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_cutterhead_model_id = None
|
||||
record.chuck_name = None
|
||||
record.sf_tool_brand_id_6 = None
|
||||
|
||||
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
|
||||
tool_loading_length = fields.Char(string='装刀长(mm)', readonly=True)
|
||||
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
|
||||
@@ -795,11 +782,12 @@ class FunctionalToolAssembly(models.Model):
|
||||
cut_length = fields.Char(string='已切削长度(mm)', readonly=True)
|
||||
cut_number = fields.Char(string='已切削次数', readonly=True)
|
||||
|
||||
loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀')], string='装刀任务来源', readonly=True)
|
||||
loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀'), ('2', '按库存组装')],
|
||||
string='装刀任务来源', readonly=True)
|
||||
applicant = fields.Char(string='申请人', readonly=True)
|
||||
reason_for_applying = fields.Char(string='申请原因', readonly=True)
|
||||
apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True)
|
||||
assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装'), ('2', '已出库')], string='组装状态',
|
||||
assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态',
|
||||
default='0', readonly=True)
|
||||
use_tool_time = fields.Datetime(string='用刀时间', readonly=True)
|
||||
production_line_name_id = fields.Many2one('sf.production.line', string='产线名称', readonly=False)
|
||||
@@ -814,159 +802,33 @@ class FunctionalToolAssembly(models.Model):
|
||||
remark = fields.Char(string='备注说明', readonly=True)
|
||||
|
||||
check_box_1 = fields.Boolean(string='复选框', default=False, readonly=False)
|
||||
sf_machine_table_tool_changing_apply_id = fields.Many2one('sf.machine.table.tool.changing.apply', '机床换刀申请')
|
||||
sf_machine_table_tool_changing_apply_id = fields.Many2one('sf.machine.table.tool.changing.apply', '机床换刀申请', readonly=True)
|
||||
sf_cam_work_order_program_knife_plan_id = fields.Many2one('sf.cam.work.order.program.knife.plan',
|
||||
'CAM工单程序用刀计划')
|
||||
'CAM工单程序用刀计划', readonly=True, )
|
||||
|
||||
def open_sf_cam_work_order_program_knife_plan(self):
|
||||
def _get_code(self, loading_task_source):
|
||||
"""
|
||||
跳转到CAM工单程序用刀计划界面按钮功能
|
||||
自动生成组装单编码
|
||||
"""
|
||||
action = self.env.ref('sf_tool_management.sf_cam_work_order_program_knife_plan_view_act')
|
||||
result = action.read()[0]
|
||||
result['domain'] = [('sf_functional_tool_assembly_id', '=', self.id)]
|
||||
return result
|
||||
|
||||
def open_sf_machine_table_tool_changing_apply(self):
|
||||
"""
|
||||
跳转到机床换刀申请界面按钮功能
|
||||
"""
|
||||
action = self.env.ref('sf_tool_management.sf_machine_table_tool_changing_apply_view_act')
|
||||
result = action.read()[0]
|
||||
result['domain'] = [('sf_functional_tool_assembly_id', '=', self.id)]
|
||||
return result
|
||||
|
||||
def cancel_functional_tool_assembly(self):
|
||||
"""
|
||||
取消功能刀具组装
|
||||
:return:
|
||||
"""
|
||||
if self.new_former == '0':
|
||||
# 如果是新刀,则删除功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录的记录
|
||||
record = self.env['sf.functional.cutting.tool.entity'].search([
|
||||
('code', '=', self.functional_tool_code)])
|
||||
self.env['sf.functional.tool.warning'].search(
|
||||
[('functional_cutting_tool_id', '=', record.id)]).unlink()
|
||||
self.env['sf.real.time.distribution.of.functional.tools'].search(
|
||||
[('functional_cutting_tool_id', '=', record.id)]).unlink()
|
||||
self.env['sf.inbound.and.outbound.records.of.functional.tools'].search(
|
||||
[('functional_cutting_tool_id', '=', record.id)]).unlink()
|
||||
record.unlink()
|
||||
new_time = str(fields.Date.today())
|
||||
datetime = new_time[2:4] + new_time[5:7] + new_time[-2:]
|
||||
functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().search(
|
||||
[('loading_task_source', '=', loading_task_source),
|
||||
('assembly_order_code', 'ilike', datetime)], limit=1, order="id desc")
|
||||
if not functional_tool_assembly:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
# 获取功能刀具缓存信息
|
||||
record = self.env['sf.functional.cutting.tool.entity.cache'].search([
|
||||
('code', '=', self.functional_tool_code)], limit=1)
|
||||
# # 删除现有功能刀具列表记录
|
||||
# self.env['sf.functional.cutting.tool.entity'].search([
|
||||
# ('code', '=', self.functional_tool_code)]).unlink()
|
||||
# 修改功能刀具列表信息
|
||||
self.env['sf.functional.cutting.tool.entity'].search([
|
||||
('code', '=', self.functional_tool_code)]).sudo().write({
|
||||
'code': record.code,
|
||||
'name': record.name,
|
||||
'mrs_cutting_tool_type_id': record.mrs_cutting_tool_type_id.id,
|
||||
'mrs_cutting_tool_model_id': record.mrs_cutting_tool_model_id.id,
|
||||
'cutting_tool_integral_model_id': record.cutting_tool_integral_model_id.id,
|
||||
'cutting_tool_blade_model_id': record.cutting_tool_blade_model_id.id,
|
||||
'cutting_tool_cutterbar_model_id': record.cutting_tool_cutterbar_model_id.id,
|
||||
'cutting_tool_cutterpad_model_id': record.cutting_tool_cutterpad_model_id.id,
|
||||
'cutting_tool_cutterhandle_model_id': record.cutting_tool_cutterhandle_model_id.id,
|
||||
'cutting_tool_cutterhead_model_id': record.cutting_tool_cutterhead_model_id.id,
|
||||
'diameter': record.diameter,
|
||||
'tool_grade': record.tool_grade,
|
||||
'machining_accuracy': record.machining_accuracy,
|
||||
'tool_length': record.tool_length,
|
||||
'blade_number': record.blade_number,
|
||||
'integral_blade_length': record.integral_blade_length,
|
||||
'effective_blade_length': record.effective_blade_length,
|
||||
'max_life': record.max_life,
|
||||
'is_standard': record.is_standard,
|
||||
'applicable_range': record.applicable_range,
|
||||
'image': record.image,
|
||||
})
|
||||
# 删除功能刀具缓存信息
|
||||
self.env['sf.functional.cutting.tool.entity.cache'].search([
|
||||
('code', '=', self.functional_tool_code)]).unlink()
|
||||
|
||||
# 修改功能刀具组装的组装信息
|
||||
self.env['sf.functional.tool.assembly'].search([
|
||||
('machine_tool_name_id', '=', self.machine_tool_name_id.id),
|
||||
('cutter_spacing_code', '=', self.cutter_spacing_code),
|
||||
('assemble_status', '=', '1')
|
||||
]).write({
|
||||
'cutting_tool_integral_model_id': None,
|
||||
'integral_code': None,
|
||||
'integral_name': None,
|
||||
'sf_tool_brand_id_1': None,
|
||||
'cutting_tool_blade_model_id': None,
|
||||
'blade_code': None,
|
||||
'blade_name': None,
|
||||
'sf_tool_brand_id_2': None,
|
||||
'cutting_tool_cutterbar_model_id': None,
|
||||
'bar_code': None,
|
||||
'bar_name': None,
|
||||
'sf_tool_brand_id_3': None,
|
||||
'cutting_tool_cutterpad_model_id': None,
|
||||
'pad_code': None,
|
||||
'pad_name': None,
|
||||
'sf_tool_brand_id_4': None,
|
||||
'cutting_tool_cutterhandle_model_id': None,
|
||||
'handle_code': None,
|
||||
'handle_name': None,
|
||||
'sf_tool_brand_id_5': None,
|
||||
'cutting_tool_cutterhead_model_id': None,
|
||||
'chuck_code': None,
|
||||
'chuck_name': None,
|
||||
'sf_tool_brand_id_6': None,
|
||||
'coarse_middle_thin': None,
|
||||
'tool_loading_length': None,
|
||||
'new_former': None,
|
||||
'reference_length': None,
|
||||
'cut_time': None,
|
||||
'cut_length': None,
|
||||
'cut_number': None,
|
||||
'assemble_status': '0',
|
||||
'tool_loading_person': None,
|
||||
'tool_loading_time': None
|
||||
})
|
||||
|
||||
def show_popup(self):
|
||||
"""
|
||||
单个功能刀具出库
|
||||
:return:
|
||||
"""
|
||||
self.env['sf.delivery.of.cargo.from.storage'].search([]).unlink()
|
||||
|
||||
vals = self.env['sf.functional.tool.assembly'].search(
|
||||
[('check_box_1', '=', True), ('assemble_status', '=', '1')])
|
||||
if vals:
|
||||
for val in vals:
|
||||
self.env['sf.delivery.of.cargo.from.storage'].create({
|
||||
'functional_tool_code': val.functional_tool_code,
|
||||
'name': val.name.id,
|
||||
'functional_tool_type_id': val.functional_tool_type_id.id,
|
||||
'production_line_name_id': val.production_line_name_id.id,
|
||||
'machine_tool_code': val.machine_tool_code,
|
||||
'receive_person': val.receive_person,
|
||||
'receive_time': val.receive_time})
|
||||
m = int(functional_tool_assembly.assembly_order_code[-3:]) + 1
|
||||
num = "%03d" % m
|
||||
if loading_task_source == '0':
|
||||
code = 'CAMZZD' + datetime + str(num)
|
||||
elif loading_task_source == '1':
|
||||
code = 'JTZZD' + datetime + str(num)
|
||||
elif loading_task_source == '2':
|
||||
code = 'MTSZZD' + datetime + str(num)
|
||||
else:
|
||||
self.env['sf.delivery.of.cargo.from.storage'].create({
|
||||
'functional_tool_code': self.functional_tool_code,
|
||||
'name': self.name.id,
|
||||
'functional_tool_type_id': self.functional_tool_type_id.id,
|
||||
'production_line_name_id': self.production_line_name_id.id,
|
||||
'machine_tool_code': self.machine_tool_code,
|
||||
'receive_person': self.receive_person,
|
||||
'receive_time': self.receive_time})
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': '功能刀具出库',
|
||||
'res_model': 'sf.delivery.of.cargo.from.storage',
|
||||
'view_mode': 'tree',
|
||||
'view_type': 'tree',
|
||||
'target': 'new'
|
||||
}
|
||||
code = False
|
||||
return code
|
||||
|
||||
def automated_assembly(self):
|
||||
"""
|
||||
@@ -985,3 +847,12 @@ class FunctionalToolAssembly(models.Model):
|
||||
todo 组装单打印
|
||||
:return:
|
||||
"""
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals):
|
||||
obj = super(FunctionalToolAssembly, self).create(vals)
|
||||
if obj.loading_task_source:
|
||||
code = self._get_code(obj.loading_task_source)
|
||||
obj.assembly_order_code = code
|
||||
obj.name = code
|
||||
return obj
|
||||
Reference in New Issue
Block a user