Accept Merge Request #372: (feature/整体式刀具能力参数补充 -> develop)

Merge Request: 刀具物料功能模型从sf_base模块迁移到sf_manufacturing模块;新增每齿走刀量模型;整体式刀具物料新增关联每齿走刀量对象字段; 

Created By: @禹翔辉
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/372?initial=true
This commit is contained in:
禹翔辉
2023-09-08 10:25:41 +08:00
committed by Coding
13 changed files with 138 additions and 55 deletions

View File

@@ -18,7 +18,6 @@
'views/common_view.xml', 'views/common_view.xml',
'views/fixture_view.xml', 'views/fixture_view.xml',
'views/functional_fixture_view.xml', 'views/functional_fixture_view.xml',
'views/tool_other_features_view.xml',
'views/menu_view.xml', 'views/menu_view.xml',
"views/tool_views.xml", "views/tool_views.xml",
"views/tool_menu.xml", "views/tool_menu.xml",

View File

@@ -3,7 +3,6 @@ from . import common
from . import tool_base_new from . import tool_base_new
from . import fixture from . import fixture
from . import functional_fixture from . import functional_fixture
from . import tool_other_features

View File

@@ -24,12 +24,7 @@ access_sf_fixture_model,sf_fixture_model,model_sf_fixture_model,base.group_user,
access_sf_functional_fixture_type,sf_functional_fixture_type,model_sf_functional_fixture_type,base.group_user,1,1,1,1 access_sf_functional_fixture_type,sf_functional_fixture_type,model_sf_functional_fixture_type,base.group_user,1,1,1,1
access_sf_functional_fixture,sf_functional_fixture,model_sf_functional_fixture,base.group_user,1,1,1,1 access_sf_functional_fixture,sf_functional_fixture,model_sf_functional_fixture,base.group_user,1,1,1,1
access_sf_sync_common,sf_sync_common,model_sf_sync_common,base.group_user,1,1,1,1 access_sf_sync_common,sf_sync_common,model_sf_sync_common,base.group_user,1,1,1,1
access_sf_suitable_machining_method,sf_suitable_machining_method,model_sf_suitable_machining_method,base.group_user,1,1,1,1
access_sf_blade_tip_characteristics,sf_blade_tip_characteristics,model_sf_blade_tip_characteristics,base.group_user,1,1,1,1
access_sf_handle_type,sf_handle_type,model_sf_handle_type,base.group_user,1,1,1,1
access_sf_cutting_direction,sf_cutting_direction,model_sf_cutting_direction,base.group_user,1,1,1,1
access_sf_suitable_coolant,sf_suitable_coolant,model_sf_suitable_coolant,base.group_user,1,1,1,1
access_sf_cutting_speed,sf_cutting_speed,model_sf_cutting_speed,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
24 access_sf_functional_fixture_type sf_functional_fixture_type model_sf_functional_fixture_type base.group_user 1 1 1 1
25 access_sf_functional_fixture sf_functional_fixture model_sf_functional_fixture base.group_user 1 1 1 1
26 access_sf_sync_common sf_sync_common model_sf_sync_common base.group_user 1 1 1 1
27
access_sf_blade_tip_characteristics sf_blade_tip_characteristics model_sf_blade_tip_characteristics base.group_user 1 1 1 1
access_sf_handle_type sf_handle_type model_sf_handle_type base.group_user 1 1 1 1
access_sf_cutting_direction sf_cutting_direction model_sf_cutting_direction base.group_user 1 1 1 1
access_sf_suitable_coolant sf_suitable_coolant model_sf_suitable_coolant base.group_user 1 1 1 1
access_sf_cutting_speed sf_cutting_speed model_sf_cutting_speed base.group_user 1 1 1 1
28
29
30

View File

@@ -211,22 +211,51 @@
</group> </group>
</group> </group>
<group string="适合加工方式"> <group string="适合加工方式">
<field name="suitable_machining_method_ids" string=""/> <field name="suitable_machining_method_ids" string="" widget="many2many_checkboxes"/>
</group> </group>
<group string="刀尖特征"> <group string="刀尖特征">
<field name="blade_tip_characteristics_ids" string=""/> <field name="blade_tip_characteristics_ids" string="" widget="many2many_checkboxes"/>
</group> </group>
<group string="柄部类型"> <group string="柄部类型">
<field name="handle_type_ids" string=""/> <field name="handle_type_ids" string="" widget="many2many_checkboxes"/>
</group> </group>
<group string="走刀方向"> <group string="走刀方向">
<field name="cutting_direction_ids" string=""/> <field name="cutting_direction_ids" string="" widget="many2many_checkboxes"/>
</group> </group>
<group string="适合冷却液"> <group string="适合冷却液">
<field name="suitable_coolant_ids" string=""/> <field name="suitable_coolant_ids" string="" widget="many2many_checkboxes"/>
</group> </group>
<group string="切削速度Vc"> <group string="切削速度Vc">
<field name="cutting_speed_ids" string=""/> <field name="cutting_speed_ids" string="" widget="one2many">
<tree editable="bottom">
<!-- <field name="order"/>-->
<field name="execution_standard_id"/>
<field name="material_code"/>
<field name="material_name"/>
<field name="material_grade"/>
<field name="tensile_strength"/>
<field name="hardness"/>
<field name="cutting_speed_n1"/>
<field name="cutting_speed_n2"/>
<field name="cutting_speed_n3"/>
<field name="cutting_speed_n4"/>
<field name="cutting_speed_n5"/>
<field name="rough_machining"/>
<field name="precision_machining"/>
<field name="application"/>
</tree>
</field>
</group>
<group string="每齿走刀量fz">
<field name="feed_per_tooth_ids" string="" widget="one2many">
<tree editable="bottom">
<field name="cutting_speed" attrs="{'readonly': [('materials_type_id','!=',False)]}"/>
<field name="materials_type_id" attrs="{'readonly': [('cutting_speed','!=',False)]}"/>
<field name="blade_diameter"/>
<field name="feed_per_tooth"/>
<field name="unit"/>
</tree>
</field>
</group> </group>
</group> </group>
</page> </page>

View File

@@ -22,6 +22,7 @@
'views/mrp_workcenter_views.xml', 'views/mrp_workcenter_views.xml',
'views/mrp_workorder_view.xml', 'views/mrp_workorder_view.xml',
'views/production_line_view.xml', 'views/production_line_view.xml',
'views/tool_other_features_view.xml',
# 'views/tray_view.xml', # 'views/tray_view.xml',
'views/model_type_view.xml', 'views/model_type_view.xml',
# 'views/kanban_change.xml' # 'views/kanban_change.xml'

View File

@@ -9,6 +9,7 @@ from . import mrp_routing_workcenter
from . import stock from . import stock
from . import res_user from . import res_user
from . import production_line_base from . import production_line_base
from . import tool_other_features

View File

@@ -1,8 +1,8 @@
from odoo import models, fields, api from odoo import models, fields, api
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
from odoo.modules import get_resource_path from odoo.modules import get_resource_path
from OCC.Extend.DataExchange import read_step_file # from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file # from OCC.Extend.DataExchange import write_stl_file
import logging import logging
import base64 import base64
import hashlib import hashlib
@@ -100,7 +100,8 @@ class ResProductMo(models.Model):
cutting_direction_ids = fields.Many2many('sf.cutting.direction', 'rel_cutting_direction_product_template', '走刀方向') cutting_direction_ids = fields.Many2many('sf.cutting.direction', 'rel_cutting_direction_product_template', '走刀方向')
suitable_coolant_ids = fields.Many2many('sf.suitable.coolant', 'rel_suitable_coolant_product_template', '适合冷却液') suitable_coolant_ids = fields.Many2many('sf.suitable.coolant', 'rel_suitable_coolant_product_template', '适合冷却液')
cutting_speed_ids = fields.Many2many('sf.cutting.speed', 'rel_sf_cutting_speed', '切削速度Vc') cutting_speed_ids = fields.One2many('sf.cutting.speed', 'product_template_id', string='切削速度Vc')
feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'product_template_id', string='每齿走刀量fz')
@api.constrains('suitable_machining_method_ids') @api.constrains('suitable_machining_method_ids')
def _check_suitable_machining_method_ids(self): def _check_suitable_machining_method_ids(self):
@@ -662,20 +663,20 @@ class ResProductMo(models.Model):
item.model_file = self.transition_glb_file(report_path, model_code) item.model_file = self.transition_glb_file(report_path, model_code)
# 将attach的datas内容转为glb文件 # 将attach的datas内容转为glb文件
def transition_glb_file(self, report_path, code): # def transition_glb_file(self, report_path, code):
shapes = read_step_file(report_path) # shapes = read_step_file(report_path)
output_file = os.path.join('/tmp', str(code) + '.stl') # output_file = os.path.join('/tmp', str(code) + '.stl')
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5) # write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
# 转化为glb # # 转化为glb
output_glb_file = os.path.join('/tmp', str(code) + '.glb') # output_glb_file = os.path.join('/tmp', str(code) + '.glb')
util_path = get_resource_path('sf_dlm', 'static/util') # util_path = get_resource_path('sf_dlm', 'static/util')
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file) # cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
os.system(cmd) # os.system(cmd)
# 转base64 # # 转base64
with open(output_glb_file, 'rb') as fileObj: # with open(output_glb_file, 'rb') as fileObj:
image_data = fileObj.read() # image_data = fileObj.read()
base64_data = base64.b64encode(image_data) # base64_data = base64.b64encode(image_data)
return base64_data # return base64_data
class ResMrpBomMo(models.Model): class ResMrpBomMo(models.Model):

View File

@@ -1,4 +1,4 @@
from odoo import fields, models from odoo import fields, models, api
class SuitableMachiningMethod(models.Model): class SuitableMachiningMethod(models.Model):
@@ -56,12 +56,14 @@ class CuttingSpeed(models.Model):
# #
# order = fields.Char('序', default=_get_order, readonly=True) # order = fields.Char('序', default=_get_order, readonly=True)
product_template_id = fields.Many2one('product.template', string='产品')
execution_standard_id = fields.Char('执行标准') execution_standard_id = fields.Char('执行标准')
material_code = fields.Char('材料代号') material_code = fields.Char('材料代号')
material_name = fields.Char('材料名称') material_name = fields.Char('材料名称')
material_grade = fields.Char('材料牌号') material_grade = fields.Char('材料牌号')
tensile_strength = fields.Char('拉伸强度 (N/mm²)') tensile_strength = fields.Float('拉伸强度 (N/mm²)')
hardness = fields.Char('硬度(HRC)') hardness = fields.Float('硬度(HRC)')
cutting_speed_n1 = fields.Char('径向切宽 ae=100%D1 ap=1*D1 切削速度Vc') cutting_speed_n1 = fields.Char('径向切宽 ae=100%D1 ap=1*D1 切削速度Vc')
cutting_speed_n2 = fields.Char('径向切宽 ae=50%D1 ap=1.5*D1 切削速度Vc') cutting_speed_n2 = fields.Char('径向切宽 ae=50%D1 ap=1.5*D1 切削速度Vc')
@@ -70,4 +72,22 @@ class CuttingSpeed(models.Model):
cutting_speed_n5 = fields.Char('径向切宽 ae=5%D1 ap=L1max 切削速度Vc') cutting_speed_n5 = fields.Char('径向切宽 ae=5%D1 ap=L1max 切削速度Vc')
rough_machining = fields.Char('粗加工 Vc(m/min)') rough_machining = fields.Char('粗加工 Vc(m/min)')
precision_machining = fields.Char('精加工 Vc(m/min)') precision_machining = fields.Char('精加工 Vc(m/min)')
application = fields.Selection([('主应用', '主应用'), ('次应用', '次应用')], '主/次应用') application = fields.Selection([('主应用', '主应用'), ('次应用', '次应用')], '主/次应用')
class FeedPerTooth(models.Model):
_name = 'sf.feed.per.tooth'
_description = '每齿走刀量fz'
product_template_id = fields.Many2one('product.template', string='产品')
cutting_speed = fields.Char('径向切宽 ae(mm)')
materials_type_id = fields.Many2one('sf.materials.model', string='材料型号')
blade_diameter = fields.Float('刃部直径D1(mm)', readonly=True, compute='_compute_product_template_id')
feed_per_tooth = fields.Char('每齿走刀量 (mm/z)')
unit = fields.Char('单位', default='fz')
@api.depends('product_template_id')
def _compute_product_template_id(self):
if self.product_template_id is not None:
self.blade_diameter = self.product_template_id.integral_blade_diameter

View File

@@ -7,6 +7,12 @@ access_sf_surface_technics_model_type_routing_sort,sf_surface_technics_model_typ
access_sf_production_line,sf.production.line,model_sf_production_line,base.group_user,1,1,1,1 access_sf_production_line,sf.production.line,model_sf_production_line,base.group_user,1,1,1,1
access_sf_suitable_machining_method,sf_suitable_machining_method,model_sf_suitable_machining_method,base.group_user,1,1,1,1
access_sf_blade_tip_characteristics,sf_blade_tip_characteristics,model_sf_blade_tip_characteristics,base.group_user,1,1,1,1
access_sf_handle_type,sf_handle_type,model_sf_handle_type,base.group_user,1,1,1,1
access_sf_cutting_direction,sf_cutting_direction,model_sf_cutting_direction,base.group_user,1,1,1,1
access_sf_suitable_coolant,sf_suitable_coolant,model_sf_suitable_coolant,base.group_user,1,1,1,1
access_sf_cutting_speed,sf_cutting_speed,model_sf_cutting_speed,base.group_user,1,1,1,1
access_sf_feed_per_tooth,sf_feed_per_tooth,model_sf_feed_per_tooth,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
7 access_sf_production_line sf.production.line model_sf_production_line base.group_user 1 1 1 1
8 access_sf_suitable_machining_method sf_suitable_machining_method model_sf_suitable_machining_method base.group_user 1 1 1 1
9 access_sf_blade_tip_characteristics sf_blade_tip_characteristics model_sf_blade_tip_characteristics base.group_user 1 1 1 1
10 access_sf_handle_type sf_handle_type model_sf_handle_type base.group_user 1 1 1 1
11 access_sf_cutting_direction sf_cutting_direction model_sf_cutting_direction base.group_user 1 1 1 1
12 access_sf_suitable_coolant sf_suitable_coolant model_sf_suitable_coolant base.group_user 1 1 1 1
13 access_sf_cutting_speed sf_cutting_speed model_sf_cutting_speed base.group_user 1 1 1 1
14 access_sf_feed_per_tooth sf_feed_per_tooth model_sf_feed_per_tooth base.group_user 1 1 1 1
15
16
17
18

View File

@@ -105,7 +105,7 @@
<field name="name">切削速度Vc</field> <field name="name">切削速度Vc</field>
<field name="model">sf.cutting.speed</field> <field name="model">sf.cutting.speed</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="切削速度Vc" editable="bottom"> <tree string="切削速度Vc" create="1">
<!-- <field name="order"/>--> <!-- <field name="order"/>-->
<field name="execution_standard_id"/> <field name="execution_standard_id"/>
<field name="material_code"/> <field name="material_code"/>
@@ -131,4 +131,27 @@
<field name="res_model">sf.cutting.speed</field> <field name="res_model">sf.cutting.speed</field>
<field name="view_mode">tree</field> <field name="view_mode">tree</field>
</record> </record>
<!-- ======================================== 每齿走刀量fz========================================-->
<record model="ir.ui.view" id="sf_feed_per_tooth_tree">
<field name="name">每齿走刀量fz</field>
<field name="model">sf.feed.per.tooth</field>
<field name="arch" type="xml">
<tree>
<field name="cutting_speed" attrs="{'readonly': [('materials_type_id','!=',False)]}"/>
<field name="materials_type_id" attrs="{'readonly': [('cutting_speed','!=',False)]}"/>
<field name="blade_diameter"/>
<field name="feed_per_tooth"/>
<field name="unit"/>
</tree>
</field>
</record>
<record id="sf_feed_per_tooth_act" model="ir.actions.act_window">
<field name="name">每齿走刀量fz</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.feed.per.tooth</field>
<field name="view_mode">tree</field>
</record>
</odoo> </odoo>

View File

@@ -1,7 +1,7 @@
from odoo import models, fields, api from odoo import models, fields, api
from odoo.modules import get_resource_path from odoo.modules import get_resource_path
from OCC.Extend.DataExchange import read_step_file # from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file # from OCC.Extend.DataExchange import write_stl_file
from odoo.exceptions import ValidationError, UserError from odoo.exceptions import ValidationError, UserError
from odoo.addons.sf_base.commons.common import Common from odoo.addons.sf_base.commons.common import Common
from datetime import datetime from datetime import datetime
@@ -86,22 +86,22 @@ class QuickEasyOrder(models.Model):
return obj return obj
# 将attach的datas内容转为glb文件 # 将attach的datas内容转为glb文件
def transition_glb_file(self, report_path, model_code): # def transition_glb_file(self, report_path, model_code):
shapes = read_step_file(report_path) # shapes = read_step_file(report_path)
# output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl') # # output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl')
output_file = os.path.join('/tmp', str(model_code) + '.stl') # output_file = os.path.join('/tmp', str(model_code) + '.stl')
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5) # write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
# 转化为glb # # 转化为glb
# output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.glb') # # output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.glb')
output_glb_file = os.path.join('/tmp', str(model_code) + '.glb') # output_glb_file = os.path.join('/tmp', str(model_code) + '.glb')
util_path = get_resource_path('sf_dlm', 'static/util') # util_path = get_resource_path('sf_dlm', 'static/util')
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file) # cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
os.system(cmd) # os.system(cmd)
# 转base64 # # 转base64
with open(output_glb_file, 'rb') as fileObj: # with open(output_glb_file, 'rb') as fileObj:
image_data = fileObj.read() # image_data = fileObj.read()
base64_data = base64.b64encode(image_data) # base64_data = base64.b64encode(image_data)
return base64_data # return base64_data
# return False # return False

View File

@@ -102,6 +102,9 @@ class SfToolMaterialSearch(models.Model):
cutting_direction_ids = fields.Many2many('sf.cutting.direction', 'rel_cutting_direction', '走刀方向') cutting_direction_ids = fields.Many2many('sf.cutting.direction', 'rel_cutting_direction', '走刀方向')
suitable_coolant_ids = fields.Many2many('sf.suitable.coolant', 'rel_suitable_coolant', '适合冷却液') suitable_coolant_ids = fields.Many2many('sf.suitable.coolant', 'rel_suitable_coolant', '适合冷却液')
cutting_speed_ids = fields.Many2many('sf.cutting.speed', string='切削速度Vc')
feed_per_tooth_ids = fields.Many2many('sf.feed.per.tooth', 'rel_feed_per_tooth_ids', '每齿走刀量fz')
@api.constrains('suitable_machining_method_ids') @api.constrains('suitable_machining_method_ids')
def _check_suitable_machining_method_ids(self): def _check_suitable_machining_method_ids(self):
for record in self: for record in self:

View File

@@ -240,6 +240,12 @@
<field name="suitable_coolant_ids" string=""/> <field name="suitable_coolant_ids" string=""/>
</group> </group>
</page> </page>
<page string="切削速度Vc" attrs="{'invisible': [('cutting_tool_type','!=','整体式刀具')]}">
<field name="cutting_speed_ids" string=""/>
</page>
<page string="每齿走刀量fz" attrs="{'invisible': [('cutting_tool_type','!=','整体式刀具')]}">
<field name="feed_per_tooth_ids" string=""/>
</page>
<page string="刀杆信息" attrs="{'invisible': [('cutting_tool_type','!=','刀杆')]}"> <page string="刀杆信息" attrs="{'invisible': [('cutting_tool_type','!=','刀杆')]}">
<group> <group>
<group> <group>