Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化制造订单报废流程

This commit is contained in:
jinling.yang
2024-05-29 09:30:41 +08:00
7 changed files with 102 additions and 28 deletions

View File

@@ -516,3 +516,9 @@ div:has(.o_required_modifier) > label::before {
border-bottom: 1px solid;
}
}
// 设置表格横向滚动
.o_list_renderer.o_renderer {
max-width: 100%;
overflow-x: auto;
}

View File

@@ -5,7 +5,7 @@ import re
import requests
from itertools import groupby
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.exceptions import UserError, ValidationError
from odoo.addons.sf_base.commons.common import Common
from odoo.tools import float_compare, float_round, float_is_zero, format_datetime
@@ -507,10 +507,58 @@ class MrpProduction(models.Model):
def _reset_work_order_sequence(self):
for rec in self:
current_sequence = 1
product_routing_sequence_list = {} # 成品
embryo_routing_sequence_list = {} # 坯料
model_type_id = rec.product_id.product_model_type_id
if model_type_id:
tmpl_num = 1
# 成品工序
product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids
if product_routing_tmpl_ids:
for tmpl_id in product_routing_tmpl_ids:
product_routing_sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
tmpl_num += 1
# 表面工艺工序
# 模型类型的表面工艺工序模版
surface_tmpl_ids = model_type_id.surface_technics_routing_tmpl_ids
# 产品选择的表面工艺
model_process_parameters_ids = rec.product_id.model_process_parameters_ids
process_dict = {}
if model_process_parameters_ids:
for process_parameters_id in model_process_parameters_ids:
process_id = process_parameters_id.process_id
surface_tmpl_name = ''
for surface_tmpl_id in surface_tmpl_ids:
if process_id == surface_tmpl_id.route_workcenter_id.surface_technics_id:
surface_tmpl_name = surface_tmpl_id.route_workcenter_id.name
process_dict.update({int(process_id.category_id.code): '%s-%s' % (
surface_tmpl_name, process_parameters_id.name)})
process_list = sorted(process_dict.keys())
for process_num in process_list:
product_routing_sequence_list.update({process_dict.get(process_num): tmpl_num})
tmpl_num += 1
# 坯料工序
tmpl_num = 1
embryo_routing_tmpl_ids = model_type_id.embryo_routing_tmpl_ids
if embryo_routing_tmpl_ids:
for tmpl_id in embryo_routing_tmpl_ids:
embryo_routing_sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
tmpl_num += 1
else:
raise ValidationError('该产品没有选择【模版类型】!')
if rec.product_id.categ_id.name == '成品':
for work in rec.workorder_ids:
work.sequence = current_sequence
current_sequence += 1
if product_routing_sequence_list.get(work.name):
work.sequence = product_routing_sequence_list[work.name]
else:
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
elif rec.product_id.categ_id.name == '坯料':
for work in rec.workorder_ids:
if embryo_routing_sequence_list.get(work.name):
work.sequence = embryo_routing_sequence_list[work.name]
else:
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
# if work.name == '获取CNC加工程序':
# work.button_start()
# #work.fetchCNC()

View File

@@ -578,7 +578,12 @@ class FunctionalToolAssembly(models.Model):
def put_start_preset(self):
self.search([('start_preset_bool', '=', True)]).write({'start_preset_bool': False})
self.write({'start_preset_bool': True})
self.write({
'after_assembly_tool_loading_length': 0,
'after_assembly_functional_tool_diameter': 0,
'after_assembly_knife_tip_r_angle': 0,
'start_preset_bool': True
})
return {
'type': 'ir.actions.act_window',
'res_model': 'sf.functional.tool.assembly.order',

View File

@@ -216,6 +216,7 @@ class FunctionalCuttingToolEntity(models.Model):
'coarse_middle_thin': item.coarse_middle_thin,
'new_former': item.new_former,
'tool_loading_length': item.tool_loading_length,
'handle_length': item.handle_length,
'functional_tool_length': item.functional_tool_length,
'effective_length': item.effective_length,
'max_lifetime_value': item.max_lifetime_value,

View File

@@ -464,8 +464,8 @@
<field name="arch" type="xml">
<form create="0" delete="0" edit="0">
<header>
<button string="修改编码" name="put_assembly_order_code" type="object"
class="btn-primary" confirm="是否确认修改编码"/>
<!-- <button string="修改编码" name="put_assembly_order_code" type="object"-->
<!-- class="btn-primary" confirm="是否确认修改编码"/>-->
<button string="组装" name="put_start_preset" type="object"
attrs="{'invisible': [('assemble_status', '!=', '0')]}"
class="btn-primary"/>

View File

@@ -223,8 +223,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
image = fields.Binary('图片')
@api.onchange('functional_tool_name')
def _onchange_functional_tool_name(self):
@api.depends('functional_tool_name')
def _compute_functional_tool_name(self):
for item in self:
if item.functional_tool_name:
inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', item.functional_tool_name)])
@@ -456,13 +456,15 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
item.handle_freight_rfid = None
# 组装功能刀具参数信息
after_name_id = fields.Many2one('sf.tool.inventory', string='功能刀具名称', required=True)
after_name_id = fields.Many2one('sf.tool.inventory', string='功能刀具名称', compute='_compute_functional_tool_name',
store=True)
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
rfid = fields.Char('Rfid', compute='_compute_rfid')
code = fields.Char(string='功能刀具编码', compute='_compute_code')
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name', store=True)
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
string='组装后功能刀具类型')
string='组装后功能刀具类型', store=True,
compute='_compute_after_assembly_max_lifetime_value')
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)', digits=(10, 3))
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)', digits=(10, 3))
after_assembly_new_former = fields.Selection([('0', ''), ('1', '')], string='组装后新/旧', default='0')
@@ -484,7 +486,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
after_assembly_effective_length = fields.Float(string='组装后有效长(mm)')
L_D_number = fields.Float(string='L/D值(mm)', compute='_compute_l_d_number')
hiding_length = fields.Float(string='避空长(mm)')
after_tool_groups_id = fields.Many2one('sf.tool.groups', string='组装后刀具组')
after_tool_groups_id = fields.Many2one('sf.tool.groups', string='组装后刀具组', store=True,
compute='_compute_after_assembly_max_lifetime_value')
obtain_measurement_status = fields.Boolean('是否获取测量值', default=False)
@api.depends('after_assembly_tool_loading_length', 'after_assembly_handle_length')
def _compute_after_assembly_functional_tool_length(self):
@@ -502,11 +507,16 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
获取刀具预调仪数据
"""
tool = self.env['sf.functional.tool.assembly'].search([('assembly_order_code', '=', self.assembly_order_code)])
tool_loading_length = tool.after_assembly_tool_loading_length
diameter = tool.after_assembly_functional_tool_diameter
r_angle = tool.after_assembly_knife_tip_r_angle
if tool_loading_length == 0 and diameter == 0 and r_angle == 0:
raise ValidationError('没有获取到测量数据!')
self.write({
'after_assembly_tool_loading_length': tool.after_assembly_tool_loading_length, # 总长度
'after_assembly_functional_tool_diameter': tool.after_assembly_functional_tool_diameter, # 直径
'after_assembly_knife_tip_r_angle': tool.after_assembly_knife_tip_r_angle # R角
'after_assembly_tool_loading_length': tool_loading_length, # 总长度
'after_assembly_functional_tool_diameter': diameter, # 直径
'after_assembly_knife_tip_r_angle': r_angle, # R角
'obtain_measurement_status': True # 是否获取测量值
})
return {
@@ -523,6 +533,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
for item in self:
if item.after_name_id:
item.after_assembly_max_lifetime_value = item.after_name_id.life_span
item.after_assembly_functional_tool_type_id = item.after_name_id.functional_cutting_tool_model_id.id
item.after_tool_groups_id = item.after_name_id.tool_groups_id.id
@api.onchange('after_name_id')
def _onchange_number(self):
@@ -533,8 +545,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
item.after_assembly_tool_loading_length = item.after_name_id.tool_length
item.after_assembly_functional_tool_length = item.after_name_id.extension
item.hiding_length = item.after_name_id.blade_length
item.after_assembly_functional_tool_type_id = item.after_name_id.functional_cutting_tool_model_id.id
item.after_tool_groups_id = item.after_name_id.tool_groups_id.id
else:
item.after_assembly_functional_tool_type_id = item.functional_tool_type_id.id
item.after_tool_groups_id = item.tool_groups_id.id

View File

@@ -341,18 +341,20 @@
<field name="rfid" class="custom_required"/>
</group>
<group>
<button name="get_tool_preset_parameter" string="刷新" type="object" class="btn-primary"/>
<field name="obtain_measurement_status" invisible="1"/>
<button name="get_tool_preset_parameter" string="获取测量值" type="object"
class="btn-primary"/>
</group>
</group>
<group>
<group>
<field name="after_name_id" string="功能刀具名称" placeholder="请选择功能刀具名称"
<field name="after_name_id" string="功能刀具名称" placeholder="请选择功能刀具名称" readonly="1"
options="{'no_create': True, 'no_quick_create': True}"/>
<field name="after_assembly_functional_tool_name" string="功能刀具名称"
invisible="1"/>
<field name="after_assembly_functional_tool_type_id" string="功能刀具类型"
<field name="after_assembly_functional_tool_type_id" string="功能刀具类型" readonly="1"
options="{'no_create': True, 'no_quick_create': True}"/>
<field name="after_tool_groups_id"
<field name="after_tool_groups_id" readonly="1"
options="{'no_create': True, 'no_quick_create': True}"/>
<field name="after_assembly_whether_standard_knife" string="是否标准刀"/>
<field name="after_assembly_coarse_middle_thin" string="粗/中/精"/>
@@ -366,11 +368,11 @@
</group>
<group>
<field name="after_assembly_functional_tool_diameter" string="刀具直径(mm)"
class="custom_required"/>
class="custom_required" readonly="1"/>
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"
class="custom_required"/>
class="custom_required" readonly="1"/>
<field name="after_assembly_tool_loading_length" string="总长度(mm)"
class="custom_required"/>
class="custom_required" readonly="1"/>
<field name="after_assembly_handle_length" string="刀柄长度(mm)"
class="custom_required"/>
<field name="after_assembly_functional_tool_length" string="伸出长(mm)"
@@ -390,6 +392,7 @@
</sheet>
<footer>
<button string="确定" name="functional_tool_assembly" type="object" class="btn-primary"
attrs="{'invisible': [('obtain_measurement_status', '=', False)]}"
confirm="是否确认申请组装"/>
<button string="取消" class="btn-secondary" special="cancel"/>
</footer>