优化刀具产品

This commit is contained in:
jinling.yang
2024-03-12 17:32:40 +08:00
parent 0289e2f9ff
commit 0c44bba5f2
9 changed files with 238 additions and 159 deletions

View File

@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json from datetime import date
import requests
from odoo import fields, models, api from odoo import fields, models, api
from odoo.exceptions import ValidationError
from odoo.addons.sf_base.commons.common import Common
class CuttingToolMaterial(models.Model): class CuttingToolMaterial(models.Model):
@@ -113,6 +110,24 @@ class CuttingToolModel(models.Model):
feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz(整体式刀具)') feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz(整体式刀具)')
feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz(刀片)') feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz(刀片)')
material_model_id = fields.Many2one('sf.materials.model', '材料型号') material_model_id = fields.Many2one('sf.materials.model', '材料型号')
@api.onchange('cutting_tool_material_id')
def _get_code(self):
if self.is_cloud is False:
today = date.today().strftime("%Y%m%d")
today_code = 'T-DJWL-%s-%s' % (self.cutting_tool_material_id.code, today)
cutting_tool_model = self.search(
[('code', 'ilike', today_code), ('is_cloud', '=', False),
('active', 'in', [True, False])],
limit=1,
order="id desc")
if not cutting_tool_model:
num = "%03d" % 1
else:
m = int(today_code[-3:]) + 1
num = "%03d" % m
return "%s%s" % (today_code, num)
# 适用夹头型号可以多选 # 适用夹头型号可以多选
# chuck_ids = fields.Many2many( # chuck_ids = fields.Many2many(
# 'sf.cutting_tool.standard.library', # 'sf.cutting_tool.standard.library',

View File

@@ -10,6 +10,7 @@ class ToolMaterialsBasicParameters(models.Model):
standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具标准库') standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具标准库')
cutting_tool_type = fields.Char(related='standard_library_id.cutting_tool_type', string='刀具物料类型', cutting_tool_type = fields.Char(related='standard_library_id.cutting_tool_type', string='刀具物料类型',
store=True) store=True)
is_cloud = fields.Boolean(related='standard_library_id.is_cloud', string='云端数据')
# 整体式刀具参数 # 整体式刀具参数
total_length = fields.Float('总长度(mm)') total_length = fields.Float('总长度(mm)')
@@ -170,8 +171,6 @@ class FeedPerTooth(models.Model):
feed_per_tooth = fields.Char('每齿走刀量 (mm/z)', size=20) feed_per_tooth = fields.Char('每齿走刀量 (mm/z)', size=20)
active = fields.Boolean(string='有效', default=True) active = fields.Boolean(string='有效', default=True)
# @api.depends('product_template_id') # @api.depends('product_template_id')
# def _compute_product_template_id(self): # def _compute_product_template_id(self):
# if self.product_template_id is not None: # if self.product_template_id is not None:

View File

@@ -118,12 +118,69 @@
</field> </field>
</record> </record>
<record id="view_sf_tool_materials_basic_parameters_form" model="ir.ui.view">
<field name="name">sf.tool.materials.basic.parameters.form</field>
<field name="model">sf.tool.materials.basic.parameters</field>
<field name="arch" type="xml">
<form string="规则">
<sheet>
<field name="cutting_tool_type"/>
<field name="standard_library_id"/>
<group>
<group attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')]}">
<field name="total_length"/>
<field name="blade_number"/>
<field name="neck_diameter"/>
<field name="neck_length"/>
<field name="handle_diameter"/>
<field name="handle_length"/>
<field name="blade_tip_diameter"/>
<field name="blade_tip_working_size"/>
<field name="blade_tip_taper"/>
</group>
<group attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')]}">
<field name="blade_diameter"/>
<field name="blade_length"/>
<field name="blade_helix_angle"/>
<field name="blade_width"/>
<field name="blade_width"/>
<field name="pitch"/>
<field name="cutting_depth"/>
</group>
<group attrs="{'invisible': [('cutting_tool_type', '!=', '刀片')]}">
<field name="total_length"/>
<field name="length"/>
<field name="thickness"/>
<field name="width"/>
<field name="cutting_blade_length"/>
<field name="relief_angle"/>
<field name="blade_tip_circular_arc_radius"/>
<field name="inscribed_circle_diameter"/>
<field name="install_aperture_diameter"/>
<field name="chip_breaker_groove"/>
<field name="blade_teeth_model"/>
<field name="blade_blade_number"/>
</group>
<group attrs="{'invisible': [('cutting_tool_type', '!=', '刀片')]}">
<field name="main_included_angle"/>
<field name="top_angle"/>
<field name="thread_model"/>
<field name="thread_num"/>
<field name="blade_tip_height_tolerance"/>
<field name="inscribed_circle_tolerance"/>
<field name="thickness_tolerance"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_sf_tool_materials_basic_parameters" model="ir.actions.act_window"> <record id="action_sf_tool_materials_basic_parameters" model="ir.actions.act_window">
<field name="name">基础参数</field> <field name="name">基础参数</field>
<field name="res_model">sf.tool.materials.basic.parameters</field> <field name="res_model">sf.tool.materials.basic.parameters</field>
<field name="view_mode">tree</field> <field name="view_mode">form</field>
<field name="context">{'default_cutting_tool_type': cutting_tool_type}</field>
<!-- <field name="context">{'selection_mode': 'single'}</field>-->
<field name="domain">[]</field> <field name="domain">[]</field>
<!-- <field name="multi">false</field>--> <!-- <field name="multi">false</field>-->
</record> </record>

View File

@@ -123,7 +123,7 @@
<form string="刀具标准库" delete="0" create="0" edit="0"> <form string="刀具标准库" delete="0" create="0" edit="0">
<sheet> <sheet>
<field name="image" widget='image' class="oe_avatar" <field name="image" widget='image' class="oe_avatar"
options="{'zoom': true, 'preview_image':'image_128'}"/> options="{'zoom': true, 'preview_image':'image_128'}" required="1"/>
<div class="oe_title"> <div class="oe_title">
<h1> <h1>
<field name="code"/> <field name="code"/>
@@ -133,9 +133,9 @@
<group> <group>
<field name="name"/> <field name="name"/>
<field name="cutting_tool_material_id"/> <field name="cutting_tool_material_id"/>
<field name="cutting_tool_type"/> <field name="cutting_tool_type" readonly="1"/>
<field name="cutting_tool_type_id"/> <field name="cutting_tool_type_id" required="1"/>
<field name="brand_id"/> <field name="brand_id" required="1"/>
<label for="integral_run_out_accuracy_min" string="端跳精度" <label for="integral_run_out_accuracy_min" string="端跳精度"
attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')]}"/> attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')]}"/>
<div class="o_address_format" <div class="o_address_format"

View File

@@ -15,7 +15,7 @@
attrs="{'invisible': ['|', '|',('categ_type', '!=', '成品'),('categ_type', '=', False),('is_bfm','=', True)]}"/> attrs="{'invisible': ['|', '|',('categ_type', '!=', '成品'),('categ_type', '=', False),('is_bfm','=', True)]}"/>
<field name="model_file" widget="Viewer3D" string="模型" readonly="1" force_save="1" <field name="model_file" widget="Viewer3D" string="模型" readonly="1" force_save="1"
attrs="{'invisible': ['|','|', ('categ_type', '!=', '成品'),('categ_type', '=', False),('model_file', '=', False)]}"/> attrs="{'invisible': ['|','|', ('categ_type', '!=', '成品'),('categ_type', '=', False),('model_file', '=', False)]}"/>
<field name='cutting_tool_type' invisible="1"/> <field name='cutting_tool_type'/>
<field name="fixture_material_type" invisible="1"/> <field name="fixture_material_type" invisible="1"/>
<field name="embryo_model_type_id" string="模型类型" options="{'no_create': True}" <field name="embryo_model_type_id" string="模型类型" options="{'no_create': True}"
attrs="{'invisible': ['|',('categ_type', '!=', '坯料'),('categ_type', '=', False)],'readonly': [('id', '!=', False)]}"/> attrs="{'invisible': ['|',('categ_type', '!=', '坯料'),('categ_type', '=', False)],'readonly': [('id', '!=', False)]}"/>
@@ -32,9 +32,11 @@
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}" attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}"
placeholder="请选择"/> placeholder="请选择"/>
<field name="cutting_tool_model_id" placeholder="请选择" class="custom_required" <field name="cutting_tool_model_id" placeholder="请选择" class="custom_required"
options="{'no_create': True}" domain="[('cutting_tool_material_id','=',cutting_tool_material_id)]"
context="{'default_cutting_tool_material_id': cutting_tool_material_id}"
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}"/> attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}"/>
<field name="specification_id" placeholder="请选择" class="custom_required" <field name="specification_id" placeholder="请选择" class="custom_required"
context="{'default_cutting_tool_type': cutting_tool_type}"
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}" attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}"
domain="[('standard_library_id','=',cutting_tool_model_id)]"/> domain="[('standard_library_id','=',cutting_tool_model_id)]"/>
<field name="fixture_material_id" attrs="{'invisible': [('categ_type', '!=', '夹具')]}" <field name="fixture_material_id" attrs="{'invisible': [('categ_type', '!=', '夹具')]}"

View File

@@ -6,8 +6,10 @@ import os
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 write_stl_file
# from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file
class ResProductMo(models.Model): class ResProductMo(models.Model):
@@ -101,6 +103,10 @@ class ResProductMo(models.Model):
compaction_way_id = fields.Many2one('maintenance.equipment.image', compaction_way_id = fields.Many2one('maintenance.equipment.image',
'压紧方式', domain=[('type', '=', '压紧方式')]) '压紧方式', domain=[('type', '=', '压紧方式')])
@api.onchange('cutting_tool_model_id')
def _onchange_cutting_tool_model_id(self):
self.specification_id = False
@api.onchange('cutting_tool_material_id') @api.onchange('cutting_tool_material_id')
def _onchange_cutting_tool_material_id(self): def _onchange_cutting_tool_material_id(self):
for item in self: for item in self:
@@ -350,30 +356,30 @@ class ResProductMo(models.Model):
self.cutting_speed_ids = False self.cutting_speed_ids = False
self.feed_per_tooth_ids = False self.feed_per_tooth_ids = False
@api.constrains('fit_blade_shape_id', 'suitable_machining_method_ids', 'blade_tip_characteristics_id', # @api.constrains('fit_blade_shape_id', 'suitable_machining_method_ids', 'blade_tip_characteristics_id',
'handle_type_id', 'cutting_direction_ids', 'suitable_coolant_ids', 'compaction_way_id') # 'handle_type_id', 'cutting_direction_ids', 'suitable_coolant_ids', 'compaction_way_id')
def _check_cutting_tool_ability(self): # def _check_cutting_tool_ability(self):
if self.cutting_tool_type in ['整体式刀具', '刀片', '刀杆', '刀盘']: # if self.cutting_tool_type in ['整体式刀具', '刀片', '刀杆', '刀盘']:
if self.cutting_tool_type in ['刀片', '刀杆', '刀盘']: # if self.cutting_tool_type in ['刀片', '刀杆', '刀盘']:
if not self.fit_blade_shape_id: # if not self.fit_blade_shape_id:
raise ValidationError("请选择适配刀片形状") # raise ValidationError("请选择适配刀片形状")
if self.cutting_tool_type in ['刀杆', '刀盘']: # if self.cutting_tool_type in ['刀杆', '刀盘']:
if not self.compaction_way_id: # if not self.compaction_way_id:
raise ValidationError("请选择压紧方式") # raise ValidationError("请选择压紧方式")
if self.cutting_tool_type == '刀片': # if self.cutting_tool_type == '刀片':
if not self.suitable_coolant_ids: # if not self.suitable_coolant_ids:
raise ValidationError("请选择适合冷却方式") # raise ValidationError("请选择适合冷却方式")
elif self.cutting_tool_type == '整体式刀具': # elif self.cutting_tool_type == '整体式刀具':
if not self.handle_type_id: # if not self.handle_type_id:
raise ValidationError("请选择柄部类型") # raise ValidationError("请选择柄部类型")
if not self.suitable_coolant_ids: # if not self.suitable_coolant_ids:
raise ValidationError("请选择适合冷却方式") # raise ValidationError("请选择适合冷却方式")
if not self.suitable_machining_method_ids: # if not self.suitable_machining_method_ids:
raise ValidationError("请选择适合加工方式") # raise ValidationError("请选择适合加工方式")
if not self.blade_tip_characteristics_id: # if not self.blade_tip_characteristics_id:
raise ValidationError("请选择刀尖特征") # raise ValidationError("请选择刀尖特征")
if not self.cutting_direction_ids: # if not self.cutting_direction_ids:
raise ValidationError("请选择走刀方向") # raise ValidationError("请选择走刀方向")
cutting_speed_ids = fields.One2many('sf.cutting.speed', 'product_template_id', string='切削速度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') feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'product_template_id', string='每齿走刀量fz')

View File

@@ -2,7 +2,7 @@
import logging import logging
from odoo.modules import get_resource_path from odoo.modules import get_resource_path
from odoo import fields, models, api from odoo import fields, models, api
from quatotion import readSql, feature_recognize, auto_quatotion # from quatotion import readSql, feature_recognize, auto_quatotion
__author__ = 'jinling.yang' __author__ = 'jinling.yang'
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)

View File

@@ -8,8 +8,8 @@ from datetime import datetime
import requests import requests
from odoo import http from odoo import http
from odoo.http import request from odoo.http import request
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 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 odoo.exceptions import ValidationError, UserError from odoo.exceptions import ValidationError, UserError

View File

@@ -1,7 +1,7 @@
import datetime import datetime
import base64 import base64
from odoo import models, fields, api, _ from odoo import models, fields, api, _
from odoo.exceptions import UserError from odoo.exceptions import UserError, ValidationError
class ReSaleOrder(models.Model): class ReSaleOrder(models.Model):
@@ -99,7 +99,7 @@ class ReSaleOrder(models.Model):
def check_order_line(self): def check_order_line(self):
for item in self: for item in self:
if not item.order_line: if not item.order_line:
raise UserError('请选择【订单行】中的【产品】') raise ValidationError('请选择【订单行】中的【产品】')
for line in item.order_line: for line in item.order_line:
if not line.product_template_id: if not line.product_template_id:
raise UserError('请对【订单行】中的【产品】进行选择') raise UserError('请对【订单行】中的【产品】进行选择')