Accept Merge Request #913: (feature/夹具物料搜索 -> develop)
Merge Request: 新增夹具物料搜索模型及注册接口 Created By: @禹翔辉 Reviewed By: @马广威 Approved By: @马广威 Accepted By: @禹翔辉 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/913
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
'views/sf_maintenance_equipment.xml',
|
||||
'views/menu_view.xml',
|
||||
'views/tool_material_search.xml',
|
||||
'views/fixture_material_search_views.xml',
|
||||
],
|
||||
'demo': [
|
||||
],
|
||||
|
||||
@@ -3,4 +3,6 @@ from . import tool_material_search
|
||||
from . import maintenance_equipment
|
||||
from . import mrp_workorder
|
||||
from . import functional_tool_enroll
|
||||
from . import fixture_material_search
|
||||
from . import fixture_enroll
|
||||
|
||||
|
||||
82
sf_tool_management/models/fixture_enroll.py
Normal file
82
sf_tool_management/models/fixture_enroll.py
Normal file
@@ -0,0 +1,82 @@
|
||||
import json
|
||||
import base64
|
||||
import requests
|
||||
from odoo import models, api
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class StockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
_description = '夹具物料序列号注册'
|
||||
|
||||
def enroll_fixture_material_stock(self):
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + "/api/fixture_material_stock/create"
|
||||
objs_all = self.env['stock.lot'].search([('id', '=', self.id)])
|
||||
fixture_material_stock_list = []
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
val = {
|
||||
'name': item.name,
|
||||
'tool_material_status': item.tool_material_status,
|
||||
'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
|
||||
'fixture_material_search_id': item.fixture_material_search_id.id,
|
||||
}
|
||||
fixture_material_stock_list.append(val)
|
||||
kw = json.dumps(fixture_material_stock_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return '夹具物料序列号注册成功'
|
||||
else:
|
||||
raise UserError("没有注册夹具物料序列号信息")
|
||||
|
||||
|
||||
class FixtureMaterialSearch(models.Model):
|
||||
_inherit = 'sf.fixture.material.search'
|
||||
_description = '夹具物料搜索注册'
|
||||
|
||||
crea_url = "/api/fixture_material/create"
|
||||
|
||||
def enroll_fixture_material(self):
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.search([('id', '=', self.id)])
|
||||
fixture_material_list = []
|
||||
if objs_all:
|
||||
for obj in objs_all:
|
||||
val = {
|
||||
'name': obj.name,
|
||||
'id': obj.id,
|
||||
'fixture_material_code': obj.fixture_material_id.code,
|
||||
'fixture_model_code': obj.fixture_model_id.code,
|
||||
'specification_name': obj.specification_fixture_id.name,
|
||||
'image': '' if not obj.image else base64.b64encode(obj.image).decode('utf-8'),
|
||||
'number': obj.number,
|
||||
'usable_num': obj.usable_num,
|
||||
'have_been_used_num': obj.have_been_used_num,
|
||||
'scrap_num': obj.scrap_num
|
||||
}
|
||||
fixture_material_list.append(val)
|
||||
kw = json.dumps(fixture_material_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return '夹具物料注册成功'
|
||||
else:
|
||||
raise UserError("没有注册夹具物料信息")
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super(FixtureMaterialSearch, self).create(vals_list)
|
||||
for record in records:
|
||||
if record:
|
||||
record.enroll_fixture_material()
|
||||
return records
|
||||
55
sf_tool_management/models/fixture_material_search.py
Normal file
55
sf_tool_management/models/fixture_material_search.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from odoo import models, fields, api, SUPERUSER_ID
|
||||
|
||||
|
||||
class FixtureMaterialSearch(models.Model):
|
||||
_name = 'sf.fixture.material.search'
|
||||
_description = '夹具物料搜索'
|
||||
|
||||
product_id = fields.Many2one('product.product', string='夹具物料产品')
|
||||
|
||||
name = fields.Char('名称', related='product_id.name')
|
||||
code = fields.Char('编码')
|
||||
fixture_material_id = fields.Many2one('sf.fixture.material', '夹具物料',
|
||||
related='product_id.fixture_material_id',
|
||||
store=True,
|
||||
group_expand='_read_group_fixture_material_id')
|
||||
fixture_material_name = fields.Char('物料名称', related='product_id.fixture_material_id.name')
|
||||
fixture_model_id = fields.Many2one('sf.fixture.model', '夹具型号',
|
||||
related='product_id.fixture_model_id')
|
||||
specification_fixture_id = fields.Many2one('sf.fixture.materials.basic.parameters', '规格',
|
||||
related='product_id.specification_fixture_id')
|
||||
image = fields.Binary('图片', related='product_id.image_1920')
|
||||
number = fields.Integer('总数量', compute='_compute_number')
|
||||
usable_num = fields.Integer('可用数量', compute='_compute_number')
|
||||
have_been_used_num = fields.Integer('在用数量', compute='_compute_number')
|
||||
scrap_num = fields.Integer('报废数量', compute='_compute_number')
|
||||
|
||||
barcode_ids = fields.One2many('stock.lot', 'fixture_material_search_id', string='序列号', readonly=True)
|
||||
|
||||
@api.depends('barcode_ids')
|
||||
def _compute_number(self):
|
||||
for record in self:
|
||||
usable_num = 0
|
||||
have_been_used_num = 0
|
||||
scrap_num = 0
|
||||
if record.barcode_ids:
|
||||
record.number = len(record.barcode_ids)
|
||||
for barcode_id in record.barcode_ids:
|
||||
if barcode_id.quant_ids:
|
||||
if barcode_id.quant_ids[-1].location_id.name not in '夹具房':
|
||||
have_been_used_num = have_been_used_num + 1
|
||||
else:
|
||||
usable_num = usable_num + 1
|
||||
record.usable_num = usable_num
|
||||
record.have_been_used_num = have_been_used_num
|
||||
record.scrap_num = scrap_num
|
||||
else:
|
||||
record.number = 0
|
||||
record.usable_num = 0
|
||||
record.have_been_used_num = 0
|
||||
record.scrap_num = 0
|
||||
|
||||
@api.model
|
||||
def _read_group_fixture_material_id(self, categories, domain, order):
|
||||
fixture_material_id = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
|
||||
return categories.browse(fixture_material_id)
|
||||
@@ -34,14 +34,12 @@ class StockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
_description = '刀具物料序列号注册'
|
||||
|
||||
crea_url = "/api/tool_material_stock/create"
|
||||
|
||||
def enroll_tool_material_stock(self):
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
|
||||
objs_all = self.env['stock.lot'].search([('id', '=', self.id)])
|
||||
tool_material_stock_list = []
|
||||
if objs_all:
|
||||
@@ -61,15 +59,6 @@ class StockLot(models.Model):
|
||||
else:
|
||||
raise UserError("没有注册刀具物料序列号信息")
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super(StockLot, self).create(vals_list)
|
||||
for record in records:
|
||||
if record.product_id.categ_id.name == '刀具':
|
||||
record.tool_material_status = '未入库'
|
||||
record.enroll_tool_material_stock()
|
||||
return records
|
||||
|
||||
|
||||
class ToolMaterial(models.Model):
|
||||
_inherit = 'sf.tool.material.search'
|
||||
@@ -87,10 +76,6 @@ class ToolMaterial(models.Model):
|
||||
tool_material_list = []
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
barcode_names = []
|
||||
for barcode_id in item.barcode_ids:
|
||||
if barcode_id.name:
|
||||
barcode_names.append(barcode_id.name)
|
||||
val = {
|
||||
'name': item.name,
|
||||
'id': item.id,
|
||||
@@ -101,9 +86,7 @@ class ToolMaterial(models.Model):
|
||||
'number': item.number,
|
||||
'usable_num': item.usable_num,
|
||||
'have_been_used_num': item.have_been_used_num,
|
||||
'scrap_num': item.scrap_num,
|
||||
'barcode_names': str(barcode_names),
|
||||
'active': item.active
|
||||
'scrap_num': item.scrap_num
|
||||
}
|
||||
tool_material_list.append(val)
|
||||
kw = json.dumps(tool_material_list, ensure_ascii=False)
|
||||
|
||||
@@ -97,6 +97,7 @@ class StockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
|
||||
tool_material_search_id = fields.Many2one('sf.tool.material.search', string='刀具物料搜索')
|
||||
fixture_material_search_id = fields.Many2one('sf.fixture.material.search', string='夹具物料搜索')
|
||||
tool_material_status = fields.Selection(
|
||||
[('未入库', '未入库'), ('可用', '可用'), ('在用', '在用'), ('报废', '报废')], string='状态',
|
||||
compute='_compute_tool_material_status', store=True)
|
||||
@@ -105,20 +106,20 @@ class StockLot(models.Model):
|
||||
def _compute_tool_material_status(self):
|
||||
for record in self:
|
||||
if record:
|
||||
if record.quant_ids:
|
||||
if record.quant_ids[-1].location_id.name == '刀具房':
|
||||
record.tool_material_status = '可用'
|
||||
elif record.quant_ids[-1].location_id.name == '刀具组装位置':
|
||||
record.tool_material_status = '在用'
|
||||
else:
|
||||
record.tool_material_status = '未入库'
|
||||
|
||||
@api.onchange('tool_material_status')
|
||||
def _onchange_tool_material_status(self):
|
||||
for obj in self:
|
||||
if obj:
|
||||
# 注册刀具物料状态到cloud平台
|
||||
obj.enroll_tool_material_stock()
|
||||
if record.product_id.categ_id.name in ['刀具', '夹具']:
|
||||
if record.quant_ids:
|
||||
if record.quant_ids[-1].location_id.name in ['刀具房', '夹具房']:
|
||||
record.tool_material_status = '可用'
|
||||
elif record.quant_ids[-1].location_id.name == '刀具组装位置':
|
||||
record.tool_material_status = '在用'
|
||||
else:
|
||||
record.tool_material_status = '未入库'
|
||||
if record.tool_material_search_id:
|
||||
# 注册刀具物料状态到cloud平台
|
||||
record.enroll_tool_material_stock()
|
||||
elif record.fixture_material_search_id:
|
||||
# 注册夹具物料状态到cloud平台
|
||||
record.enroll_fixture_material_stock()
|
||||
|
||||
@api.model
|
||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||
@@ -149,7 +150,14 @@ class StockLot(models.Model):
|
||||
tool_material_search = self.env['sf.tool.material.search'].sudo().search(
|
||||
[('id', '=', record.product_id.tool_material_id)])
|
||||
if tool_material_search:
|
||||
record.tool_material_search_id = tool_material_search
|
||||
record.tool_material_status = '未入库'
|
||||
record.tool_material_search_id = tool_material_search.id
|
||||
elif record.product_id.categ_id.name == '夹具':
|
||||
fixture_material_search = self.env['sf.fixture.material.search'].sudo().search(
|
||||
[('id', '=', record.product_id.fixture_material_search_id)])
|
||||
if fixture_material_search:
|
||||
record.tool_material_status = '未入库'
|
||||
record.fixture_material_search_id = fixture_material_search.id
|
||||
return records
|
||||
|
||||
|
||||
@@ -157,6 +165,7 @@ class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
tool_material_id = fields.Char('刀具物料搜索模型ID')
|
||||
fixture_material_search_id = fields.Char('夹具物料搜索模型ID')
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
@@ -167,4 +176,9 @@ class ProductProduct(models.Model):
|
||||
'product_id': record.id
|
||||
})
|
||||
record.tool_material_id = tool_material.id
|
||||
elif record.categ_id.name == '夹具':
|
||||
fixture_material = self.env['sf.fixture.material.search'].sudo().create({
|
||||
'product_id': record.id
|
||||
})
|
||||
record.fixture_material_search_id = fixture_material.id
|
||||
return records
|
||||
|
||||
@@ -2,308 +2,6 @@
|
||||
from odoo import fields, models, api, SUPERUSER_ID
|
||||
|
||||
|
||||
# from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
# 刀具物料搜索(待删除)
|
||||
class SfToolMaterialSearch(models.Model):
|
||||
_name = 'sf.tool.material.search'
|
||||
_description = '刀具物料搜索'
|
||||
|
||||
sequence = fields.Integer('序号')
|
||||
code = fields.Char('编码')
|
||||
name = fields.Char('名称', required=True)
|
||||
# 关联刀具类型
|
||||
mrs_cutting_tool_type_id = fields.Many2one(
|
||||
'sf.cutting.tool.type', '刀具类型',
|
||||
domain="[('cutting_tool_material_id.name', '=', cutting_tool_material_name)]", required=True)
|
||||
# 关联刀具物料名称
|
||||
mrs_cutting_tool_material_name = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料名称',
|
||||
store=True)
|
||||
cutting_tool_type = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料类型', store=True)
|
||||
mrs_machine_brand_id = fields.Many2one('sf.machine.brand', '品牌', required=True,
|
||||
domain="[('tag_ids.name', 'ilike', '刀具')]")
|
||||
# 关联刀具型号
|
||||
# mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', '刀具型号')
|
||||
|
||||
# 关联刀具物料模型
|
||||
mrs_cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料',
|
||||
group_expand='_read_group_mrs_cutting_tool_material_ids',
|
||||
required=True)
|
||||
cutting_tool_material_name = fields.Char(string='物料名称', invisible=True)
|
||||
|
||||
@api.onchange('mrs_cutting_tool_material_id')
|
||||
def _onchange_mrs_cutting_tool_material_id(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.cutting_tool_material_name = record.mrs_cutting_tool_material_id.name
|
||||
|
||||
@api.model
|
||||
def _read_group_mrs_cutting_tool_material_ids(self, categories, domain, order):
|
||||
mrs_cutting_tool_material_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
|
||||
return categories.browse(mrs_cutting_tool_material_ids)
|
||||
|
||||
# 刀片特有字段
|
||||
blade_code = fields.Char('刀片编码', readonly=True)
|
||||
blade_length = fields.Float('刀片长度L(mm)')
|
||||
blade_width = fields.Float('刀片宽度D(mm)')
|
||||
blade_height = fields.Float('刀片高度T(mm)')
|
||||
blade_top_angle = fields.Float('刀片顶角(°)')
|
||||
blade_front_angle = fields.Float('刀片前角(°)')
|
||||
blade_rear_angle = fields.Float('刀片后角(°)')
|
||||
blade_main_included_angle = fields.Float('刀片主偏角(°)')
|
||||
blade_r_angle = fields.Float('刀片R角(°)')
|
||||
blade_hardness = fields.Integer('刀片加工硬度')
|
||||
blade_accuracy = fields.Char('刀片精度等级')
|
||||
blade_coating_material_id = fields.Char('刀片涂层材质')
|
||||
blade_radius = fields.Float('刀片刀尖半径(mm)')
|
||||
blade_nut = fields.Float('刀片配对螺母(mm)')
|
||||
mrs_cutting_tool_model_blade_cutter_bar_ids = fields.Many2many(
|
||||
'sf.cutting_tool.standard.library',
|
||||
relation='sf_tool_material_search_blade_cutter_bar_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('cutting_tool_type', '=', '刀杆')]",
|
||||
string='适用刀杆型号',
|
||||
default=lambda self: [], # 使用空列表作为默认值
|
||||
)
|
||||
mrs_cutting_tool_model_blade_cutter_pad_ids = fields.Many2many(
|
||||
'sf.cutting_tool.standard.library',
|
||||
relation='sf_tool_material_search_blade_cutter_pad_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('cutting_tool_type', '=', '刀盘')]",
|
||||
string='适用刀盘型号',
|
||||
default=lambda self: [], # 使用空列表作为默认值
|
||||
)
|
||||
|
||||
# 整体式刀具特有字段
|
||||
integral_code = fields.Char('整体式刀具编码', readonly=True)
|
||||
integral_total_length = fields.Float('整体式刀具总长度(mm)', digits=(6, 1))
|
||||
integral_shank_length = fields.Float('整体式刀具柄部长度(mm)', digits=(6, 1))
|
||||
integral_blade_length = fields.Float('整体式刀具刃部长度(mm)', digits=(6, 1))
|
||||
integral_neck_length = fields.Float('整体式刀具颈部长度(mm)', digits=(6, 1))
|
||||
integral_shank_diameter = fields.Float('整体式刀具柄部直径(mm)', digits=(6, 1))
|
||||
integral_blade_diameter = fields.Float('整体式刀具刃部直径(mm)', digits=(6, 1))
|
||||
integral_neck_diameter = fields.Float('整体式刀具颈部直径(mm)', digits=(6, 1))
|
||||
integral_blade_number = fields.Integer('整体式刀具刃数(个)')
|
||||
integral_blade_tip_diameter = fields.Float('整体式刀具刀尖直径(mm)', digits=(6, 1))
|
||||
integral_blade_tip_taper = fields.Float('整体式刀具刀尖锥度(°)', digits=(6, 1))
|
||||
integral_blade_helix_angle = fields.Float('整体式刀具刃部螺旋角(°)', digits=(6, 1))
|
||||
integral_blade_type = fields.Char('整体式刀具刃部类型')
|
||||
integral_coarse_medium_fine = fields.Selection([('粗', '粗'), ('中', '中'), ('精', '精')], '整体式刀具粗/中/精')
|
||||
# integral_blade_material = fields.Selection([('碳素钢', '碳素钢'), ('硬质合金', '硬质合金')], '整体式刀具刀具材质')
|
||||
integral_hardness = fields.Integer('整体式刀具硬度(HRC)')
|
||||
integral_coating_material = fields.Char('整体式刀具涂层材质')
|
||||
integral_run_out_accuracy_max = fields.Float('整体式刀具端跳精度max', digits=(6, 1))
|
||||
integral_run_out_accuracy_min = fields.Float('整体式刀具端跳精度min', digits=(6, 1))
|
||||
|
||||
suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image',
|
||||
'rel_machining_product_template_material_search', '适合加工方式',
|
||||
domain=[('type', '=', '加工能力')])
|
||||
blade_tip_characteristics_id = fields.Many2one('maintenance.equipment.image', '刀尖特征',
|
||||
domain=[('type', '=', '刀尖特征')])
|
||||
handle_type_id = fields.Many2one('maintenance.equipment.image', '柄部类型', domain=[('type', '=', '柄部类型')])
|
||||
cutting_direction_ids = fields.Many2many('maintenance.equipment.image',
|
||||
'rel_cutting_product_template_material_search', '走刀方向',
|
||||
domain=[('type', '=', '走刀方向')])
|
||||
suitable_coolant_ids = fields.Many2many('maintenance.equipment.image',
|
||||
'rel_coolants_product_template_material_search', '适合冷却方式',
|
||||
domain=[('type', '=', '冷却方式')])
|
||||
|
||||
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')
|
||||
# def _check_suitable_machining_method_ids(self):
|
||||
# for record in self:
|
||||
# if len(record.suitable_machining_method_ids) == 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("适合加工方式不能为空!")
|
||||
#
|
||||
# @api.constrains('blade_tip_characteristics_ids')
|
||||
# def _check_blade_tip_characteristics_ids(self):
|
||||
# for record in self:
|
||||
# if len(record.blade_tip_characteristics_ids) == 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("刀尖特征不能为空!")
|
||||
# if len(record.blade_tip_characteristics_ids) > 1 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("刀尖特征只能单选!")
|
||||
#
|
||||
# @api.constrains('handle_type_ids')
|
||||
# def _check_handle_type_ids(self):
|
||||
# for record in self:
|
||||
# if len(record.handle_type_ids) == 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("柄部类型不能为空!")
|
||||
# if len(record.handle_type_ids) > 1 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("柄部类型只能单选!")
|
||||
#
|
||||
# @api.constrains('cutting_direction_ids')
|
||||
# def _check_cutting_direction_ids(self):
|
||||
# for record in self:
|
||||
# if len(record.cutting_direction_ids) == 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("走刀方向不能为空!")
|
||||
#
|
||||
# @api.constrains('suitable_coolant_ids')
|
||||
# def _check_suitable_coolant_ids(self):
|
||||
# for record in self:
|
||||
# if not record.suitable_coolant_ids and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("适合冷却液不能为空!")
|
||||
#
|
||||
# @api.constrains('integral_total_length')
|
||||
# def _check_integral_total_length(self):
|
||||
# if self.integral_total_length <= 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("总长度不能为0")
|
||||
#
|
||||
# @api.constrains('integral_shank_length')
|
||||
# def _check_integral_shank_length(self):
|
||||
# if self.integral_shank_length <= 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("柄部长度不能为0")
|
||||
#
|
||||
# @api.constrains('integral_blade_length')
|
||||
# def _check_integral_blade_length(self):
|
||||
# if self.integral_blade_length <= 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("刃部长度不能为0")
|
||||
#
|
||||
# @api.constrains('integral_blade_number')
|
||||
# def _check_integral_blade_number(self):
|
||||
# if self.integral_blade_number <= 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("刃数不能为0")
|
||||
#
|
||||
# @api.constrains('integral_shank_diameter')
|
||||
# def _check_integral_shank_diameter(self):
|
||||
# if self.integral_shank_diameter <= 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("柄部直径不能为0")
|
||||
#
|
||||
# @api.constrains('integral_blade_diameter')
|
||||
# def _check_integral_blade_diameter(self):
|
||||
# if self.integral_blade_diameter <= 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("刃部直径不能为0")
|
||||
#
|
||||
# @api.constrains('integral_run_out_accuracy_min')
|
||||
# def _check_integral_blade_diameter(self):
|
||||
# if self.integral_run_out_accuracy_min <= 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("端跳精度最小(min)不能为0")
|
||||
#
|
||||
# @api.constrains('integral_run_out_accuracy_max')
|
||||
# def _check_integral_run_out_accuracy_max(self):
|
||||
# if self.integral_run_out_accuracy_max <= 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("端跳精度最大(max)不能为0")
|
||||
|
||||
# integral_front_angle = fields.Float('整体式刀具前角(°)')
|
||||
# integral_rear_angle = fields.Float('整体式刀具后角(°)')
|
||||
# integral_main_included_angle = fields.Float('整体式刀具主偏角(°)')
|
||||
# integral_accuracy = fields.Float('整体式刀具精度等级')
|
||||
# integral_hardness = fields.Float('整体式刀具加工硬度(HRC)')
|
||||
# integral_coating_material = fields.Char('整体式刀具涂层材质')
|
||||
# integral_nut = fields.Float('整体式刀具配对螺母(mm)')
|
||||
# integral_scope = fields.Char('整体式刀具适用范围')
|
||||
|
||||
# 刀杆特有字段
|
||||
bar_code = fields.Char('刀杆编码', readonly=True)
|
||||
# bar_name = fields.Char('刀杆名称', required=True)
|
||||
bar_c_diameter = fields.Float('刀杆C柄径(mm)')
|
||||
bar_total_length = fields.Float('刀杆L总长(mm)')
|
||||
bar_blade_number = fields.Integer('刀杆刃数')
|
||||
bar_d_diameter = fields.Float('刀杆D刃径(mm)')
|
||||
mrs_cutting_tool_model_bar_blade_ids = fields.Many2many(
|
||||
'sf.cutting_tool.standard.library',
|
||||
relation='sf_tool_material_search_bar_blade_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('cutting_tool_type', '=', '刀片')]",
|
||||
string='刀杆适用刀片型号'
|
||||
)
|
||||
bar_wrench = fields.Float('刀杆配对扳手(mm)')
|
||||
bar_screw = fields.Float('刀杆配备螺丝(mm)')
|
||||
bar_radius = fields.Float('刀杆刀尖圆角半径')
|
||||
bar_accuracy = fields.Char('刀杆精度等级')
|
||||
bar_hardness = fields.Integer('刀杆硬度(°)')
|
||||
bar_scope = fields.Char('刀杆适用范围')
|
||||
|
||||
# 刀盘特有字段
|
||||
pad_code = fields.Char('刀盘编码', readonly=True)
|
||||
# pad_name = fields.Char('刀盘名称', required=True)
|
||||
pad_c_diameter = fields.Float('刀盘C柄径(mm)')
|
||||
pad_total_length = fields.Float('刀盘L总长(mm)')
|
||||
pad_blade_number = fields.Integer('刀盘刃数')
|
||||
pad_d_diameter = fields.Float('刀盘D刃径(mm)')
|
||||
mrs_cutting_tool_model_pad_blade_ids = fields.Many2many(
|
||||
'sf.cutting_tool.standard.library',
|
||||
relation='sf_tool_material_search_pad_blade_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('cutting_tool_type', '=', '刀片')]",
|
||||
string='刀盘适用刀片型号'
|
||||
)
|
||||
pad_wrench = fields.Float('刀盘配对扳手(mm)')
|
||||
pad_screw = fields.Float('刀盘配备螺丝(mm)')
|
||||
pad_radius = fields.Float('刀盘刀尖圆角半径')
|
||||
pad_accuracy = fields.Char('刀盘精度等级')
|
||||
pad_hardness = fields.Integer('刀盘硬度(°)')
|
||||
pad_scope = fields.Char('刀盘适用范围')
|
||||
|
||||
# 刀柄特有字段
|
||||
handle_code = fields.Char('刀柄编码', readonly=True)
|
||||
# 柄长L(mm)、法兰柄长L1(mm)、法兰直径D1(mm)
|
||||
handle_length = fields.Float('刀柄柄长L(mm)')
|
||||
handle_diameter = fields.Float('刀柄直径D(mm)')
|
||||
handle_flange_length = fields.Float('刀柄法兰柄长L1(mm)')
|
||||
handle_flange_diameter = fields.Float('刀柄法兰直径D1(mm)')
|
||||
# 夹持直径min、夹持直径max、径跳精度、最大转速n/min、3D模型图
|
||||
handle_clamping_diameter_min = fields.Float('刀柄夹持直径min')
|
||||
handle_clamping_diameter_max = fields.Float('刀柄夹持直径max')
|
||||
handle_jump_accuracy = fields.Float('刀柄径跳精度')
|
||||
handle_max_speed = fields.Float('刀柄最大转速n/min')
|
||||
handle_weight = fields.Float('刀柄重量(kg)')
|
||||
handle_body_accuracy = fields.Float('刀柄本体精度(mm)')
|
||||
handle_nut = fields.Float('刀柄配对螺母(mm)')
|
||||
mrs_cutting_tool_model_handle_chuck_model_ids = fields.Many2many(
|
||||
'sf.cutting_tool.standard.library',
|
||||
relation='sf_tool_material_search_handle_chuck_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('cutting_tool_type', '=', '夹头')]",
|
||||
string='适用夹头型号'
|
||||
)
|
||||
handle_clamping_range = fields.Float('刀柄夹持范围(mm)')
|
||||
handle_detection_accuracy = fields.Float('刀柄检测精度')
|
||||
handle_detection_hardness = fields.Integer('刀柄检测硬度')
|
||||
handle_standard_speed = fields.Float('刀柄标准转速')
|
||||
|
||||
# 夹头特有字段
|
||||
chuck_code = fields.Char('夹头编码', readonly=True)
|
||||
# chuck_name = fields.Char('夹头名称', required=True)
|
||||
chuck_accuracy = fields.Float('夹头精度(mm)')
|
||||
# 夹持直径min、夹持直径max、3D模型图
|
||||
chuck_clamping_diameter_min = fields.Float('夹头夹持直径min(mm)')
|
||||
chuck_clamping_diameter_max = fields.Float('夹头夹持直径max(mm)')
|
||||
chuck_diameter = fields.Float('夹头外径(mm)')
|
||||
chuck_inner_diameter = fields.Float('夹头内径(mm)')
|
||||
chuck_height = fields.Float('夹头高度(mm)')
|
||||
chuck_nut = fields.Float('夹头配对螺母(mm)')
|
||||
mrs_cutting_tool_model_chuck_handle_model_ids = fields.Many2many(
|
||||
'sf.cutting_tool.standard.library',
|
||||
relation='sf_tool_material_search_chuck_handle_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('cutting_tool_type', '=', '刀柄')]",
|
||||
string='适用刀柄型号'
|
||||
)
|
||||
chuck_clamping_range = fields.Float('夹头夹持范围(mm)')
|
||||
chuck_feature = fields.Char('夹头特性')
|
||||
image = fields.Binary('夹头图片')
|
||||
|
||||
# 数量、采购入库日期、采购批次、供应商、仓库名称、库区、库位、3D模型
|
||||
number = fields.Integer('数量')
|
||||
mrs_materials_model_id = fields.Many2one('sf.materials.model', '材料型号')
|
||||
purchase_date = fields.Date('采购入库日期')
|
||||
purchase_batch = fields.Char('采购批次')
|
||||
supplier = fields.Char('供应商')
|
||||
warehouse_name = fields.Char('仓库名称')
|
||||
warehouse_area = fields.Char('库区')
|
||||
warehouse_location = fields.Char('库位')
|
||||
three_d_model = fields.Many2one('ir.attachment', '3D模型')
|
||||
|
||||
|
||||
class ToolMaterial(models.Model):
|
||||
_name = 'sf.tool.material.search'
|
||||
_description = '刀具物料搜索'
|
||||
@@ -329,8 +27,6 @@ class ToolMaterial(models.Model):
|
||||
|
||||
barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True)
|
||||
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
@api.depends('barcode_ids')
|
||||
def _compute_number(self):
|
||||
for record in self:
|
||||
|
||||
@@ -13,6 +13,7 @@ access_sf_tool_transfer_request_information,sf.tool.transfer.request.information
|
||||
access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_fixture_material_search,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_sf_tool_user,1,1,1,0
|
||||
|
||||
|
||||
access_sf_functional_cutting_tool_entity_group_plan_dispatch,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,sf_base.group_plan_dispatch,1,0,0,0
|
||||
@@ -29,3 +30,4 @@ access_sf_tool_transfer_request_information_group_plan_dispatch,sf.tool.transfer
|
||||
access_sf_functional_tool_assembly_group_plan_dispatch,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_functional_tool_assembly_order_group_plan_dispatch,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_tool_material_search_group_plan_dispatch,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
|
105
sf_tool_management/views/fixture_material_search_views.xml
Normal file
105
sf_tool_management/views/fixture_material_search_views.xml
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="sf_fixture_material_search_tree" model="ir.ui.view">
|
||||
<field name="name">sf.fixture.material.search.tree</field>
|
||||
<field name="model">sf.fixture.material.search</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="夹具物料查询" create="0">
|
||||
<field name="name"/>
|
||||
<field name="fixture_material_id"/>
|
||||
<field name="fixture_model_id"/>
|
||||
<field name="specification_fixture_id"/>
|
||||
<field name="number"/>
|
||||
<field name="usable_num"/>
|
||||
<field name="image" type="image"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="sf_fixture_material_search_form" model="ir.ui.view">
|
||||
<field name="name">sf.fixture.material.search.form</field>
|
||||
<field name="model">sf.fixture.material.search</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="夹具物料查询" create="0">
|
||||
<!-- <header>-->
|
||||
<!-- <button string="夹具物料注册" name="enroll_fixture_material" type="object" class="btn-primary"/>-->
|
||||
<!-- </header>-->
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<field name="product_id" readonly="1"/>
|
||||
</h1>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name" invisible="1"/>
|
||||
<field name="fixture_material_id"/>
|
||||
<field name="fixture_model_id"/>
|
||||
<field name="specification_fixture_id"/>
|
||||
<field name="number"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="image" type="image"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group col="3">
|
||||
<group>
|
||||
<field name="usable_num"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="have_been_used_num"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="scrap_num"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="序列号">
|
||||
<field name="barcode_ids">
|
||||
<tree create="0">
|
||||
<field name="name"/>
|
||||
<field name="tool_material_status"/>
|
||||
<!-- <button string="序列号注册" name="enroll_fixture_material_stock" type="object"-->
|
||||
<!-- class="btn-primary"/>-->
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_fixture_material_search_search" model="ir.ui.view">
|
||||
<field name="name">sf.fixture.material.search.search</field>
|
||||
<field name="model">sf.fixture.material.search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="夹具物料搜索">
|
||||
<field name="name" string="名称搜索" filter_domain="[('name','ilike',self)]"/>
|
||||
<field name="fixture_material_id" string="夹具型号搜索"/>
|
||||
<field name="specification_fixture_id" string="规格搜索"/>
|
||||
<searchpanel>
|
||||
<field name="fixture_material_id" icon="fa-building" enable_counters="1"/>
|
||||
</searchpanel>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_sf_fixture_material_search" model="ir.actions.act_window">
|
||||
<field name="name">夹具物料查询</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.fixture.material.search</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
sequence="25"
|
||||
name="夹具物料查询"
|
||||
id="menu_sf_fixture_material_search"
|
||||
action="action_sf_fixture_material_search"
|
||||
parent="menu_sf_tool_manage"
|
||||
/>
|
||||
</odoo>
|
||||
@@ -82,7 +82,6 @@
|
||||
<field name="name" string="名称搜索" filter_domain="[('name','ilike',self)]"/>
|
||||
<field name="cutting_tool_standard_library_id" string="刀具型号搜索"/>
|
||||
<field name="specification_id" string="规格搜索"/>
|
||||
<filter string="已归档" name="inactive" domain="[('active', '=', False)]"/>
|
||||
<searchpanel>
|
||||
<field name="cutting_tool_material_id" icon="fa-building" enable_counters="1"/>
|
||||
</searchpanel>
|
||||
|
||||
Reference in New Issue
Block a user