Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化agv和ftp

# Conflicts:
#	sf_manufacturing/models/mrp_production.py
#	sf_manufacturing/models/mrp_workorder.py
#	sf_mrs_connect/models/ftp_operate.py
#	sf_sale/models/quick_easy_order_old.py
This commit is contained in:
jinling.yang
2024-04-19 11:28:50 +08:00
38 changed files with 2005 additions and 1483 deletions

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from datetime import date from datetime import date
from odoo import fields, models, api from odoo import fields, models, api
from odoo.exceptions import UserError
class CuttingToolMaterial(models.Model): class CuttingToolMaterial(models.Model):
@@ -333,3 +334,16 @@ class ToolInventory(models.Model):
tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组') tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组')
active = fields.Boolean('已归档', default=True) active = fields.Boolean('已归档', default=True)
@api.model_create_multi
def create(self, vals_list):
# 名称重复校验
name_list = []
for val in vals_list:
tool_inventory = self.search([('name', '=', val['name'])])
if tool_inventory:
name_list.append(val['name'])
if name_list:
raise UserError("功能刀具名称%s已存在,请重新输入" % name_list)
records = super(ToolInventory, self).create(vals_list)
return records

View File

@@ -200,3 +200,17 @@ access_group_sf_mrp_user_group_purchase_director,sf_tool_inventory_group_purchas
access_group_sf_mrp_user_group_sale_director,sf_tool_inventory_group_sale_director,model_sf_tool_inventory,sf_base.group_sale_director,1,0,1,0 access_group_sf_mrp_user_group_sale_director,sf_tool_inventory_group_sale_director,model_sf_tool_inventory,sf_base.group_sale_director,1,0,1,0
access_sf_cutting_tool_material_group_plan_director,sf_tool_inventory_group_plan_director,model_sf_tool_inventory,sf_base.group_plan_director,1,0,1,0 access_sf_cutting_tool_material_group_plan_director,sf_tool_inventory_group_plan_director,model_sf_tool_inventory,sf_base.group_plan_director,1,0,1,0
access_group_sf_mrp_user_group_sf_mrp_user,sf_tool_inventory_group_sf_mrp_user,model_sf_tool_inventory,sf_base.group_sf_mrp_user,1,1,0,0 access_group_sf_mrp_user_group_sf_mrp_user,sf_tool_inventory_group_sf_mrp_user,model_sf_tool_inventory,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_fixture_material_group_purchase_director,sf_fixture_material_group_purchase_director,model_sf_fixture_material,sf_base.group_purchase_director,1,0,0,0
access_sf_multi_mounting_type_group_purchase_director,sf_multi_mounting_type_group_purchase_director,model_sf_multi_mounting_type,sf_base.group_purchase_director,1,0,0,0
access_sf_fixture_model_group_purchase_director,sf_fixture_model_group_purchase_director,model_sf_fixture_model,sf_base.group_purchase_director,1,0,0,0
access_sf_fixture_materials_basic_parameters_group_purchase_director,sf_fixture_materials_basic_parameters_group_purchase_director,model_sf_fixture_materials_basic_parameters,sf_base.group_purchase_director,1,0,0,0
access_sf_machine_tool_type_group_purchase_director,sf_machine_tool_type_group_purchase_director,model_sf_machine_tool_type,sf_base.group_purchase_director,1,0,0,0
access_sf_fixture_material_group_sale_director,sf_fixture_material_group_sale_director,model_sf_fixture_material,sf_base.group_sale_director,1,0,0,0
access_sf_multi_mounting_type_group_sale_director,sf_multi_mounting_type_group_sale_director,model_sf_multi_mounting_type,sf_base.group_sale_director,1,0,0,0
access_sf_fixture_model_group_sale_director,sf_fixture_model_group_sale_director,model_sf_fixture_model,sf_base.group_sale_director,1,0,0,0
access_sf_fixture_materials_basic_parameters_group_sale_director,sf_fixture_materials_basic_parameters_group_sale_director,model_sf_fixture_materials_basic_parameters,sf_base.group_sale_director,1,0,0,0
access_sf_machine_tool_type_group_sale_director,sf_machine_tool_type_group_sale_director,model_sf_machine_tool_type,sf_base.group_sale_director,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
200 access_sf_machine_tool_type_group_purchase_director sf_machine_tool_type_group_purchase_director model_sf_machine_tool_type sf_base.group_purchase_director 1 0 0 0
201 access_sf_fixture_material_group_sale_director sf_fixture_material_group_sale_director model_sf_fixture_material sf_base.group_sale_director 1 0 0 0
202 access_sf_multi_mounting_type_group_sale_director sf_multi_mounting_type_group_sale_director model_sf_multi_mounting_type sf_base.group_sale_director 1 0 0 0
203 access_sf_fixture_model_group_sale_director sf_fixture_model_group_sale_director model_sf_fixture_model sf_base.group_sale_director 1 0 0 0
204 access_sf_fixture_materials_basic_parameters_group_sale_director sf_fixture_materials_basic_parameters_group_sale_director model_sf_fixture_materials_basic_parameters sf_base.group_sale_director 1 0 0 0
205 access_sf_machine_tool_type_group_sale_director sf_machine_tool_type_group_sale_director model_sf_machine_tool_type sf_base.group_sale_director 1 0 0 0
206
207
208
209
210
211
212
213
214
215
216

View File

@@ -21,7 +21,7 @@
<field name="name">刀具标准库</field> <field name="name">刀具标准库</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.cutting_tool.standard.library</field> <field name="res_model">sf.cutting_tool.standard.library</field>
<!-- <field name="context">{'default_cutting_tool_material_id': cutting_tool_material_id}</field>--> <!-- <field name="context">{'default_cutting_tool_material_id': cutting_tool_material_id}</field>-->
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
</record> </record>
<!-- 功能刀具action --> <!-- 功能刀具action -->
@@ -69,14 +69,22 @@
sequence="20" sequence="20"
action="action_sf_cutting_tool_standard_library" action="action_sf_cutting_tool_standard_library"
/> />
<menuitem
id="menu_sf_tool_inventory"
parent="menu_sf_cutting_tool"
name="功能刀具清单"
sequence="25"
action="action_sf_tool_inventory"
/>
<!-- 功能刀具 --> <!-- 功能刀具 -->
<!-- <menuitem--> <!-- <menuitem-->
<!-- id="menu_sf_functional_cutting_tool"--> <!-- id="menu_sf_functional_cutting_tool"-->
<!-- parent="menu_sf_cutting_tool"--> <!-- parent="menu_sf_cutting_tool"-->
<!-- name="功能刀具"--> <!-- name="功能刀具"-->
<!-- sequence="5"--> <!-- sequence="5"-->
<!-- action="action_sf_functional_cutting_tool"--> <!-- action="action_sf_functional_cutting_tool"-->
<!-- />--> <!-- />-->
<!-- 功能刀具类型 --> <!-- 功能刀具类型 -->
<menuitem <menuitem
id="menu_sf_functional_cutting_tool_model_type" id="menu_sf_functional_cutting_tool_model_type"
@@ -87,18 +95,18 @@
/> />
<menuitem <menuitem
id="menu_sf_maintenance_equipment_image" id="menu_sf_maintenance_equipment_image"
name="能力特征库" name="能力特征库"
parent="menu_sf_cutting_tool" parent="menu_sf_cutting_tool"
action="action_maintenance_equipment_image" action="action_maintenance_equipment_image"
sequence="40"/> sequence="40"/>
<menuitem <menuitem
id="menu_sf_tool_groups" id="menu_sf_tool_groups"
name="刀具组" name="刀具组"
parent="menu_sf_cutting_tool" parent="menu_sf_cutting_tool"
action="sf_tool_groups_view_act" action="sf_tool_groups_view_act"
sequence="50"/> sequence="50"/>
</data> </data>
</odoo> </odoo>

View File

@@ -609,13 +609,4 @@
<field name="view_mode">tree</field> <field name="view_mode">tree</field>
</record> </record>
<menuitem
id="menu_sf_tool_inventory"
parent="menu_sf_cutting_tool"
name="功能刀具清单"
sequence="25"
action="action_sf_tool_inventory"
/>
</odoo> </odoo>

View File

@@ -10,6 +10,7 @@
<field name='categ_id' class="custom_required" attrs="{'readonly': [('id', '!=', False)]}"/> <field name='categ_id' class="custom_required" attrs="{'readonly': [('id', '!=', False)]}"/>
<field name='is_bfm' invisible="1"/> <field name='is_bfm' invisible="1"/>
<field name='categ_type' invisible="1"/> <field name='categ_type' invisible="1"/>
<field name='manual_quotation' attrs="{'invisible':[('upload_model_file', '=', [])]}"/>
<field name="upload_model_file" <field name="upload_model_file"
widget="many2many_binary" widget="many2many_binary"
attrs="{'invisible': ['|', '|',('categ_type', '!=', '成品'),('categ_type', '=', False),('is_bfm','=', True)]}"/> attrs="{'invisible': ['|', '|',('categ_type', '!=', '成品'),('categ_type', '=', False),('is_bfm','=', True)]}"/>

View File

@@ -115,7 +115,7 @@ class Manufacturing_Connect(http.Controller):
logging.info('RfidCode:%s' % ret['RfidCode']) logging.info('RfidCode:%s' % ret['RfidCode'])
if 'RfidCode' in ret: if 'RfidCode' in ret:
workorder = request.env['mrp.workorder'].sudo().search( workorder = request.env['mrp.workorder'].sudo().search(
[('routing_type', '=', '装夹预调'), ('rfid_code', '=', ret['RfidCode'])]) [('routing_type', '=', '装夹预调'), ('rfid_code', '=', ret['RfidCode'])], limit=1, order='id asc')
if workorder: if workorder:
for item in workorder: for item in workorder:
if item.material_center_point: if item.material_center_point:
@@ -123,8 +123,8 @@ class Manufacturing_Connect(http.Controller):
res['Datas'].append({ res['Datas'].append({
'XOffset': 0 if not item.material_center_point else offset[0], 'XOffset': 0 if not item.material_center_point else offset[0],
'YOffset': 0 if not item.material_center_point else offset[1], 'YOffset': 0 if not item.material_center_point else offset[1],
'ZOffet': 0 if not item.material_center_point else offset[2], 'ZOffset': 0 if not item.material_center_point else offset[2],
'COffset': 0 if not item.X_deviation_angle else item.X_deviation_angle, 'COffset': 0,
'Coordinate': 'G54' 'Coordinate': 'G54'
}) })
else: else:

View File

@@ -57,6 +57,8 @@ class MrpProduction(models.Model):
production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')], production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
string='上/下产线', default='待上产线') string='上/下产线', default='待上产线')
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
@api.depends( @api.depends(
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state') 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state')
@@ -132,6 +134,14 @@ class MrpProduction(models.Model):
# cnc程序获取 # cnc程序获取
def fetchCNC(self): def fetchCNC(self):
cnc = self.env['mrp.production'].search([('id', '=', self.id)]) cnc = self.env['mrp.production'].search([('id', '=', self.id)])
quick_order = self.env['quick.easy.order'].search([('id', '=', cnc.product_id.id)])
programme_way = False
if cnc.manual_quotation is True:
programme_way = 'manual operation'
else:
programme_way = 'auto'
if quick_order:
programme_way = 'manual operation'
try: try:
res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code, res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code,
'production_no': cnc.name, 'production_no': cnc.name,
@@ -146,8 +156,9 @@ class MrpProduction(models.Model):
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height, 'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width, 'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
'order_no': cnc.origin, 'order_no': cnc.origin,
'model_order_no': '-'.join(cnc.product_id.default_code.split('-')[:4]), 'model_order_no': cnc.product_id.default_code,
'user': cnc.env.user.name, 'user': cnc.env.user.name,
'programme_way': programme_way,
'model_file': '' if not cnc.product_id.model_file else base64.b64encode( 'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
cnc.product_id.model_file).decode('utf-8') cnc.product_id.model_file).decode('utf-8')
} }

View File

@@ -46,6 +46,8 @@ class ResMrpWorkOrder(models.Model):
], string="工序类型") ], string="工序类型")
results = fields.Char('结果') results = fields.Char('结果')
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
@api.onchange('users_ids') @api.onchange('users_ids')
def get_user_permissions(self): def get_user_permissions(self):
uid = self.env.uid uid = self.env.uid
@@ -364,6 +366,7 @@ class ResMrpWorkOrder(models.Model):
y7 = self.Y7_axis y7 = self.Y7_axis
y8 = self.Y8_axis y8 = self.Y8_axis
z1 = self.Z9_axis z1 = self.Z9_axis
z2 = self.Z10_axis
x0 = ((x3 - x4) * (x2 * y1 - x1 * y2) - (x1 - x2) * (x4 * y3 - x3 * y4)) / ( x0 = ((x3 - x4) * (x2 * y1 - x1 * y2) - (x1 - x2) * (x4 * y3 - x3 * y4)) / (
(x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4)) (x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4))
y0 = ((y3 - y4) * (y2 * x1 - y1 * x2) - (y1 - y2) * (y4 * x3 - y3 * x4)) / ( y0 = ((y3 - y4) * (y2 * x1 - y1 * x2) - (y1 - y2) * (y4 * x3 - y3 * x4)) / (
@@ -374,7 +377,7 @@ class ResMrpWorkOrder(models.Model):
(y7 - y8) * (x5 - x6) - (y5 - y6) * (x7 - x8)) (y7 - y8) * (x5 - x6) - (y5 - y6) * (x7 - x8))
x = (x0 + x1) / 2 x = (x0 + x1) / 2
y = (y0 + y1) / 2 y = (y0 + y1) / 2
z = z1 / 2 z = (z1 + z2) / 2
jd = math.atan2((x5 - x6), (y5 - y6)) jd = math.atan2((x5 - x6), (y5 - y6))
jdz = jd * 180 / math.pi jdz = jd * 180 / math.pi
@@ -815,7 +818,7 @@ class ResMrpWorkOrder(models.Model):
production_no_ftp = reportpath.split('/') production_no_ftp = reportpath.split('/')
production_no = workorder.production_id.name.replace('/', '_') production_no = workorder.production_id.name.replace('/', '_')
# ftp地址 # ftp地址
remotepath = os.path.join('/NC/', production_no_ftp[1], 'detection') remotepath = os.path.join('/NC', production_no_ftp[1], 'detection')
logging.info('ftp地址:%s' % remotepath) logging.info('ftp地址:%s' % remotepath)
if reportpath.find(production_no) != -1: if reportpath.find(production_no) != -1:
# 服务器内临时地址 # 服务器内临时地址
@@ -894,7 +897,7 @@ class CNCprocessing(models.Model):
'cutting_tool_handle_type': obj['cutting_tool_handle_type'], 'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
'estimated_processing_time': obj['estimated_processing_time'], 'estimated_processing_time': obj['estimated_processing_time'],
'remark': obj['remark'], 'remark': obj['remark'],
'program_path': program_path.replace('/tmp', '') 'program_path': program_path.replace('/tmp', '/home/ftp/ftp_root/NC')
}) })
cnc_processing.get_cnc_processing_file(program_path_tmp, cnc_processing, program_path) cnc_processing.get_cnc_processing_file(program_path_tmp, cnc_processing, program_path)
# cnc_workorder.state = 'done' # cnc_workorder.state = 'done'
@@ -933,7 +936,7 @@ class CNCprocessing(models.Model):
# 将FTP的nc文件下载到临时目录 # 将FTP的nc文件下载到临时目录
def download_file_tmp(self, production_no, processing_panel): def download_file_tmp(self, production_no, processing_panel):
remotepath = os.path.join('/NC/', production_no, 'return', processing_panel) remotepath = os.path.join('/NC', production_no, 'return', processing_panel)
serverdir = os.pat.join('/tmp', production_no, 'return', processing_panel) serverdir = os.pat.join('/tmp', production_no, 'return', processing_panel)
ftp_resconfig = self.env['res.config.settings'].get_values() ftp_resconfig = self.env['res.config.settings'].get_values()
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'], ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
@@ -986,15 +989,16 @@ class SfWorkOrderBarcodes(models.Model):
workorder = self.env['mrp.workorder'].browse(self.ids) workorder = self.env['mrp.workorder'].browse(self.ids)
# workorder = self.env['mrp.workorder'].search( # workorder = self.env['mrp.workorder'].search(
# [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)]) # [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)])
# workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)]) workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)])
# if workorder_old: if workorder_old:
# raise UserError('该托盘已绑定工件,请先解除绑定!!!') raise UserError('该托盘已绑定工件,请先解除绑定!!!')
if workorder: if workorder:
if workorder.routing_type == '装夹预调': if workorder.routing_type == '装夹预调':
if workorder.state in ['progress', 'done']: if workorder.state in ['done']:
work_state = {'progress': '进行中', 'done': '已完工'} work_state = {'done': '已完工'}
raise UserError('该工单%s不能重新绑定托盘' % work_state.get(workorder.state)) raise UserError('装夹%s请勿重复扫码' % work_state.get(workorder.state))
lots = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)]) lots = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)])
logging.info("托盘信息:%s" % lots)
if lots: if lots:
for lot in lots: for lot in lots:
if lot.product_id.categ_type == '夹具': if lot.product_id.categ_type == '夹具':
@@ -1013,6 +1017,7 @@ class SfWorkOrderBarcodes(models.Model):
if workorder_rfid: if workorder_rfid:
for item in workorder_rfid: for item in workorder_rfid:
item.write({'rfid_code': barcode}) item.write({'rfid_code': barcode})
logging.info("Rfid绑定成功")
else: else:
embryo_stock_lot = self.env['stock.lot'].search([('name', '=', barcode)]) embryo_stock_lot = self.env['stock.lot'].search([('name', '=', barcode)])
if embryo_stock_lot: if embryo_stock_lot:

View File

@@ -10,7 +10,6 @@ from odoo.modules import get_resource_path
# from OCC.Extend.DataExchange import write_stl_file # from OCC.Extend.DataExchange import write_stl_file
class ResProductMo(models.Model): class ResProductMo(models.Model):
_inherit = 'product.template' _inherit = 'product.template'
@@ -522,6 +521,9 @@ class ResProductMo(models.Model):
string='注册状态', default='未注册') string='注册状态', default='未注册')
industry_code = fields.Char('行业编码', readonly=True) industry_code = fields.Char('行业编码', readonly=True)
# bfm下单
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
@api.constrains('tool_length') @api.constrains('tool_length')
def _check_tool_length_size(self): def _check_tool_length_size(self):
if self.tool_length > 1000000: if self.tool_length > 1000000:
@@ -616,6 +618,7 @@ class ResProductMo(models.Model):
'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']), 'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']),
'model_remark': item['remark'], 'model_remark': item['remark'],
'default_code': '%s-%s' % (order_number, i), 'default_code': '%s-%s' % (order_number, i),
'manual_quotation': item['manual_quotation'] or False,
'active': True, 'active': True,
} }
copy_product_id.sudo().write(vals) copy_product_id.sudo().write(vals)

View File

@@ -317,13 +317,15 @@ class ProductionLot(models.Model):
""" """
now = datetime.now().strftime("%Y%m%d") now = datetime.now().strftime("%Y%m%d")
last_serial = self.env['stock.lot'].search( last_serial = self.env['stock.lot'].search(
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'like', now)], [('company_id', '=', company.id), ('product_id', '=', product.id)],
limit=1, order='id DESC') limit=1, order='id DESC')
if product.cutting_tool_model_id: if product.cutting_tool_model_id:
split_codes = product.cutting_tool_model_id.code.split('-')
if not last_serial: if not last_serial:
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1) return "%s-T-%s-%s-%03d" % (split_codes[0], now, product.specification_id.name, 1)
else: else:
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, int(last_serial.name[-3:]) + 1) return "%s-T-%s-%s-%03d" % (
split_codes[0], now, product.specification_id.name, int(last_serial.name[-3:]) + 1)
else: else:
raise ValidationError('该刀具物料产品的型号字段为空,请补充完整!!!') raise ValidationError('该刀具物料产品的型号字段为空,请补充完整!!!')
@@ -341,7 +343,8 @@ class ProductionLot(models.Model):
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[1] return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[1]
now = datetime.now().strftime("%Y%m%d") now = datetime.now().strftime("%Y%m%d")
if product.cutting_tool_model_id: if product.cutting_tool_model_id:
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1) split_codes = product.cutting_tool_model_id.code.split('-')
return "%s-T-%s-%s-%03d" % (split_codes[0], now, product.specification_id.name, 1)
return "%s-%03d" % (product.name, 1) return "%s-%03d" % (product.name, 1)
qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code') qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code')
@@ -539,6 +542,65 @@ class ReStockMove(models.Model):
else: else:
raise UserError(_("没有可打印的标签数据")) raise UserError(_("没有可打印的标签数据"))
def action_show_details(self):
""" Returns an action that will open a form view (in a popup) allowing to work on all the
move lines of a particular move. This form view is used when "show operations" is not
checked on the picking type.
"""
self.ensure_one()
# If "show suggestions" is not checked on the picking type, we have to filter out the
# reserved move lines. We do this by displaying `move_line_nosuggest_ids`. We use
# different views to display one field or another so that the webclient doesn't have to
# fetch both.
if self.picking_type_id.show_reserved:
view = self.env.ref('stock.view_stock_move_operations')
else:
view = self.env.ref('stock.view_stock_move_nosuggest_operations')
if self.product_id.tracking == "serial" and self.state == "assigned":
print(self.origin)
if self.product_id.categ_id.name == '刀具':
self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
else:
self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
return {
'name': _('Detailed Operations'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'stock.move',
'views': [(view.id, 'form')],
'view_id': view.id,
'target': 'new',
'res_id': self.id,
'context': dict(
self.env.context,
show_owner=self.picking_type_id.code != 'incoming',
show_lots_m2o=self.has_tracking != 'none' and (
self.picking_type_id.use_existing_lots or self.state == 'done' or self.origin_returned_move_id.id),
# able to create lots, whatever the value of ` use_create_lots`.
show_lots_text=self.has_tracking != 'none' and self.picking_type_id.use_create_lots and not self.picking_type_id.use_existing_lots and self.state != 'done' and not self.origin_returned_move_id.id,
show_source_location=self.picking_type_id.code != 'incoming',
show_destination_location=self.picking_type_id.code != 'outgoing',
show_package=not self.location_id.usage == 'supplier',
show_reserved_quantity=self.state != 'done' and not self.picking_id.immediate_transfer and self.picking_type_id.code != 'incoming'
),
}
def _get_tool_next_serial(self, company, product, origin):
"""Return the next serial number to be attributed to the product."""
if product.tracking == "serial":
last_serial = self.env['stock.lot'].search(
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', origin)],
limit=1, order='id DESC')
split_codes = product.cutting_tool_model_id.code.split('-')
if last_serial:
return "%s-T-%s-%s-%03d" % (
split_codes[0], origin, product.specification_id.name, int(last_serial.name[-3:]) + 1)
else:
return "%s-T-%s-%s-%03d" % (split_codes[0], origin, product.specification_id.name, 1)
class ReStockQuant(models.Model): class ReStockQuant(models.Model):
_inherit = 'stock.quant' _inherit = 'stock.quant'

View File

@@ -46,6 +46,9 @@
<attribute name="invisible">1</attribute> <attribute name="invisible">1</attribute>
</xpath> </xpath>
<xpath expr="//field[@name='name']" position="after">
<field name="production_id"/>
</xpath>
<!-- <button name="button_start" type="object" string="Start" class="btn-success"--> <!-- <button name="button_start" type="object" string="Start" class="btn-success"-->
<!-- attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False)]}"/>--> <!-- attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False)]}"/>-->
<!-- <button name="button_pending" type="object" string="Pause" class="btn-warning"--> <!-- <button name="button_pending" type="object" string="Pause" class="btn-warning"-->

View File

@@ -591,6 +591,7 @@ class MachineBrand(models.Model):
if not brand: if not brand:
self.create({ self.create({
"name": item['name'], "name": item['name'],
"active": item['active'],
"code": item['code'], "code": item['code'],
"remark": item['remark'], "remark": item['remark'],
"image_brand": '' if not item['image_brand'] else base64.b64decode(item['image_brand']), "image_brand": '' if not item['image_brand'] else base64.b64decode(item['image_brand']),
@@ -599,6 +600,7 @@ class MachineBrand(models.Model):
}) })
else: else:
brand.name = item['name'] brand.name = item['name']
brand.active = item['active']
brand.remark = item['remark'] brand.remark = item['remark']
brand.image_brand = '' if not item['image_brand'] else base64.b64decode(item['image_brand']) brand.image_brand = '' if not item['image_brand'] else base64.b64decode(item['image_brand'])
brand.tag_ids = self.env['sf.machine.brand.tags'].search( brand.tag_ids = self.env['sf.machine.brand.tags'].search(

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

@@ -2,19 +2,14 @@ import logging
import base64 import base64
import hashlib import hashlib
import os import os
import platform
import json
from datetime import datetime from datetime import datetime
import requests from stl import mesh
from odoo import http # from OCC.Core.GProp import GProp_GProps
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
from odoo.addons.sf_base.commons.common import Common
from . import parser_and_calculate_work_time as pc
class QuickEasyOrder(models.Model): class QuickEasyOrder(models.Model):
@@ -36,7 +31,7 @@ class QuickEasyOrder(models.Model):
('0.02', '±0.02mm'), ('0.02', '±0.02mm'),
('0.01', '±0.01mm')], string='加工精度', default='0.10') ('0.01', '±0.01mm')], string='加工精度', default='0.10')
material_id = fields.Many2one('sf.production.materials', '材料') material_id = fields.Many2one('sf.production.materials', '材料')
material_model_id = fields.Many2one('sf.materials.model', '型号') material_model_id = fields.Many2one('sf.materials.model', '型号', domain="[('materials_id', '=', material_id)]")
# process_id = fields.Many2one('sf.production.process', string='表面工艺') # process_id = fields.Many2one('sf.production.process', string='表面工艺')
parameter_ids = fields.Many2many('sf.production.process.parameter', 'process_item_order_rel', string='可选参数') parameter_ids = fields.Many2many('sf.production.process.parameter', 'process_item_order_rel', string='可选参数')
quantity = fields.Integer('数量', default=1) quantity = fields.Integer('数量', default=1)
@@ -83,9 +78,7 @@ class QuickEasyOrder(models.Model):
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest() model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
report_path = attachment._full_path(attachment.store_fname) report_path = attachment._full_path(attachment.store_fname)
vals['model_file'] = self.transition_glb_file(report_path, model_code) vals['model_file'] = self.transition_glb_file(report_path, model_code)
logging.info('create-model_file:%s' % len(vals['model_file']))
obj = super(QuickEasyOrder, self).create(vals) obj = super(QuickEasyOrder, self).create(vals)
self.model_coloring(obj)
logging.info('---------开始派单到工厂-------') logging.info('---------开始派单到工厂-------')
self.distribute_to_factory(obj) self.distribute_to_factory(obj)
obj.state = '待接单' obj.state = '待接单'
@@ -122,15 +115,42 @@ class QuickEasyOrder(models.Model):
base64_data = base64.b64encode(file_attachment_id.datas) base64_data = base64.b64encode(file_attachment_id.datas)
base64_datas = base64_data.decode('utf-8') base64_datas = base64_data.decode('utf-8')
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest() model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
logging.info("模型编码: %s" % model_code) # 读取文件
item.model_file = self.transition_glb_file(report_path, model_code) shapes = read_step_file(report_path)
# # 第一种获取体积方式
# props = GProp_GProps()
# # brepgprop_VolumeProperties(shapes, props)
# volume = props.Mass()
# # print(volume)
# item.model_volume = volume
# # 长宽高/体积
# output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(library_of_models.code) + '.stl')
output_file = os.path.join('/tmp', str(model_code) + '.stl')
your_mesh = mesh.Mesh.from_file(output_file)
volume, cog, inertia = your_mesh.get_mass_properties()
xyz = (your_mesh.max_ - your_mesh.min_)
item.model_length = xyz[0] # 长 单位mm
item.model_width = xyz[1] # 宽
item.model_height = xyz[2] # 高
item.model_volume = volume
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
# 转化为glb
# output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(library_of_models.code) + '.glb')
output_glb_file = os.path.join('/tmp', str(model_code) + '.glb')
util_path = get_resource_path('sf_base', 'static/util')
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
os.system(cmd)
# 转base64
with open(output_glb_file, 'rb') as fileObj:
image_data = fileObj.read()
base64_data = base64.b64encode(image_data)
item.model_file = base64_data
else: else:
item.model_length = False
item.model_width = False
item.model_height = False
item.model_volume = False
item.model_file = False item.model_file = False
item.model_feature = False
item.model_length = 0
item.model_width = 0
item.model_height = 0
item.model_volume = 0
def distribute_to_factory(self, obj): def distribute_to_factory(self, obj):
""" """
@@ -201,7 +221,7 @@ class QuickEasyOrder(models.Model):
self_machining_bom = self.env['mrp.bom'].bom_create(self_machining_embryo, 'normal', False) self_machining_bom = self.env['mrp.bom'].bom_create(self_machining_embryo, 'normal', False)
# 创建坯料里bom的组件 # 创建坯料里bom的组件
self_machining_bom_line = self_machining_bom.bom_create_line(self_machining_embryo) self_machining_bom_line = self_machining_bom.bom_create_line(self_machining_embryo)
if self_machining_bom_line is False: if not self_machining_bom_line:
self.cr.rollback() self.cr.rollback()
return UserError('该订单模型的材料型号在您分配的工厂里暂未有原材料,请先配置再进行分配') return UserError('该订单模型的材料型号在您分配的工厂里暂未有原材料,请先配置再进行分配')
# 产品配置bom # 产品配置bom
@@ -212,12 +232,16 @@ class QuickEasyOrder(models.Model):
outsource_embryo = self.env['product.template'].sudo().no_bom_product_create(outsource_id, item, outsource_embryo = self.env['product.template'].sudo().no_bom_product_create(outsource_id, item,
order_id, order_id,
'subcontract', i) 'subcontract', i)
if outsource_embryo == -3:
self.cr.rollback()
return UserError(
'该订单模型的材料型号在您分配的工厂里暂未设置获取方式和供应商,请先配置再进行分配')
# 创建坯料的bom # 创建坯料的bom
outsource_bom = self.env['mrp.bom'].bom_create(outsource_embryo, 'subcontract', True) outsource_bom = self.env['mrp.bom'].bom_create(outsource_embryo, 'subcontract', True)
# 创建坯料的bom的组件 # 创建坯料的bom的组件
outsource_bom_line = outsource_bom.with_user( outsource_bom_line = outsource_bom.with_user(
self.env.ref("base.user_admin")).bom_create_line(outsource_embryo) self.env.ref("base.user_admin")).bom_create_line(outsource_embryo)
if outsource_bom_line is False: if not outsource_bom_line:
self.cr.rollback() self.cr.rollback()
return UserError('该订单模型的材料型号在您分配的工厂里暂未有原材料,请先配置再进行分配') return UserError('该订单模型的材料型号在您分配的工厂里暂未有原材料,请先配置再进行分配')
# 产品配置bom # 产品配置bom
@@ -227,6 +251,10 @@ class QuickEasyOrder(models.Model):
purchase_embryo = self.env['product.template'].sudo().no_bom_product_create(purchase_id, item, purchase_embryo = self.env['product.template'].sudo().no_bom_product_create(purchase_id, item,
order_id, order_id,
'purchase', i) 'purchase', i)
if purchase_embryo == -3:
self.cr.rollback()
return UserError(
'该订单模型的材料型号在您分配的工厂里暂未设置获取方式和供应商,请先配置再进行分配')
# 产品配置bom # 产品配置bom
product_bom_purchase = self.env['mrp.bom'].bom_create(product, 'normal', False) product_bom_purchase = self.env['mrp.bom'].bom_create(product, 'normal', False)
product_bom_purchase.bom_create_line_has(purchase_embryo) product_bom_purchase.bom_create_line_has(purchase_embryo)
@@ -234,93 +262,3 @@ class QuickEasyOrder(models.Model):
except Exception as e: except Exception as e:
# self.cr.rollback() # self.cr.rollback()
return UserError('工厂创建销售订单和产品失败,请联系管理员') return UserError('工厂创建销售订单和产品失败,请联系管理员')
# 特征识别
def feature_recognition(self, report_path, model_code):
feature_path = self.env['sf.auto_quatotion.common'].sudo().get_feature_full_path()
process_time_db_path = self.env['sf.auto_quatotion.common'].sudo().get_process_time_db_path()
ret = self.env['sf.auto_quatotion.common'].sudo().get_auto_quatotion(report_path, feature_path,
process_time_db_path,
model_code)
return ret
# 模型上色
def model_coloring(self, order):
url = '/api/library_of_models/create'
config = self.env['res.config.settings'].get_values()
config_header = Common.get_headers(self, config['token'], config['sf_secret_key'])
logging.info('order: %s' % order.name)
if order:
attachment = order.upload_model_file[0]
base64_data = base64.b64encode(attachment.datas)
base64_datas = base64_data.decode('utf-8')
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
logging.info('model_file-size: %s' % len(order.model_file))
logging.info('attachment.datas-size: %s' % len(attachment.datas))
vals = {
'model_code': model_code,
'model_data': base64_data,
'model_name': attachment.name,
'model_long': order.model_length,
'model_width': order.model_width,
'model_height': order.model_height,
'model_volume': order.model_volume,
'model_order_no': order.name,
'remark': '订单号:%s 客户:%s' % (order.name, order.customer_id.name)
}
try:
ret = requests.post((config['sf_url'] + url), json={}, data=vals, headers=config_header,
timeout=60)
ret = ret.json()
# result = json.loads(ret['result'])
if ret['status'] == 1:
order.model_color_state = 'success'
else:
order.model_color_state = 'fail'
raise UserError(ret['message'])
except Exception as e:
order.model_color_state = 'fail'
raise UserError("模型上色失败")
# 自动报价
def _get_price(self, order):
url = '/api/automatic_quotes'
config = self.env['res.config.settings'].sudo().get_values()
config_header = Common.get_headers(self, config['token'], config['sf_secret_key'])
logging.info("报价接口..........% s" % order.name)
try:
if order:
vals = {}
# mrs合作伙伴token
vals['token'] = config['token']
vals['accuracy'] = order.machining_precision
vals['number'] = order.quantity
vals['process_code'] = 0
vals['texture_code'] = order.material_model_id.materials_no
vals['delivery_days'] = 15
if order.model_file:
for item in order.upload_model_file:
if item.ids[0]:
logging.info('create-attachment:%s' % int(item.ids[0]))
attachment = self.env['ir.attachment'].sudo().search([('id', '=', int(item.ids[0]))])
vals['attachment_id'] = attachment.id
else:
vals['attachment_id'] = ''
vals['feature_infos'] = order.model_feature
vals['model_long'] = order.model_length
vals['model_width'] = order.model_width
vals['model_height'] = order.model_height
logging.info('vals:%s' % vals)
ret = requests.post((config['sf_url'] + url), json={}, data=vals, headers=config_header)
result = json.dumps(json.loads(ret.text), ensure_ascii=False, indent=4, separators=(',', ':'))
logging.info('报价接口返回:%s' % result)
price_result = json.loads(result)
# random.randint(0, 10000)
order.write({'price': price_result.get('price')})
else:
raise UserError("订单不存在")
except Exception as e:
if ret['status'] != 1:
raise UserError(e)
else:
raise UserError("自动报价失败,请联系管理员")

View File

@@ -142,6 +142,12 @@ class ResaleOrderLine(models.Model):
check_status = fields.Selection(related='order_id.check_status') check_status = fields.Selection(related='order_id.check_status')
class ProductTemplate(models.Model):
_inherit = 'product.template'
manual_quotation = fields.Boolean('人工编程', default=False)
class RePurchaseOrder(models.Model): class RePurchaseOrder(models.Model):
_inherit = 'purchase.order' _inherit = 'purchase.order'
@@ -206,6 +212,16 @@ class RePurchaseOrder(models.Model):
order.message_subscribe([order.partner_id.id]) order.message_subscribe([order.partner_id.id])
return True return True
@api.onchange('order_line')
def _onchange_order_line(self):
for order in self:
if order.order_line:
line = order.order_line
product = line.product_id
product_id = product.ids
if len(product_id) != len(line):
raise ValidationError('%s】已存在,请勿重复添加' % product[-1].name)
class ResPartnerToSale(models.Model): class ResPartnerToSale(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'

View File

@@ -1,7 +1,7 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_quick_easy_order,quick_easy_order,model_quick_easy_order,base.group_system,1,1,1,0 access_quick_easy_order,quick_easy_order,model_quick_easy_order,base.group_system,1,1,1,0
access_quick_easy_order_group_sale_salemanager,quick_easy_order_group_sale_salemanager,model_quick_easy_order,sf_base.group_sale_salemanager,1,1,1,0 access_quick_easy_order_group_sale_salemanager,quick_easy_order_group_sale_salemanager,model_quick_easy_order,sf_base.group_sale_salemanager,1,0,1,0
access_quick_easy_order_group_sale_director,quick_easy_order_group_sale_director,model_quick_easy_order,sf_base.group_sale_director,1,1,1,0 access_quick_easy_order_group_sale_director,quick_easy_order_group_sale_director,model_quick_easy_order,sf_base.group_sale_director,1,0,1,0
access_sf_auto_quatotion_common,sf_auto_quatotion_common,model_sf_auto_quatotion_common,base.group_system,1,1,1,1 access_sf_auto_quatotion_common,sf_auto_quatotion_common,model_sf_auto_quatotion_common,base.group_system,1,1,1,1
access_sale_order_manager,sale_order_manager,model_sale_order,sf_base.group_sale_salemanager,1,1,1,0 access_sale_order_manager,sale_order_manager,model_sale_order,sf_base.group_sale_salemanager,1,1,1,0
access_sale_order_director,sale_order_director,model_sale_order,sf_base.group_sale_director,1,1,1,0 access_sale_order_director,sale_order_director,model_sale_order,sf_base.group_sale_director,1,1,1,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_quick_easy_order quick_easy_order model_quick_easy_order base.group_system 1 1 1 0
3 access_quick_easy_order_group_sale_salemanager quick_easy_order_group_sale_salemanager model_quick_easy_order sf_base.group_sale_salemanager 1 1 0 1 0
4 access_quick_easy_order_group_sale_director quick_easy_order_group_sale_director model_quick_easy_order sf_base.group_sale_director 1 1 0 1 0
5 access_sf_auto_quatotion_common sf_auto_quatotion_common model_sf_auto_quatotion_common base.group_system 1 1 1 1
6 access_sale_order_manager sale_order_manager model_sale_order sf_base.group_sale_salemanager 1 1 1 0
7 access_sale_order_director sale_order_director model_sale_order sf_base.group_sale_director 1 1 1 0

View File

@@ -47,17 +47,8 @@
</h1> </h1>
<group> <group>
<group> <group>
<field name="customer_id" /> <field name="customer_id" context="{'is_customer': True }"
<field name="material_id"/> options="{'no_create': True}"/>
<field name="material_model_id"/>
<!-- <field name="process_id"/>-->
<field name="parameter_ids" widget="many2many_tags" string="表面工艺参数"/>
<field name="machining_precision"/>
<field name="quantity"/>
<field name="unit_price"/>
<field name="price"/>
</group>
<group>
<field name="upload_model_file" widget="many2many_binary"/> <field name="upload_model_file" widget="many2many_binary"/>
<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': [('model_file', '=', False)]}"/> attrs="{'invisible': [('model_file', '=', False)]}"/>
@@ -75,8 +66,18 @@
<field name="model_height" class="o_address_zip" <field name="model_height" class="o_address_zip"
options="{'format': false}"/> options="{'format': false}"/>
</div> </div>
<field name="model_volume" attrs="{'invisible': [('model_file', '=', False)]}"/> <field name="model_volume" attrs="{'invisible': [('model_file', '=', False)]}"
options="{'format': false}"/>
<field name="material_id" options="{'no_create': True}"/>
<field name="material_model_id" options="{'no_create': True}"/>
<!-- <field name="process_id"/>-->
<field name="parameter_ids" widget="many2many_tags" string="表面工艺参数"
options="{'no_create': True}"/>
<field name="machining_precision"/>
<field name="processing_time"/> <field name="processing_time"/>
<field name="quantity" options="{'format': false}"/>
<field name="unit_price"/>
<field name="price" options="{'format': false}"/>
</group> </group>
</group> </group>
</sheet> </sheet>

View File

@@ -16,6 +16,7 @@
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'wizard/wizard_view.xml', 'wizard/wizard_view.xml',
'views/tool_base_views.xml', 'views/tool_base_views.xml',
'views/functional_tool_views.xml',
'views/mrp_workcenter_views.xml', 'views/mrp_workcenter_views.xml',
'views/sf_maintenance_equipment.xml', 'views/sf_maintenance_equipment.xml',
'views/menu_view.xml', 'views/menu_view.xml',

View File

@@ -22,14 +22,14 @@ class Manufacturing_Connect(http.Controller):
ret = json.loads(datas) ret = json.loads(datas)
# ret = json.loads(ret['result']) # ret = json.loads(ret['result'])
logging.info('DeviceId:%s' % ret) logging.info('DeviceId:%s' % ret)
functional_tools = request.env['sf.functional.cutting.tool.entity'].sudo().search([]) functional_tools = request.env['sf.tool.inventory'].sudo().search([])
res = {'Succeed': True, 'Datas': []} res = {'Succeed': True, 'Datas': []}
if functional_tools: if functional_tools:
for item in functional_tools: for item in functional_tools:
res['Datas'].append({ res['Datas'].append({
'GroupName': item.tool_groups_id.name, 'GroupName': item.tool_groups_id.name,
'ToolId': item.code, 'ToolId': item.functional_cutting_tool_model_id.name,
'ToolName': item.name 'ToolName': item.name
}) })
except Exception as e: except Exception as e:

View File

@@ -1,4 +1,5 @@
from . import base from . import base
from . import functional_tool
from . import tool_material_search from . import tool_material_search
from . import maintenance_equipment from . import maintenance_equipment
from . import mrp_workorder from . import mrp_workorder

View File

@@ -1,477 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import logging
import json
import requests
from datetime import timedelta from datetime import timedelta
from odoo import SUPERUSER_ID from odoo import SUPERUSER_ID
from odoo import fields, models, api from odoo import fields, models, api
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
from odoo.addons.sf_base.commons.common import Common
class FunctionalCuttingToolEntity(models.Model):
_name = 'sf.functional.cutting.tool.entity'
_description = '功能刀具列表'
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
code = fields.Char('编码')
rfid = fields.Char('Rfid', readonly=True)
name = fields.Char('名称')
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称', readonly=True)
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号')
sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型',
group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True)
functional_tool_diameter = fields.Integer(string='刀具直径(mm)', readonly=True)
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True)
coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], string='粗/中/精', readonly=True)
new_former = fields.Selection([('0', ''), ('1', '')], string='新/旧', readonly=True)
tool_loading_length = fields.Float(string='总长度(mm)', readonly=True)
functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True)
effective_length = fields.Float(string='有效长(mm)', readonly=True)
tool_room_num = fields.Integer(string='刀具房数量', readonly=True)
line_edge_knife_library_num = fields.Integer(string='线边刀库数量', readonly=True)
machine_knife_library_num = fields.Integer(string='机内刀库数量', readonly=True)
max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True)
alarm_value = fields.Integer(string='报警值(min)', readonly=True)
used_value = fields.Integer(string='已使用值(min)', readonly=True)
functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')],
string='状态', store=True, default='正常')
current_location_id = fields.Many2one('stock.location', string='当前位置', readonly=True)
current_location = fields.Selection(
[('组装后', '组装后'), ('刀具房', '刀具房'), ('线边刀库', '线边刀库'), ('机内刀库', '机内刀库')],
string='位置', compute='_compute_current_location_id', store=True)
image = fields.Binary('图片', readonly=True)
active = fields.Boolean(string='已归档', default=True)
@api.depends('barcode_id.quant_ids')
def _compute_current_location_id(self):
for record in self:
if record.barcode_id.quant_ids:
for quant_id in record.barcode_id.quant_ids:
if quant_id.inventory_quantity_auto_apply > 0:
record.current_location_id = quant_id.location_id
if quant_id.location_id.name == '制造前':
record.current_location = '机内刀库'
else:
record.current_location = quant_id.location_id.name
if record.current_location_id:
record.sudo().get_location_num()
else:
record.current_location_id = False
record.current_location = False
def get_location_num(self):
"""
计算库存位置数量
"""
for obj in self:
if obj.current_location_id:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 0
if obj.current_location in ['刀具房']:
obj.tool_room_num = 1
elif "线边刀库" in obj.current_location:
obj.line_edge_knife_library_num = 1
elif "机内刀库" in obj.current_location:
obj.machine_knife_library_num = 1
@api.model
def _read_group_mrs_cutting_tool_type_id(self, categories, domain, order):
mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(mrs_cutting_tool_type_ids)
# 整体式刀具型号
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', '=', '夹头')])
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True)
L_D_number = fields.Float(string='L/D值(mm)', readonly=True)
hiding_length = fields.Float(string='避空长(mm)', readonly=True)
cut_time = fields.Integer(string='已切削时间(min)', readonly=True)
cut_length = fields.Float(string='已切削长度(mm)', readonly=True)
cut_number = fields.Integer(string='已切削次数', readonly=True)
suitable_machining_method_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_machining_product_template_tool_entity', '适合加工方式',
domain=[('type', '=', '加工能力')], compute='_compute_maintenance_equipment_image')
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_tool_entity', '走刀方向',
domain=[('type', '=', '走刀方向')])
suitable_coolant_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_coolants_product_template_tool_entity', '适合冷却方式',
domain=[('type', '=', '冷却方式')])
@api.depends('cutting_tool_integral_model_id', 'cutting_tool_blade_model_id')
def _compute_maintenance_equipment_image(self):
for record in self:
if record.cutting_tool_integral_model_id:
print(record.cutting_tool_integral_model_id)
record.sudo().suitable_machining_method_ids = record.cutting_tool_integral_model_id.suitable_machining_method_ids.ids
record.sudo().blade_tip_characteristics_id = record.cutting_tool_integral_model_id.blade_tip_characteristics_id.id
record.sudo().handle_type_id = record.cutting_tool_integral_model_id.handle_type_id.id
record.sudo().cutting_direction_ids = record.cutting_tool_integral_model_id.cutting_direction_ids.ids
record.sudo().suitable_coolant_ids = record.cutting_tool_integral_model_id.suitable_coolant_ids.ids
print(record.cutting_tool_integral_model_id.blade_tip_characteristics_id.ids)
elif record.cutting_tool_blade_model_id:
record.sudo().suitable_machining_method_ids = record.cutting_tool_blade_model_id.suitable_machining_method_ids.ids
record.sudo().blade_tip_characteristics_id = record.cutting_tool_blade_model_id.blade_tip_characteristics_id.id
record.sudo().handle_type_id = record.cutting_tool_blade_model_id.handle_type_id.id
record.sudo().cutting_direction_ids = record.cutting_tool_blade_model_id.cutting_direction_ids.ids
record.sudo().suitable_coolant_ids = record.cutting_tool_blade_model_id.suitable_coolant_ids.ids
else:
record.sudo().suitable_machining_method_ids = []
record.sudo().blade_tip_characteristics_id = None
record.sudo().handle_type_id = None
record.sudo().cutting_direction_ids = []
record.sudo().suitable_coolant_ids = []
def _get_functional_tool_model_ids(self, functional_tool_model_code):
functional_tool_model_ids = []
for item in functional_tool_model_code:
functional_tool_model = self.env['sf.cutting_tool.standard.library'].search([('code', '=', item)])
functional_tool_model_ids.append(functional_tool_model.id)
return [(6, 0, functional_tool_model_ids)]
def open_functional_tool_warning(self):
action = self.env.ref('sf_tool_management.action_sf_functional_tool_warning')
result = action.read()[0]
result['domain'] = [('functional_tool_name_id', '=', self.functional_tool_name_id.id)]
return result
def open_stock_move_line(self):
action = self.env.ref('sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_act')
result = action.read()[0]
result['domain'] = [('lot_id', '=', self.barcode_id.id), ('qty_done', '>', 0)]
return result
def open_safety_stock(self):
action = self.env.ref('sf_tool_management.sf_real_time_distribution_of_functional_tools_view_act')
result = action.read()[0]
result['domain'] = [('name', '=', self.name), ('diameter', '=', self.functional_tool_diameter),
('knife_tip_r_angle', '=', self.knife_tip_r_angle),
('coarse_middle_thin', '=', self.coarse_middle_thin)]
return result
def tool_inventory_displacement_out(self):
"""
机床当前刀库实时信息接口,功能刀具出库
"""
# 获取位置对象
location_inventory_id = self.current_location_id
stock_location_id = self.env['stock.location'].search([('name', '=', '制造前')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
self.barcode_id.create_stock_quant(location_inventory_id, stock_location_id,
self.functional_tool_name_id.id, '机床装刀', self.functional_tool_name_id)
# ==========刀具组接口==========
# def _register_functional_tool_groups(self, obj):
# create_url = '/AutoDeviceApi/ToolGroup'
# 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(obj, token, sf_secret_key)
# strurl = sf_sync_config['sf_url'] + create_url
# val = {
# 'ToolName': obj.name,
# 'GroupName': obj.tool_groups_id.name,
# 'ToolId': obj.code
# }
# kw = json.dumps(val, ensure_ascii=False)
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
# ret = r.json()
# if r == 200:
# return "刀具组发送成功"
# else:
# raise ValidationError("刀具组发送失败")
# @api.model_create_multi
# def create(self, vals):
# obj = super(FunctionalCuttingToolEntity, self).create(vals)
# # 调用刀具组接口
# self._register_functional_tool_groups(obj)
# return obj
class FunctionalToolWarning(models.Model):
_name = 'sf.functional.tool.warning'
_description = '功能刀具预警'
code = fields.Char('编码', related='functional_tool_name_id.code')
rfid = fields.Char('Rfid', related='functional_tool_name_id.rfid')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
name = fields.Char('名称', invisible=True, readonly=True, related='functional_tool_name_id.name')
# 机床信息
production_line_id = fields.Many2one('sf.production.line', string='生产线',
group_expand='_read_group_machine_table_name_ids')
maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床')
machine_tool_code = fields.Char(string='机台号', related='maintenance_equipment_id.name')
machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型',
related='maintenance_equipment_id.category_id')
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号',
domain="[('equipment_id', '=', maintenance_equipment_id)]")
# 功能刀具信息
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称')
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', related='functional_tool_name_id.barcode_id')
mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
diameter = fields.Integer(string='刀具直径(mm)')
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)')
# 其他信息
install_tool_time = fields.Datetime("刀具组装时间", related='functional_tool_name_id.tool_loading_time')
on_board_time = fields.Datetime('上机装刀时间')
max_lifetime_value = fields.Integer(string='最大寿命值(min)')
alarm_value = fields.Integer(string='报警值(min)')
used_value = fields.Integer(string='已使用值(min)')
functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')], string='状态')
alarm_time = fields.Datetime('报警时间')
dispose_user = fields.Char('处理人')
dispose_time = fields.Char('处理时间')
dispose_func = fields.Char('处理方法/措施', readonly=False)
active = fields.Boolean(string='已归档', default=True)
@api.model
def _read_group_machine_table_name_ids(self, categories, domain, order):
machine_table_name_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(machine_table_name_ids)
def create_tool_warning_record(self, obj):
"""
机台换刀申请报警状态时,创建功能刀具预警记录
"""
if obj:
for tool in obj.get('tool_changing_apply_id'):
self.env['sf.functional.tool.warning'].create({
'production_line_id': tool.production_line_id.id,
'maintenance_equipment_id': tool.maintenance_equipment_id.id,
'machine_tool_code': tool.machine_tool_code,
'machine_table_type_id': tool.machine_table_type_id.id,
'cutter_spacing_code_id': tool.cutter_spacing_code_id.id,
'functional_tool_name_id': tool.functional_tool_name_id.id,
'barcode_id': tool.barcode_id.id,
'diameter': tool.diameter,
'knife_tip_r_angle': tool.knife_tip_r_angle,
'max_lifetime_value': tool.max_lifetime_value,
'alarm_value': tool.alarm_value,
'used_value': tool.used_value,
'functional_tool_status': tool.functional_tool_status,
'alarm_time': fields.Datetime.now(),
})
class StockMoveLine(models.Model):
_inherit = 'stock.move.line'
_description = '功能刀具出入库记录'
_order = 'date desc'
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
group_expand='_read_group_functional_tool_type_id')
functional_tool_name = fields.Char('刀具名称')
diameter = fields.Integer(string='刀具直径(mm)')
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)')
install_tool_time = fields.Datetime("刀具组装时间", default=fields.Datetime.now())
code = fields.Char('编码')
rfid = fields.Char('Rfid')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组')
@api.model
def _read_group_functional_tool_type_id(self, categories, domain, order):
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(names)
class RealTimeDistributionOfFunctionalTools(models.Model):
_name = 'sf.real.time.distribution.of.functional.tools'
_description = '功能刀具安全库存'
name = fields.Char('名称', readonly=True, compute='_compute_name', store=True)
functional_name_id = fields.Many2one('sf.tool.inventory', string='功能刀具名称', required=True)
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=False, required=True)
sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False,
group_expand='_read_mrs_cutting_tool_type_ids', store=True)
diameter = fields.Integer(string='刀具直径(mm)', readonly=False)
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=False)
tool_stock_num = fields.Integer(string='刀具房数量')
side_shelf_num = fields.Integer(string='线边刀库数量')
on_tool_stock_num = fields.Integer(string='机内刀库数量')
tool_stock_total = fields.Integer(string='当前库存量', readonly=True)
min_stock_num = fields.Integer('最低库存量')
max_stock_num = fields.Integer('最高库存量')
batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num')
unit = fields.Char('单位')
image = fields.Binary('图片', readonly=False)
coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], string='粗/中/精', readonly=False)
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=False)
# 能力特征信息
suitable_machining_method_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_machining_product_template_distribution', '适合加工方式',
domain=[('type', '=', '加工能力')],
related='sf_functional_cutting_tool_entity_ids.suitable_machining_method_ids')
blade_tip_characteristics_id = fields.Many2one(
'maintenance.equipment.image', '刀尖特征',
domain=[('type', '=', '刀尖特征')],
related='sf_functional_cutting_tool_entity_ids.blade_tip_characteristics_id')
handle_type_id = fields.Many2one(
'maintenance.equipment.image', '柄部类型',
domain=[('type', '=', '柄部类型')], related='sf_functional_cutting_tool_entity_ids.handle_type_id')
cutting_direction_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_cutting_product_template_distribution', '走刀方向',
domain=[('type', '=', '走刀方向')], related='sf_functional_cutting_tool_entity_ids.cutting_direction_ids')
suitable_coolant_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_coolants_product_template_distribution', '适合冷却方式',
domain=[('type', '=', '冷却方式')], related='sf_functional_cutting_tool_entity_ids.suitable_coolant_ids')
sf_functional_cutting_tool_entity_ids = fields.Many2many('sf.functional.cutting.tool.entity',
'sf_functional_cutting_tool_entity_ref',
string='功能刀具列表信息', readonly=True)
sf_functional_tool_assembly_ids = fields.Many2many('sf.functional.tool.assembly', 'sf_functional_tool_assembly_ref',
'功能刀具组装单', readonly=True)
active = fields.Boolean(string='已归档', default=True)
@api.depends('functional_name_id')
def _compute_name(self):
for obj in self:
if obj.tool_groups_id:
obj.name = obj.functional_name_id.name
else:
obj.sudo().name = ''
@api.constrains('min_stock_num', 'max_stock_num')
def _check_stock_num(self):
for obj in self:
if obj.min_stock_num > obj.max_stock_num:
raise ValidationError('【最低安全库存】不能高于【最高安全库存】!!!')
@api.model
def _read_mrs_cutting_tool_type_ids(self, categories, domain, order):
mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(mrs_cutting_tool_type_ids)
@api.depends('sf_functional_cutting_tool_entity_ids', 'min_stock_num', 'max_stock_num')
def _compute_batch_replenishment_num(self):
for tool in self:
if tool:
# 判断功能刀具组装单是否已经完成
tool.sudo().estimate_functional_tool_assembly_ids(tool)
tool.sudo().get_stock_num(tool)
# 计算当前库存量
tool.sudo().tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
# 如果当前库存量小于最低库存量,计算批次补货量
tool.sudo().open_batch_replenishment_num(tool)
def open_batch_replenishment_num(self, tool):
"""
计算批次补货量
"""
if tool.tool_stock_total < tool.min_stock_num:
tool.sudo().batch_replenishment_num = tool.max_stock_num - tool.tool_stock_total
# 根据判断创建功能刀具组装单
if not tool.sf_functional_tool_assembly_ids and re.match(r'^\d+$', str(tool.id)):
for i in range(tool.batch_replenishment_num):
tool.sudo().create_functional_tool_assembly(tool)
print(i, ": ", tool.sf_functional_tool_assembly_ids)
else:
tool.sudo().batch_replenishment_num = 0
def create_functional_tool_assembly(self, tool):
"""
创建功能刀具组装单
"""
functional_tool_assembly = tool.env['sf.functional.tool.assembly'].sudo().create({
'functional_tool_name': tool.name,
'functional_tool_type_id': tool.sf_cutting_tool_type_id.id,
'tool_groups_id': tool.tool_groups_id.id,
'functional_tool_diameter': tool.diameter,
'knife_tip_r_angle': tool.knife_tip_r_angle,
'coarse_middle_thin': tool.coarse_middle_thin,
'loading_task_source': '2',
'use_tool_time': fields.Datetime.now() + timedelta(hours=4),
'applicant': '系统自动',
'apply_time': fields.Datetime.now(),
'whether_standard_knife': tool.whether_standard_knife,
'reason_for_applying': '安全库存',
})
tool.sudo().sf_functional_tool_assembly_ids = [(4, functional_tool_assembly.id)]
def estimate_functional_tool_assembly_ids(self, tool):
"""
判断功能刀具组装单是否完成如果全部完成清空sf_functional_tool_assembly_ids的数据
"""
for sf_functional_tool_assembly_id in tool.sf_functional_tool_assembly_ids:
if sf_functional_tool_assembly_id.assemble_status == '0':
return False
tool.sudo().sf_functional_tool_assembly_ids = []
def get_stock_num(self, tool):
"""
计算刀具房数量、线边刀库数量、机内刀库数量
"""
if tool:
tool.tool_stock_num = 0
tool.side_shelf_num = 0
tool.on_tool_stock_num = 0
if tool.sf_functional_cutting_tool_entity_ids:
for cutting_tool in tool.sf_functional_cutting_tool_entity_ids:
if cutting_tool.tool_room_num > 0:
tool.tool_stock_num += 1
elif cutting_tool.line_edge_knife_library_num > 0:
tool.side_shelf_num += 1
elif cutting_tool.machine_knife_library_num > 0:
tool.on_tool_stock_num += 1
def create_or_edit_safety_stock(self, vals, sf_functional_cutting_tool_entity_ids):
"""
根据传入的信息新增或者更新功能刀具安全库存的信息
"""
# 根据功能刀具名称、刀具组、直径或尖刀R角、粗/中/精查询该功能刀具是否已经存在
record = self.env['sf.real.time.distribution.of.functional.tools'].search(
[('functional_name_id', '=', vals['functional_name_id']),
('sf_cutting_tool_type_id', '=', vals['sf_cutting_tool_type_id']),
('diameter', '=', vals['diameter']), ('knife_tip_r_angle', '=', vals['knife_tip_r_angle']),
('coarse_middle_thin', '=', vals['coarse_middle_thin']), ('tool_groups_id', '=', vals['tool_groups_id'])])
if len(record) > 0:
for obj in record:
obj.write({'sf_functional_cutting_tool_entity_ids': [(4, sf_functional_cutting_tool_entity_ids.id)]})
else:
vals['sf_functional_cutting_tool_entity_ids'] = sf_functional_cutting_tool_entity_ids.ids
self.env['sf.real.time.distribution.of.functional.tools'].create(vals)
status_create = fields.Boolean('是否是新增状态', default=True)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
vals['status_create'] = False
records = super(RealTimeDistributionOfFunctionalTools, self).create(vals_list)
return records
class MachineTableToolChangingApply(models.Model): class MachineTableToolChangingApply(models.Model):
@@ -660,7 +193,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称',
domain="[('production_line_id', '=', production_line_id)]") domain="[('production_line_id', '=', production_line_id)]")
machine_table_name = fields.Char(string='机台号', readonly=True, related='machine_table_name_id.name') machine_table_name = fields.Char(string='机台号', readonly=True, related='machine_table_name_id.name')
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', required=True, cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号',
domain="[('equipment_id', '=', machine_table_name_id)]") domain="[('equipment_id', '=', machine_table_name_id)]")
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True) whether_standard_knife = fields.Boolean(string='是否标准刀', default=True)
need_knife_time = fields.Datetime(string='用刀时间', readonly=False) need_knife_time = fields.Datetime(string='用刀时间', readonly=False)
@@ -670,19 +203,20 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号',
domain=[('product_id.name', '=', '功能刀具')]) domain=[('product_id.name', '=', '功能刀具')])
functional_tool_name = fields.Char(string='功能刀具名称', compute='_compute_functional_tool_name') functional_tool_name = fields.Char(string='功能刀具名称', readonly=True)
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型',
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组') compute='_compute_tool_number', store=True)
diameter = fields.Integer(string='刀具直径(mm)', readonly=False) tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_tool_number', store=True)
tool_included_angle = fields.Float(string='尖R角(mm)', readonly=False) diameter = fields.Integer(string='具直径(mm)', compute='_compute_tool_number', store=True)
tool_loading_length = fields.Float(string='总长度(mm)', readonly=False) tool_included_angle = fields.Float(string='刀尖R角(mm)', compute='_compute_tool_number', store=True)
tool_loading_length = fields.Float(string='总长度(mm)', compute='_compute_tool_number', store=True)
extension_length = fields.Float(string='伸出长(mm)') extension_length = fields.Float(string='伸出长(mm)')
effective_length = fields.Float(string='有效长(mm)') effective_length = fields.Float(string='有效长(mm)')
new_former = fields.Selection([('0', ''), ('1', '')], string='新/旧', readonly=False, default='0') new_former = fields.Selection([('0', ''), ('1', '')], string='新/旧', readonly=False, default='0')
coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], default='3', coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], default='3',
string='粗/中/精', readonly=False) string='粗/中/精', readonly=False)
L_D = fields.Float(string='L/D值', readonly=False) L_D = fields.Float(string='L/D值', readonly=False)
clearance_length = fields.Float(string='避空长(mm)', readonly=False) clearance_length = fields.Float(string='避空长(mm)', compute='_compute_tool_number', store=True)
required_cutting_time = fields.Integer(string='需切削时长', readonly=False) required_cutting_time = fields.Integer(string='需切削时长', readonly=False)
process_type = fields.Char('加工类型') process_type = fields.Char('加工类型')
margin_x_y = fields.Float('余量_X/Y') margin_x_y = fields.Float('余量_X/Y')
@@ -698,15 +232,24 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
active = fields.Boolean(string='已归档', default=True) active = fields.Boolean(string='已归档', default=True)
@api.depends('diameter', 'tool_included_angle', 'tool_groups_id') @api.depends('functional_tool_name')
def _compute_functional_tool_name(self): def _compute_tool_number(self):
for obj in self: for item in self:
if obj.tool_groups_id: inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', item.functional_tool_name)])
obj.functional_tool_name = '%s-D%sR%s' % ( if inventory:
obj.tool_groups_id.name, obj.diameter, item.functional_tool_type_id = inventory.functional_cutting_tool_model_id.id
obj.tool_included_angle) item.tool_groups_id = inventory.tool_groups_id.id
item.diameter = int(inventory.diameter)
item.tool_included_angle = inventory.angle
item.tool_loading_length = inventory.tool_length
item.clearance_length = inventory.blade_length
else: else:
obj.functional_tool_name = None item.functional_tool_type_id = False
item.tool_groups_id = False
item.diameter = 0
item.tool_included_angle = 0
item.tool_loading_length = 0
item.clearance_length = 0
@api.model @api.model
def _read_group_names(self, categories, domain, order): def _read_group_names(self, categories, domain, order):
@@ -780,10 +323,9 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
根据传入的工单信息查询是否有需要的功能刀具如果没有则生成CAM工单程序用刀计划 根据传入的工单信息查询是否有需要的功能刀具如果没有则生成CAM工单程序用刀计划
""" """
status = False status = False
if cnc_processing.functional_tool_type_id and cnc_processing.cutting_tool_name: if cnc_processing.cutting_tool_name:
functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search( functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search(
[('sf_cutting_tool_type_id', '=', cnc_processing.functional_tool_type_id.id), [('name', '=', cnc_processing.cutting_tool_name)])
('name', '=', cnc_processing.cutting_tool_name)])
if functional_tools: if functional_tools:
for functional_tool in functional_tools: for functional_tool in functional_tools:
if functional_tool.on_tool_stock_num == 0: if functional_tool.on_tool_stock_num == 0:
@@ -796,7 +338,6 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
'name': cnc_processing.workorder_id.production_id.name, 'name': cnc_processing.workorder_id.production_id.name,
'cam_procedure_code': cnc_processing.program_name, 'cam_procedure_code': cnc_processing.program_name,
'filename': cnc_processing.cnc_id.name, 'filename': cnc_processing.cnc_id.name,
'functional_tool_type_id': cnc_processing.functional_tool_type_id.id,
'functional_tool_name': cnc_processing.cutting_tool_name, 'functional_tool_name': cnc_processing.cutting_tool_name,
'cam_cutter_spacing_code': cnc_processing.cutting_tool_no, 'cam_cutter_spacing_code': cnc_processing.cutting_tool_no,
'process_type': cnc_processing.processing_type, 'process_type': cnc_processing.processing_type,
@@ -807,8 +348,11 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
'shank_model': cnc_processing.cutting_tool_handle_type, 'shank_model': cnc_processing.cutting_tool_handle_type,
'estimated_processing_time': cnc_processing.estimated_processing_time, 'estimated_processing_time': cnc_processing.estimated_processing_time,
}) })
logging.info('CAM工单程序用刀计划创建成功')
# 创建装刀请求 # 创建装刀请求
knife_plan.apply_for_tooling() knife_plan.apply_for_tooling()
else:
logging.info('功能刀具【%s】满足CNC用刀需求')
class FunctionalToolAssembly(models.Model): class FunctionalToolAssembly(models.Model):
@@ -819,12 +363,12 @@ class FunctionalToolAssembly(models.Model):
@api.depends('functional_tool_name') @api.depends('functional_tool_name')
def _compute_name(self): def _compute_name(self):
for obj in self: for obj in self:
obj.name = obj.after_assembly_functional_tool_name obj.name = obj.assembly_order_code
code = fields.Char('功能刀具编码', readonly=True) code = fields.Char('功能刀具编码', readonly=True)
rfid = fields.Char('Rfid', readonly=True) rfid = fields.Char('Rfid', readonly=True)
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=True) tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=True)
name = fields.Char(string='名称', readonly=True, compute='_compute_name', store=True) name = fields.Char(string='名称', readonly=True, compute='_compute_name')
assembly_order_code = fields.Char(string='组装单编码', readonly=True) assembly_order_code = fields.Char(string='组装单编码', readonly=True)
functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', readonly=True) functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', readonly=True)
@@ -864,56 +408,136 @@ class FunctionalToolAssembly(models.Model):
return categories.browse(functional_tool_type_ids) return categories.browse(functional_tool_type_ids)
# 刀具物料信息 # 刀具物料信息
# 整体式刀具型号 # ==============整体式刀具型号============
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号', readonly=True) integral_freight_barcode = fields.Char('整体式刀具货位')
integral_product_id = fields.Many2one('product.product', string='整体式刀具名称',
compute='_compute_integral_product_id', store=True)
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
related='integral_code_id.product_id.cutting_tool_model_id') related='integral_product_id.cutting_tool_model_id')
integral_name = fields.Char('整体式刀具名称', related='integral_code_id.product_id.name')
integral_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='整体式刀具规格', integral_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='整体式刀具规格',
related='integral_code_id.product_id.specification_id') related='integral_product_id.specification_id')
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
related='integral_code_id.product_id.brand_id') related='integral_product_id.brand_id')
# 刀片型号
blade_code_id = fields.Many2one('stock.lot', '刀片序列号', readonly=True)
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
related='blade_code_id.product_id.cutting_tool_model_id')
blade_name = fields.Char('刀片名称', related='blade_code_id.product_id.name')
blade_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀片规格',
related='blade_code_id.product_id.specification_id')
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_code_id.product_id.brand_id')
# 刀杆型号
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', readonly=True)
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
related='bar_code_id.product_id.cutting_tool_model_id')
bar_name = fields.Char('刀杆名称', related='bar_code_id.product_id.name')
bar_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀杆规格',
related='bar_code_id.product_id.specification_id')
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_code_id.product_id.brand_id')
# 刀盘型号
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', readonly=True)
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
related='pad_code_id.product_id.cutting_tool_model_id')
pad_name = fields.Char('刀盘名称', related='pad_code_id.product_id.name')
pad_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀盘规格',
related='pad_code_id.product_id.specification_id')
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_code_id.product_id.brand_id')
# 刀柄型号
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', readonly=True)
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
related='handle_code_id.product_id.cutting_tool_model_id')
handle_name = fields.Char('刀柄名称', related='handle_code_id.product_id.name')
handle_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀柄规格',
related='handle_code_id.product_id.specification_id')
sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', related='handle_code_id.product_id.brand_id')
# 夹头型号
chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', readonly=True)
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
related='chuck_code_id.product_id.cutting_tool_model_id')
chuck_name = fields.Char('夹头名称', related='chuck_code_id.product_id.name')
chuck_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='夹头规格',
related='chuck_code_id.product_id.specification_id')
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_code_id.product_id.brand_id')
@api.depends('integral_freight_barcode')
def _compute_integral_product_id(self):
for item in self:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.integral_freight_barcode)])
if location:
item.integral_product_id = location.product_id.id
else:
item.integral_product_id = False
# =================刀片型号=============
blade_freight_barcode = fields.Char('刀片货位')
blade_product_id = fields.Many2one('product.product', string='刀片名称', compute='_compute_blade_product_id',
store=True)
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
related='blade_product_id.cutting_tool_model_id')
blade_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀片规格',
related='blade_product_id.specification_id')
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
@api.depends('blade_freight_barcode')
def _compute_blade_product_id(self):
for item in self:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.blade_freight_barcode)])
if location:
item.blade_product_id = location.product_id.id
else:
item.blade_product_id = False
# ==============刀杆型号================
bar_freight_barcode = fields.Char('刀杆货位')
bar_product_id = fields.Many2one('product.product', string='刀杆名称', compute='_compute_bar_product_id',
store=True)
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
related='bar_product_id.cutting_tool_model_id')
bar_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀杆规格',
related='bar_product_id.specification_id')
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
@api.depends('bar_freight_barcode')
def _compute_bar_product_id(self):
for item in self:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.bar_freight_barcode)])
if location:
item.bar_product_id = location.product_id.id
else:
item.bar_product_id = False
# =============刀盘型号================
pad_freight_barcode = fields.Char('刀盘货位')
pad_product_id = fields.Many2one('product.product', string='刀盘名称', compute='_compute_pad_product_id',
store=True)
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
related='pad_product_id.cutting_tool_model_id')
pad_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀盘规格',
related='pad_product_id.specification_id')
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
@api.depends('pad_freight_barcode')
def _compute_pad_product_id(self):
for item in self:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.pad_freight_barcode)])
if location:
item.pad_product_id = location.product_id.id
else:
item.pad_product_id = False
# ==============刀柄型号==============
handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_handle_product_id', store=True)
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号')
handle_product_id = fields.Many2one('product.product', string='刀柄名称', compute='_compute_handle_product_id',
store=True)
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
related='handle_product_id.cutting_tool_model_id')
handle_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀柄规格',
related='handle_product_id.specification_id')
sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', related='handle_product_id.brand_id')
@api.depends('handle_code_id')
def _compute_handle_product_id(self):
for item in self:
if item.handle_code_id:
item.handle_product_id = item.handle_code_id.product_id.id
item.handle_freight_rfid = item.handle_code_id.rfid
else:
item.handle_product_id = False
item.handle_freight_rfid = False
# ==============夹头型号==============
chuck_freight_barcode = fields.Char('夹头货位')
chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id',
store=True)
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
related='chuck_product_id.cutting_tool_model_id')
chuck_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='夹头规格',
related='chuck_product_id.specification_id')
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
@api.depends('chuck_freight_barcode')
def _compute_chuck_product_id(self):
for item in self:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.chuck_freight_barcode)])
if location:
item.chuck_product_id = location.product_id.id
else:
item.chuck_product_id = False
# ==================待删除字段==================
blade_name = fields.Char('')
integral_name = fields.Char('')
blade_code_id = fields.Many2one('stock.lot', '刀片序列号')
integral_code_id = fields.Many2one('stock.lot', '整体式刀具序列号')
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号')
bar_name = fields.Char('')
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号')
pad_name = fields.Char('')
handle_name = fields.Char('')
chuck_code_id = fields.Many2one('stock.lot', '夹头序列号')
chuck_name = fields.Char('')
# ==============================================
# 组装功能刀具参数信息 # 组装功能刀具参数信息
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', readonly=True) after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', readonly=True)

View File

@@ -0,0 +1,481 @@
# -*- coding: utf-8 -*-
import re
from datetime import timedelta
from odoo import SUPERUSER_ID
from odoo import fields, models, api
from odoo.exceptions import ValidationError
class FunctionalCuttingToolEntity(models.Model):
_name = 'sf.functional.cutting.tool.entity'
_description = '功能刀具列表'
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具组装单', readonly=True)
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
code = fields.Char('编码')
rfid = fields.Char('Rfid', readonly=True)
name = fields.Char('名称')
tool_name_id = fields.Many2one('sf.tool.inventory', '功能刀具名称')
sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号')
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型',
group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True)
functional_tool_diameter = fields.Integer(string='刀具直径(mm)', readonly=True)
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True)
coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], string='粗/中/精', readonly=True)
new_former = fields.Selection([('0', ''), ('1', '')], string='新/旧', readonly=True)
tool_loading_length = fields.Float(string='总长度(mm)', readonly=True)
functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True)
effective_length = fields.Float(string='有效长(mm)', readonly=True)
tool_room_num = fields.Integer(string='刀具房数量', readonly=True)
line_edge_knife_library_num = fields.Integer(string='线边刀库数量', readonly=True)
machine_knife_library_num = fields.Integer(string='机内刀库数量', readonly=True)
max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True)
alarm_value = fields.Integer(string='报警值(min)', readonly=True)
used_value = fields.Integer(string='已使用值(min)', readonly=True)
functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')],
string='状态', store=True, default='正常')
current_location_id = fields.Many2one('stock.location', string='当前位置', readonly=True)
current_location = fields.Selection(
[('组装后', '组装后'), ('刀具房', '刀具房'), ('线边刀库', '线边刀库'), ('机内刀库', '机内刀库')],
string='位置', compute='_compute_current_location_id', store=True)
image = fields.Binary('图片', readonly=True)
active = fields.Boolean(string='已归档', default=True)
@api.depends('barcode_id.quant_ids')
def _compute_current_location_id(self):
for record in self:
if record.barcode_id.quant_ids:
for quant_id in record.barcode_id.quant_ids:
if quant_id.inventory_quantity_auto_apply > 0:
record.current_location_id = quant_id.location_id
if quant_id.location_id.name == '制造前':
record.current_location = '机内刀库'
else:
record.current_location = quant_id.location_id.name
if record.current_location_id:
record.sudo().get_location_num()
else:
record.current_location_id = False
record.current_location = False
def get_location_num(self):
"""
计算库存位置数量
"""
for obj in self:
if obj.current_location_id:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 0
if obj.current_location in ['刀具房']:
obj.tool_room_num = 1
elif "线边刀库" in obj.current_location:
obj.line_edge_knife_library_num = 1
elif "机内刀库" in obj.current_location:
obj.machine_knife_library_num = 1
@api.model
def _read_group_mrs_cutting_tool_type_id(self, categories, domain, order):
mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(mrs_cutting_tool_type_ids)
# 整体式刀具型号
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', '=', '夹头')])
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True)
L_D_number = fields.Float(string='L/D值(mm)', readonly=True)
hiding_length = fields.Float(string='避空长(mm)', readonly=True)
cut_time = fields.Integer(string='已切削时间(min)', readonly=True)
cut_length = fields.Float(string='已切削长度(mm)', readonly=True)
cut_number = fields.Integer(string='已切削次数', readonly=True)
suitable_machining_method_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_machining_product_template_tool_entity', '适合加工方式',
domain=[('type', '=', '加工能力')], compute='_compute_maintenance_equipment_image')
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_tool_entity', '走刀方向',
domain=[('type', '=', '走刀方向')])
suitable_coolant_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_coolants_product_template_tool_entity', '适合冷却方式',
domain=[('type', '=', '冷却方式')])
@api.depends('cutting_tool_integral_model_id', 'cutting_tool_blade_model_id')
def _compute_maintenance_equipment_image(self):
for record in self:
if record.cutting_tool_integral_model_id:
print(record.cutting_tool_integral_model_id)
record.sudo().suitable_machining_method_ids = record.cutting_tool_integral_model_id.suitable_machining_method_ids.ids
record.sudo().blade_tip_characteristics_id = record.cutting_tool_integral_model_id.blade_tip_characteristics_id.id
record.sudo().handle_type_id = record.cutting_tool_integral_model_id.handle_type_id.id
record.sudo().cutting_direction_ids = record.cutting_tool_integral_model_id.cutting_direction_ids.ids
record.sudo().suitable_coolant_ids = record.cutting_tool_integral_model_id.suitable_coolant_ids.ids
print(record.cutting_tool_integral_model_id.blade_tip_characteristics_id.ids)
elif record.cutting_tool_blade_model_id:
record.sudo().suitable_machining_method_ids = record.cutting_tool_blade_model_id.suitable_machining_method_ids.ids
record.sudo().blade_tip_characteristics_id = record.cutting_tool_blade_model_id.blade_tip_characteristics_id.id
record.sudo().handle_type_id = record.cutting_tool_blade_model_id.handle_type_id.id
record.sudo().cutting_direction_ids = record.cutting_tool_blade_model_id.cutting_direction_ids.ids
record.sudo().suitable_coolant_ids = record.cutting_tool_blade_model_id.suitable_coolant_ids.ids
else:
record.sudo().suitable_machining_method_ids = []
record.sudo().blade_tip_characteristics_id = None
record.sudo().handle_type_id = None
record.sudo().cutting_direction_ids = []
record.sudo().suitable_coolant_ids = []
def _get_functional_tool_model_ids(self, functional_tool_model_code):
functional_tool_model_ids = []
for item in functional_tool_model_code:
functional_tool_model = self.env['sf.cutting_tool.standard.library'].search([('code', '=', item)])
functional_tool_model_ids.append(functional_tool_model.id)
return [(6, 0, functional_tool_model_ids)]
def open_functional_tool_warning(self):
action = self.env.ref('sf_tool_management.action_sf_functional_tool_warning')
result = action.read()[0]
result['domain'] = [('functional_tool_name_id', '=', self.functional_tool_name_id.id)]
return result
def open_stock_move_line(self):
action = self.env.ref('sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_act')
result = action.read()[0]
result['domain'] = [('lot_id', '=', self.barcode_id.id), ('qty_done', '>', 0)]
return result
def open_safety_stock(self):
action = self.env.ref('sf_tool_management.sf_real_time_distribution_of_functional_tools_view_act')
result = action.read()[0]
result['domain'] = [('name', '=', self.name), ('diameter', '=', self.functional_tool_diameter),
('knife_tip_r_angle', '=', self.knife_tip_r_angle),
('coarse_middle_thin', '=', self.coarse_middle_thin)]
return result
def tool_inventory_displacement_out(self):
"""
机床当前刀库实时信息接口,功能刀具出库
"""
# 获取位置对象
location_inventory_id = self.current_location_id
stock_location_id = self.env['stock.location'].search([('name', '=', '制造前')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
self.barcode_id.create_stock_quant(location_inventory_id, stock_location_id,
self.functional_tool_name_id.id, '机床装刀', self.functional_tool_name_id)
# ==========刀具组接口==========
# def _register_functional_tool_groups(self, obj):
# create_url = '/AutoDeviceApi/ToolGroup'
# 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(obj, token, sf_secret_key)
# strurl = sf_sync_config['sf_url'] + create_url
# val = {
# 'ToolName': obj.name,
# 'GroupName': obj.tool_groups_id.name,
# 'ToolId': obj.code
# }
# kw = json.dumps(val, ensure_ascii=False)
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
# ret = r.json()
# if r == 200:
# return "刀具组发送成功"
# else:
# raise ValidationError("刀具组发送失败")
# @api.model_create_multi
# def create(self, vals):
# obj = super(FunctionalCuttingToolEntity, self).create(vals)
# # 调用刀具组接口
# self._register_functional_tool_groups(obj)
# return obj
class FunctionalToolWarning(models.Model):
_name = 'sf.functional.tool.warning'
_description = '功能刀具预警'
code = fields.Char('编码', related='functional_tool_name_id.code')
rfid = fields.Char('Rfid', related='functional_tool_name_id.rfid')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
name = fields.Char('名称', invisible=True, readonly=True, related='functional_tool_name_id.name')
# 机床信息
production_line_id = fields.Many2one('sf.production.line', string='生产线',
group_expand='_read_group_machine_table_name_ids')
maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床')
machine_tool_code = fields.Char(string='机台号', related='maintenance_equipment_id.name')
machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型',
related='maintenance_equipment_id.category_id')
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号',
domain="[('equipment_id', '=', maintenance_equipment_id)]")
# 功能刀具信息
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称')
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', related='functional_tool_name_id.barcode_id')
mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
diameter = fields.Integer(string='刀具直径(mm)')
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)')
# 其他信息
install_tool_time = fields.Datetime("刀具组装时间", related='functional_tool_name_id.tool_loading_time')
on_board_time = fields.Datetime('上机装刀时间')
max_lifetime_value = fields.Integer(string='最大寿命值(min)')
alarm_value = fields.Integer(string='报警值(min)')
used_value = fields.Integer(string='已使用值(min)')
functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')], string='状态')
alarm_time = fields.Datetime('报警时间')
dispose_user = fields.Char('处理人')
dispose_time = fields.Char('处理时间')
dispose_func = fields.Char('处理方法/措施', readonly=False)
active = fields.Boolean(string='已归档', default=True)
@api.model
def _read_group_machine_table_name_ids(self, categories, domain, order):
machine_table_name_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(machine_table_name_ids)
def create_tool_warning_record(self, obj):
"""
机台换刀申请报警状态时,创建功能刀具预警记录
"""
if obj:
for tool in obj.get('tool_changing_apply_id'):
self.env['sf.functional.tool.warning'].create({
'production_line_id': tool.production_line_id.id,
'maintenance_equipment_id': tool.maintenance_equipment_id.id,
'machine_tool_code': tool.machine_tool_code,
'machine_table_type_id': tool.machine_table_type_id.id,
'cutter_spacing_code_id': tool.cutter_spacing_code_id.id,
'functional_tool_name_id': tool.functional_tool_name_id.id,
'barcode_id': tool.barcode_id.id,
'diameter': tool.diameter,
'knife_tip_r_angle': tool.knife_tip_r_angle,
'max_lifetime_value': tool.max_lifetime_value,
'alarm_value': tool.alarm_value,
'used_value': tool.used_value,
'functional_tool_status': tool.functional_tool_status,
'alarm_time': fields.Datetime.now(),
})
class StockMoveLine(models.Model):
_inherit = 'stock.move.line'
_description = '功能刀具出入库记录'
_order = 'date desc'
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具组装单')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
group_expand='_read_group_functional_tool_type_id')
functional_tool_name = fields.Char('刀具名称')
diameter = fields.Integer(string='刀具直径(mm)')
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)')
install_tool_time = fields.Datetime("刀具组装时间", default=fields.Datetime.now())
code = fields.Char('编码')
rfid = fields.Char('Rfid')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组')
@api.model
def _read_group_functional_tool_type_id(self, categories, domain, order):
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(names)
class RealTimeDistributionOfFunctionalTools(models.Model):
_name = 'sf.real.time.distribution.of.functional.tools'
_description = '功能刀具安全库存'
name = fields.Char('名称', readonly=True, compute='_compute_name', store=True)
functional_name_id = fields.Many2one('sf.tool.inventory', string='功能刀具名称', required=True)
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=False, required=True)
sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False,
group_expand='_read_mrs_cutting_tool_type_ids', store=True)
diameter = fields.Integer(string='刀具直径(mm)', readonly=False)
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=False)
tool_stock_num = fields.Integer(string='刀具房数量')
side_shelf_num = fields.Integer(string='线边刀库数量')
on_tool_stock_num = fields.Integer(string='机内刀库数量')
tool_stock_total = fields.Integer(string='当前库存量', readonly=True)
min_stock_num = fields.Integer('最低库存量')
max_stock_num = fields.Integer('最高库存量')
batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num')
unit = fields.Char('单位')
image = fields.Binary('图片', readonly=False)
coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], string='粗/中/精', readonly=False)
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=False)
# 能力特征信息
suitable_machining_method_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_machining_product_template_distribution', '适合加工方式',
domain=[('type', '=', '加工能力')],
related='sf_functional_cutting_tool_entity_ids.suitable_machining_method_ids')
blade_tip_characteristics_id = fields.Many2one(
'maintenance.equipment.image', '刀尖特征',
domain=[('type', '=', '刀尖特征')],
related='sf_functional_cutting_tool_entity_ids.blade_tip_characteristics_id')
handle_type_id = fields.Many2one(
'maintenance.equipment.image', '柄部类型',
domain=[('type', '=', '柄部类型')], related='sf_functional_cutting_tool_entity_ids.handle_type_id')
cutting_direction_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_cutting_product_template_distribution', '走刀方向',
domain=[('type', '=', '走刀方向')], related='sf_functional_cutting_tool_entity_ids.cutting_direction_ids')
suitable_coolant_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_coolants_product_template_distribution', '适合冷却方式',
domain=[('type', '=', '冷却方式')], related='sf_functional_cutting_tool_entity_ids.suitable_coolant_ids')
sf_functional_cutting_tool_entity_ids = fields.Many2many('sf.functional.cutting.tool.entity',
'sf_functional_cutting_tool_entity_ref',
string='功能刀具列表信息', readonly=True)
sf_functional_tool_assembly_ids = fields.Many2many('sf.functional.tool.assembly', 'sf_functional_tool_assembly_ref',
'功能刀具组装单', readonly=True)
active = fields.Boolean(string='已归档', default=True)
@api.onchange('functional_name_id')
def _onchange_num(self):
for item in self:
if item.functional_name_id:
item.tool_groups_id = item.functional_name_id.tool_groups_id.id
item.sf_cutting_tool_type_id = item.functional_name_id.functional_cutting_tool_model_id.id
item.diameter = item.functional_name_id.diameter
item.knife_tip_r_angle = item.functional_name_id.angle
@api.depends('functional_name_id')
def _compute_name(self):
for obj in self:
if obj.tool_groups_id:
obj.name = obj.functional_name_id.name
else:
obj.sudo().name = ''
@api.constrains('min_stock_num', 'max_stock_num')
def _check_stock_num(self):
for obj in self:
if obj.min_stock_num > obj.max_stock_num:
raise ValidationError('【最低安全库存】不能高于【最高安全库存】!!!')
@api.model
def _read_mrs_cutting_tool_type_ids(self, categories, domain, order):
mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(mrs_cutting_tool_type_ids)
@api.depends('sf_functional_cutting_tool_entity_ids', 'min_stock_num', 'max_stock_num')
def _compute_batch_replenishment_num(self):
for tool in self:
if tool:
# 判断功能刀具组装单是否已经完成
tool.sudo().estimate_functional_tool_assembly_ids(tool)
tool.sudo().get_stock_num(tool)
# 计算当前库存量
tool.sudo().tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
# 如果当前库存量小于最低库存量,计算批次补货量
tool.sudo().open_batch_replenishment_num(tool)
def open_batch_replenishment_num(self, tool):
"""
计算批次补货量
"""
if tool.tool_stock_total < tool.min_stock_num:
tool.sudo().batch_replenishment_num = tool.max_stock_num - tool.tool_stock_total
# 根据判断创建功能刀具组装单
if not tool.sf_functional_tool_assembly_ids and re.match(r'^\d+$', str(tool.id)):
for i in range(tool.batch_replenishment_num):
tool.sudo().create_functional_tool_assembly(tool)
print(i, ": ", tool.sf_functional_tool_assembly_ids)
else:
tool.sudo().batch_replenishment_num = 0
def create_functional_tool_assembly(self, tool):
"""
创建功能刀具组装单
"""
functional_tool_assembly = tool.env['sf.functional.tool.assembly'].sudo().create({
'functional_tool_name': tool.name,
'functional_tool_type_id': tool.sf_cutting_tool_type_id.id,
'tool_groups_id': tool.tool_groups_id.id,
'functional_tool_diameter': tool.diameter,
'knife_tip_r_angle': tool.knife_tip_r_angle,
'coarse_middle_thin': tool.coarse_middle_thin,
'loading_task_source': '2',
'use_tool_time': fields.Datetime.now() + timedelta(hours=4),
'applicant': '系统自动',
'apply_time': fields.Datetime.now(),
'whether_standard_knife': tool.whether_standard_knife,
'reason_for_applying': '安全库存',
})
tool.sudo().sf_functional_tool_assembly_ids = [(4, functional_tool_assembly.id)]
def estimate_functional_tool_assembly_ids(self, tool):
"""
判断功能刀具组装单是否完成如果全部完成清空sf_functional_tool_assembly_ids的数据
"""
for sf_functional_tool_assembly_id in tool.sf_functional_tool_assembly_ids:
if sf_functional_tool_assembly_id.assemble_status == '0':
return False
tool.sudo().sf_functional_tool_assembly_ids = []
def get_stock_num(self, tool):
"""
计算刀具房数量、线边刀库数量、机内刀库数量
"""
if tool:
tool.tool_stock_num = 0
tool.side_shelf_num = 0
tool.on_tool_stock_num = 0
if tool.sf_functional_cutting_tool_entity_ids:
for cutting_tool in tool.sf_functional_cutting_tool_entity_ids:
if cutting_tool.tool_room_num > 0:
tool.tool_stock_num += 1
elif cutting_tool.line_edge_knife_library_num > 0:
tool.side_shelf_num += 1
elif cutting_tool.machine_knife_library_num > 0:
tool.on_tool_stock_num += 1
def create_or_edit_safety_stock(self, vals, sf_functional_cutting_tool_entity_ids):
"""
根据传入的信息新增或者更新功能刀具安全库存的信息
"""
# 根据功能刀具名称、刀具组、直径或尖刀R角、粗/中/精查询该功能刀具是否已经存在
record = self.env['sf.real.time.distribution.of.functional.tools'].search(
[('functional_name_id', '=', vals['functional_name_id']),
('sf_cutting_tool_type_id', '=', vals['sf_cutting_tool_type_id']),
('diameter', '=', vals['diameter']), ('knife_tip_r_angle', '=', vals['knife_tip_r_angle']),
('coarse_middle_thin', '=', vals['coarse_middle_thin']), ('tool_groups_id', '=', vals['tool_groups_id'])])
if len(record) > 0:
for obj in record:
obj.write({'sf_functional_cutting_tool_entity_ids': [(4, sf_functional_cutting_tool_entity_ids.id)]})
else:
vals['sf_functional_cutting_tool_entity_ids'] = sf_functional_cutting_tool_entity_ids.ids
self.env['sf.real.time.distribution.of.functional.tools'].create(vals)
status_create = fields.Boolean('是否是新增状态', default=True)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
vals['status_create'] = False
records = super(RealTimeDistributionOfFunctionalTools, self).create(vals_list)
return records

View File

@@ -36,6 +36,7 @@ class CNCprocessing(models.Model):
obj = super(CNCprocessing, self).create(vals) obj = super(CNCprocessing, self).create(vals)
# 调用CAM工单程序用刀计划创建方法 # 调用CAM工单程序用刀计划创建方法
self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(obj) self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(obj)
logging.info('成功调用CAM工单程序用刀计划创建方法')
return obj return obj

View File

@@ -20,35 +20,35 @@ class ToolMaterial(models.Model):
specification_id = fields.Many2one('sf.tool.materials.basic.parameters', '规格', specification_id = fields.Many2one('sf.tool.materials.basic.parameters', '规格',
related='product_id.specification_id') related='product_id.specification_id')
image = fields.Binary('图片', related='product_id.image_1920') image = fields.Binary('图片', related='product_id.image_1920')
number = fields.Integer('总数量', compute='_compute_number') number = fields.Integer('总数量', compute='_compute_number', store=True)
usable_num = fields.Integer('可用数量', compute='_compute_number') usable_num = fields.Integer('可用数量', compute='_compute_number', store=True)
have_been_used_num = fields.Integer('在用数量', compute='_compute_number') have_been_used_num = fields.Integer('在用数量', compute='_compute_number', store=True)
scrap_num = fields.Integer('报废数量', compute='_compute_number') scrap_num = fields.Integer('报废数量', compute='_compute_number', store=True)
barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True) barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True)
@api.depends('barcode_ids') @api.depends('product_id.stock_quant_ids.quantity')
def _compute_number(self): def _compute_number(self):
for record in self: for record in self:
usable_num = 0 usable_num = 0
have_been_used_num = 0 have_been_used_num = 0
scrap_num = 0 scrap_num = 0
if record.barcode_ids: for quant in record.product_id.stock_quant_ids:
record.number = len(record.barcode_ids) location = quant.location_id.name
for barcode_id in record.barcode_ids: if location == '刀具房':
if barcode_id.quant_ids: usable_num += quant.quantity
if barcode_id.quant_ids[-1].location_id.name == '刀具组装位置': elif location == '刀具组装位置':
have_been_used_num = have_been_used_num + 1 have_been_used_num += quant.quantity
else: elif location == '进货':
usable_num = usable_num + 1 pass
record.usable_num = usable_num elif location != 'Vendors':
record.have_been_used_num = have_been_used_num scrap_num += quant.quantity
record.scrap_num = scrap_num record.usable_num = usable_num
else: record.have_been_used_num = have_been_used_num
record.number = 0 record.scrap_num = scrap_num
record.usable_num = 0 record.number = usable_num + have_been_used_num + scrap_num
record.have_been_used_num = 0 # 更新数据到cloud的动态数据
record.scrap_num = 0 record.enroll_tool_material()
@api.model @api.model
def _read_group_cutting_tool_material_id(self, categories, domain, order): def _read_group_cutting_tool_material_id(self, categories, domain, order):

View File

@@ -0,0 +1,514 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<!--========================================功能刀具列表========================================-->
<record id="view_functional_cutting_tool_list_tree" model="ir.ui.view">
<field name="name">sf.functional.cutting.tool.entity.list.tree</field>
<field name="model">sf.functional.cutting.tool.entity</field>
<field name="arch" type="xml">
<tree string="功能刀具列表" create="0" edit="0" delete="0">
<field name="barcode_id" invisible="1"/>
<field name="rfid"/>
<field name="tool_name_id"/>
<field name="image" widget='image'/>
<field name="tool_groups_id"/>
<field name="functional_tool_diameter"/>
<field name="knife_tip_r_angle"/>
<field name="coarse_middle_thin" optional="hide"/>
<field name="new_former" optional="hide"/>
<field name="tool_loading_length" optional="hide"/>
<field name="functional_tool_length" optional="hide"/>
<field name="effective_length" optional="hide"/>
<field name="tool_room_num"/>
<field name="line_edge_knife_library_num"/>
<field name="machine_knife_library_num"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status"/>
<field name="current_location_id" optional="hide"/>
<field name="current_location" optional="hide"/>
<field name="sf_cutting_tool_type_id" invisible="True"/>
</tree>
</field>
</record>
<record id="view_functional_cutting_tool_list_form" model="ir.ui.view">
<field name="name">sf.functional.cutting.tool.entity.list.form</field>
<field name="model">sf.functional.cutting.tool.entity</field>
<field name="arch" type="xml">
<form create="0" edit="0" delete="0">
<header>
<!-- <button name="enroll_functional_tool_entity" string="功能刀具注册" type="object"-->
<!-- class="btn-primary"/>-->
<field name="functional_tool_status" widget="statusbar" statusbar_visible="正常,报警,已拆除"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" groups="sf_base.group_sf_mrp_user"
name="open_functional_tool_warning"
icon="fa-list-ul"
type="object">
<div class="o_field_widget o_stat_info">
<span>
预警记录
</span>
</div>
</button>
<button class="oe_stat_button" groups="sf_base.group_sf_mrp_user"
name="open_stock_move_line"
icon="fa-list-ul"
type="object">
<div class="o_field_widget o_stat_info">
<span>
出库入库记录
</span>
</div>
</button>
<button class="oe_stat_button" groups="sf_base.group_sf_mrp_user"
name="open_safety_stock"
icon="fa-list-ul"
type="object">
<div class="o_field_widget o_stat_info">
<span>
安全库存
</span>
</div>
</button>
</div>
<div class="oe_title">
<h1>
<field name="code" readonly="1" nolabel="True"/>
</h1>
</div>
<group>
<group>
<field name="barcode_id" invisible="1"/>
<field name="rfid" readonly="1"/>
<field name="tool_name_id" invisible="0"
placeholder="请输入20字以内的名称"/>
<field name="sf_cutting_tool_type_id"/>
<field name="tool_groups_id"/>
<field name="cutting_tool_integral_model_id"
options="{'no_create': True, 'no_quick_create': True}"
attrs="{'invisible': [('cutting_tool_blade_model_id', '!=', False)]}"
/>
<field name="cutting_tool_blade_model_id"
options="{'no_create': True, 'no_quick_create': True}"
attrs="{'invisible': [('cutting_tool_integral_model_id', '!=', False)]}"
/>
<field name="cutting_tool_cutterbar_model_id"
options="{'no_create': True, 'no_quick_create': True}"
attrs="{'invisible': ['|',('cutting_tool_cutterpad_model_id','!=',False),('cutting_tool_blade_model_id', '=', False)]}"
/>
<field name="cutting_tool_cutterpad_model_id"
options="{'no_create': True, 'no_quick_create': True}"
attrs="{'invisible': ['|',('cutting_tool_cutterbar_model_id','!=',False),('cutting_tool_blade_model_id', '=', False)]}"
/>
<field name="cutting_tool_cutterhandle_model_id"
options="{'no_create': True, 'no_quick_create': True}"/>
<field name="cutting_tool_cutterhead_model_id"
options="{'no_create': True, 'no_quick_create': True}"/>
</group>
<group>
<field name="image" nolabel="1" widget="image"/>
</group>
</group>
<group col="1">
<group string="适合加工方式">
<field name="suitable_machining_method_ids" string=""
widget="custom_many2many_checkboxes"
domain="[('id','in',suitable_machining_method_ids)]"/>
</group>
<group>
<group string="刀尖特征">
<field name="blade_tip_characteristics_id" string=""
widget="many2one_radio"
domain="[('id','=',blade_tip_characteristics_id)]"/>
</group>
<group string="柄部类型">
<field name="handle_type_id" string="" widget="many2one_radio"
domain="[('id','=',handle_type_id)]"/>
</group>
</group>
<group>
<group string="走刀方向">
<field name="cutting_direction_ids" string="" widget="custom_many2many_checkboxes"
domain="[('id','in',cutting_direction_ids)]"/>
</group>
<group string="适合冷却方式">
<field name="suitable_coolant_ids" string="" widget="custom_many2many_checkboxes"
domain="[('id','in',suitable_coolant_ids)]"/>
</group>
</group>
</group>
<notebook>
<page string='参数'>
<group>
<group>
<field name="functional_tool_diameter"/>
<field name="knife_tip_r_angle"/>
<field name="whether_standard_knife"/>
<field name="coarse_middle_thin"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="current_location_id" invisible="1"/>
<field name="current_location"/>
</group>
<group>
<field name="tool_loading_length"/>
<field name="functional_tool_length"/>
<field name="effective_length"/>
<field name="L_D_number"/>
<field name="hiding_length"/>
<field name="new_former"/>
<field name="cut_time" attrs="{'invisible': [('new_former','=','0')]}"/>
<field name="cut_length" attrs="{'invisible': [('new_former','=','0')]}"/>
<field name="cut_number" attrs="{'invisible': [('new_former','=','0')]}"/>
</group>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="view_functional_cutting_tool_list_search" model="ir.ui.view">
<field name="name">sf.functional.cutting.tool.entity.list.tree</field>
<field name="model">sf.functional.cutting.tool.entity</field>
<field name="arch" type="xml">
<search>
<field name="barcode_id"/>
<field name="rfid"/>
<field name="functional_tool_name_id"/>
<field name="image" widget='image'/>
<field name="functional_tool_diameter"/>
<field name="knife_tip_r_angle"/>
<field name="coarse_middle_thin" optional="hide"/>
<field name="new_former" optional="hide"/>
<field name="tool_loading_length" optional="hide"/>
<field name="functional_tool_length" optional="hide"/>
<field name="effective_length" optional="hide"/>
<field name="tool_room_num"/>
<field name="line_edge_knife_library_num"/>
<field name="machine_knife_library_num"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status" optional="hide"/>
<field name="current_location_id" invisible="True"/>
<field name="sf_cutting_tool_type_id" invisible="True"/>
<filter string="已归档" name="inactive" domain="[('active', '=', False)]"/>
<searchpanel>
<field name="sf_cutting_tool_type_id" icon="fa-building" enable_counters="1"/>
<field name="current_location" icon="fa-building" enable_counters="1"/>
<field name="functional_tool_status" icon="fa-building" enable_counters="1"/>
</searchpanel>
</search>
</field>
</record>
<record id="sf_function_tool_entry_list_view_act" model="ir.actions.act_window">
<field name="name">功能刀具列表</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.functional.cutting.tool.entity</field>
<field name="view_mode">tree,form,search</field>
<field name="view_id" ref="view_functional_cutting_tool_list_tree"/>
</record>
<!-- ======================================== 功能刀具预警========================================-->
<record id="view_sf_functional_tool_warning_tree" model="ir.ui.view">
<field name="name">sf.functional.tool.warning.tree</field>
<field name="model">sf.functional.tool.warning</field>
<field name="arch" type="xml">
<tree string="功能刀具预警" create="0" edit="0" delete="0" editable="bottom">
<field name="production_line_id" optional="hide"/>
<field name="maintenance_equipment_id" optional="hide"/>
<field name="machine_tool_code"/>
<field name="cutter_spacing_code_id"/>
<field name="barcode_id" invisible="1"/>
<field name="rfid"/>
<field name="functional_tool_name_id"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="install_tool_time" optional="hide"/>
<field name="on_board_time" optional="hide"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status"/>
<field name="alarm_time"/>
<field name="dispose_user"/>
<field name="dispose_time"/>
<field name="dispose_func"/>
<!-- <button name="enroll_functional_tool_warning" string="刀具预警注册" type="object"-->
<!-- class="btn-primary"/>-->
</tree>
</field>
</record>
<record id="view_sf_functional_tool_warning_search" model="ir.ui.view">
<field name="name">sf.functional.tool.warning.search</field>
<field name="model">sf.functional.tool.warning</field>
<field name="arch" type="xml">
<search string="功能刀具预警">
<field name="machine_tool_code"/>
<field name="cutter_spacing_code_id"/>
<field name="barcode_id"/>
<field name="rfid"/>
<field name="functional_tool_name_id"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="install_tool_time" optional="hide"/>
<field name="on_board_time" optional="hide"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status"/>
<field name="alarm_time"/>
<field name="dispose_user"/>
<field name="dispose_time"/>
<field name="dispose_func"/>
<field name="production_line_id" invisible="True"/>
<filter string="已归档" name="inactive" domain="[('active', '=', False)]"/>
<searchpanel>
<field name="production_line_id" icon="fa-building" enable_counters="1"/>
<field name="maintenance_equipment_id" icon="fa-building" enable_counters="1"/>
<field name="cutter_spacing_code_id" icon="fa-building" enable_counters="1"/>
<field name="functional_tool_status" icon="fa-building" enable_counters="1"/>
</searchpanel>
</search>
</field>
</record>
<record id="action_sf_functional_tool_warning" model="ir.actions.act_window">
<field name="name">功能刀具预警</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.functional.tool.warning</field>
<field name="view_mode">tree,search</field>
</record>
<!-- =====================================功能刀具安全库存=================================================== -->
<record id="sf_real_time_distribution_of_functional_tools_view_tree" model="ir.ui.view">
<field name="name">功能刀具安全库存</field>
<field name="model">sf.real.time.distribution.of.functional.tools</field>
<field name="arch" type="xml">
<tree>
<field name="name" invisible="1"/>
<field name="functional_name_id"/>
<field name="sf_cutting_tool_type_id" invisible="True"/>
<field name="tool_groups_id"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="coarse_middle_thin"/>
<field name="tool_stock_num"/>
<field name="side_shelf_num"/>
<field name="on_tool_stock_num"/>
<field name="tool_stock_total"/>
<field name="min_stock_num"/>
<field name="max_stock_num"/>
<field name="batch_replenishment_num"/>
<field name="unit"/>
</tree>
</field>
</record>
<record id="sf_real_time_distribution_of_functional_tools_view_form" model="ir.ui.view">
<field name="name">功能刀具安全库存</field>
<field name="model">sf.real.time.distribution.of.functional.tools</field>
<field name="arch" type="xml">
<form>
<!-- <header>-->
<!-- <button name="enroll_functional_tool_real_time_distribution" string="安全库存注册" type="object"-->
<!-- class="btn-primary"/>-->
<!-- </header>-->
<sheet>
<div class="oe_title">
<h1>
<field name="functional_name_id" placeholder="请选择"
attrs="{'readonly': [('status_create', '=', False)]}"/>
</h1>
</div>
<field name="name" invisible="1"/>
<field name="status_create" invisible="1"/>
<group>
<group>
<group>
<field name="sf_cutting_tool_type_id" class="custom_required"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="tool_groups_id" class="custom_required" options="{'no_create': True}"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="diameter" class="custom_required"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="knife_tip_r_angle" class="custom_required"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="coarse_middle_thin"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="whether_standard_knife"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="min_stock_num" class="custom_required"/>
<field name="max_stock_num" class="custom_required"/>
<field name="batch_replenishment_num"/>
</group>
</group>
<group>
<field name="image" widget='image'
attrs="{'readonly': [('status_create', '=', False)]}"/>
</group>
</group>
<group col="1">
<group string="适合加工方式">
<field name="suitable_machining_method_ids" string=""
widget="custom_many2many_checkboxes" readonly="1"
domain="[('id','in',suitable_machining_method_ids)]"/>
</group>
<group>
<group string="刀尖特征">
<field name="blade_tip_characteristics_id" string=""
widget="many2one_radio" readonly="1"
domain="[('id','=',blade_tip_characteristics_id)]"/>
</group>
<group string="柄部类型">
<field name="handle_type_id" string=""
widget="many2one_radio" readonly="1"
domain="[('id','=',handle_type_id)]"/>
</group>
</group>
<group>
<group string="走刀方向">
<field name="cutting_direction_ids" string="" widget="custom_many2many_checkboxes"
readonly="1"
domain="[('id','in',cutting_direction_ids)]"/>
</group>
<group string="适合冷却方式">
<field name="suitable_coolant_ids" string="" widget="custom_many2many_checkboxes"
readonly="1"
domain="[('id','in',suitable_coolant_ids)]"/>
</group>
</group>
</group>
<notebook>
<page string="刀具信息">
<field name="sf_functional_cutting_tool_entity_ids" widget="many2many">
<tree edit="0" create="0" delete="0">
<field name="rfid"/>
<field name="tool_name_id"/>
<field name="new_former"/>
<field name="tool_loading_length" string="总长度(mm)"/>
<field name="functional_tool_length"/>
<field name="effective_length"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="sf_real_time_distribution_of_functional_tools_view_search" model="ir.ui.view">
<field name="name">功能刀具安全库存</field>
<field name="model">sf.real.time.distribution.of.functional.tools</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<field name="sf_cutting_tool_type_id" invisible="True"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="tool_stock_num"/>
<field name="side_shelf_num"/>
<field name="on_tool_stock_num"/>
<field name="tool_stock_total"/>
<field name="min_stock_num"/>
<field name="max_stock_num"/>
<field name="batch_replenishment_num"/>
<field name="unit"/>
<filter string="已归档" name="inactive" domain="[('active', '=', False)]"/>
<searchpanel>
<field name="sf_cutting_tool_type_id" enable_counters="1" icon="fa-building"/>
</searchpanel>
</search>
</field>
</record>
<record id="sf_real_time_distribution_of_functional_tools_view_act" model="ir.actions.act_window">
<field name="name">功能刀具安全库存</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.real.time.distribution.of.functional.tools</field>
<field name="view_mode">tree,form,search</field>
</record>
<!-- ========================================功能刀具出入库记录================================================================== -->
<record id="sf_inbound_and_outbound_records_of_functional_tools_view_tree" model="ir.ui.view">
<field name="name">功能刀具出入库记录</field>
<field name="model">stock.move.line</field>
<field name="arch" type="xml">
<tree string="功能刀具出入库记录" create="0" edit="0" delete="0">
<field name="reference" string="单据号"/>
<field name="lot_id" invisible="1"/>
<field name="rfid"/>
<field name="functional_tool_name_id" optional="hide"/>
<field name="functional_tool_name" string="功能刀具名称"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="install_tool_time"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date"/>
<field name="qty_done" string="数量"/>
<field name="functional_tool_type_id" invisible="True"/>
<!-- <button name="enroll_functional_tool_move" string="安全库存注册" type="object" class="btn-primary"/>-->
</tree>
</field>
</record>
<record id="sf_inbound_and_outbound_records_of_functional_tools_view_search" model="ir.ui.view">
<field name="name">功能刀具出入库记录</field>
<field name="model">stock.move.line</field>
<field name="arch" type="xml">
<search>
<field name="reference"/>
<field name="lot_id"/>
<field name="rfid"/>
<field name="functional_tool_name"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="install_tool_time"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date"/>
<field name="qty_done"/>
<field name="functional_tool_type_id" invisible="True"/>
<searchpanel>
<field name="functional_tool_type_id" enable_counters="1" icon="fa-building"/>
</searchpanel>
</search>
</field>
</record>
<record id="sf_inbound_and_outbound_records_of_functional_tools_view_act" model="ir.actions.act_window">
<field name="name">功能刀具出入库记录</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.move.line</field>
<field name="view_mode">tree,search</field>
<field name="view_id"
ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_tree"/>
<field name="search_view_id"
ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_search"/>
<field name="domain">[('functional_tool_name_id', '!=', False)]</field>
</record>
</data>
</odoo>

View File

@@ -1,513 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<odoo> <odoo>
<data> <data>
<!--========================================功能刀具列表========================================-->
<record id="view_functional_cutting_tool_list_tree" model="ir.ui.view">
<field name="name">sf.functional.cutting.tool.entity.list.tree</field>
<field name="model">sf.functional.cutting.tool.entity</field>
<field name="arch" type="xml">
<tree string="功能刀具列表" create="0" edit="0" delete="0">
<field name="barcode_id" invisible="1"/>
<field name="rfid"/>
<field name="functional_tool_name_id"/>
<field name="image" widget='image'/>
<field name="tool_groups_id"/>
<field name="functional_tool_diameter"/>
<field name="knife_tip_r_angle"/>
<field name="coarse_middle_thin" optional="hide"/>
<field name="new_former" optional="hide"/>
<field name="tool_loading_length" optional="hide"/>
<field name="functional_tool_length" optional="hide"/>
<field name="effective_length" optional="hide"/>
<field name="tool_room_num"/>
<field name="line_edge_knife_library_num"/>
<field name="machine_knife_library_num"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status"/>
<field name="current_location_id" optional="hide"/>
<field name="current_location" optional="hide"/>
<field name="sf_cutting_tool_type_id" invisible="True"/>
</tree>
</field>
</record>
<record id="view_functional_cutting_tool_list_form" model="ir.ui.view">
<field name="name">sf.functional.cutting.tool.entity.list.form</field>
<field name="model">sf.functional.cutting.tool.entity</field>
<field name="arch" type="xml">
<form create="0" edit="0" delete="0">
<header>
<!-- <button name="enroll_functional_tool_entity" string="功能刀具注册" type="object"-->
<!-- class="btn-primary"/>-->
<field name="functional_tool_status" widget="statusbar" statusbar_visible="正常,报警,已拆除"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" groups="sf_base.group_sf_mrp_user"
name="open_functional_tool_warning"
icon="fa-list-ul"
type="object">
<div class="o_field_widget o_stat_info">
<span>
预警记录
</span>
</div>
</button>
<button class="oe_stat_button" groups="sf_base.group_sf_mrp_user"
name="open_stock_move_line"
icon="fa-list-ul"
type="object">
<div class="o_field_widget o_stat_info">
<span>
出库入库记录
</span>
</div>
</button>
<button class="oe_stat_button" groups="sf_base.group_sf_mrp_user"
name="open_safety_stock"
icon="fa-list-ul"
type="object">
<div class="o_field_widget o_stat_info">
<span>
安全库存
</span>
</div>
</button>
</div>
<div class="oe_title">
<h1>
<field name="code" readonly="1" nolabel="True"/>
</h1>
</div>
<group>
<group>
<field name="barcode_id" invisible="1"/>
<field name="rfid" readonly="1"/>
<field name="functional_tool_name_id" invisible="False"
placeholder="请输入20字以内的名称"/>
<field name="sf_cutting_tool_type_id"/>
<field name="tool_groups_id"/>
<field name="cutting_tool_integral_model_id"
options="{'no_create': True, 'no_quick_create': True}"
attrs="{'invisible': [('cutting_tool_blade_model_id', '!=', False)]}"
/>
<field name="cutting_tool_blade_model_id"
options="{'no_create': True, 'no_quick_create': True}"
attrs="{'invisible': [('cutting_tool_integral_model_id', '!=', False)]}"
/>
<field name="cutting_tool_cutterbar_model_id"
options="{'no_create': True, 'no_quick_create': True}"
attrs="{'invisible': ['|',('cutting_tool_cutterpad_model_id','!=',False),('cutting_tool_blade_model_id', '=', False)]}"
/>
<field name="cutting_tool_cutterpad_model_id"
options="{'no_create': True, 'no_quick_create': True}"
attrs="{'invisible': ['|',('cutting_tool_cutterbar_model_id','!=',False),('cutting_tool_blade_model_id', '=', False)]}"
/>
<field name="cutting_tool_cutterhandle_model_id"
options="{'no_create': True, 'no_quick_create': True}"/>
<field name="cutting_tool_cutterhead_model_id"
options="{'no_create': True, 'no_quick_create': True}"/>
</group>
<group>
<field name="image" nolabel="1" widget="image"/>
</group>
</group>
<group col="1">
<group string="适合加工方式">
<field name="suitable_machining_method_ids" string=""
widget="custom_many2many_checkboxes"
domain="[('id','in',suitable_machining_method_ids)]"/>
</group>
<group>
<group string="刀尖特征">
<field name="blade_tip_characteristics_id" string=""
widget="many2one_radio"
domain="[('id','=',blade_tip_characteristics_id)]"/>
</group>
<group string="柄部类型">
<field name="handle_type_id" string="" widget="many2one_radio"
domain="[('id','=',handle_type_id)]"/>
</group>
</group>
<group>
<group string="走刀方向">
<field name="cutting_direction_ids" string="" widget="custom_many2many_checkboxes"
domain="[('id','in',cutting_direction_ids)]"/>
</group>
<group string="适合冷却方式">
<field name="suitable_coolant_ids" string="" widget="custom_many2many_checkboxes"
domain="[('id','in',suitable_coolant_ids)]"/>
</group>
</group>
</group>
<notebook>
<page string='参数'>
<group>
<group>
<field name="functional_tool_diameter"/>
<field name="knife_tip_r_angle"/>
<field name="whether_standard_knife"/>
<field name="coarse_middle_thin"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="current_location_id" invisible="1"/>
<field name="current_location"/>
</group>
<group>
<field name="tool_loading_length"/>
<field name="functional_tool_length"/>
<field name="effective_length"/>
<field name="L_D_number"/>
<field name="hiding_length"/>
<field name="new_former"/>
<field name="cut_time" attrs="{'invisible': [('new_former','=','0')]}"/>
<field name="cut_length" attrs="{'invisible': [('new_former','=','0')]}"/>
<field name="cut_number" attrs="{'invisible': [('new_former','=','0')]}"/>
</group>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="view_functional_cutting_tool_list_search" model="ir.ui.view">
<field name="name">sf.functional.cutting.tool.entity.list.tree</field>
<field name="model">sf.functional.cutting.tool.entity</field>
<field name="arch" type="xml">
<search>
<field name="barcode_id"/>
<field name="rfid"/>
<field name="functional_tool_name_id"/>
<field name="image" widget='image'/>
<field name="functional_tool_diameter"/>
<field name="knife_tip_r_angle"/>
<field name="coarse_middle_thin" optional="hide"/>
<field name="new_former" optional="hide"/>
<field name="tool_loading_length" optional="hide"/>
<field name="functional_tool_length" optional="hide"/>
<field name="effective_length" optional="hide"/>
<field name="tool_room_num"/>
<field name="line_edge_knife_library_num"/>
<field name="machine_knife_library_num"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status" optional="hide"/>
<field name="current_location_id" invisible="True"/>
<field name="sf_cutting_tool_type_id" invisible="True"/>
<filter string="已归档" name="inactive" domain="[('active', '=', False)]"/>
<searchpanel>
<field name="sf_cutting_tool_type_id" icon="fa-building" enable_counters="1"/>
<field name="current_location" icon="fa-building" enable_counters="1"/>
<field name="functional_tool_status" icon="fa-building" enable_counters="1"/>
</searchpanel>
</search>
</field>
</record>
<record id="sf_function_tool_entry_list_view_act" model="ir.actions.act_window">
<field name="name">功能刀具列表</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.functional.cutting.tool.entity</field>
<field name="view_mode">tree,form,search</field>
<field name="view_id" ref="view_functional_cutting_tool_list_tree"/>
</record>
<!-- ======================================== 功能刀具预警========================================-->
<record id="view_sf_functional_tool_warning_tree" model="ir.ui.view">
<field name="name">sf.functional.tool.warning.tree</field>
<field name="model">sf.functional.tool.warning</field>
<field name="arch" type="xml">
<tree string="功能刀具预警" create="0" edit="0" delete="0" editable="bottom">
<field name="production_line_id" optional="hide"/>
<field name="maintenance_equipment_id" optional="hide"/>
<field name="machine_tool_code"/>
<field name="cutter_spacing_code_id"/>
<field name="barcode_id" invisible="1"/>
<field name="rfid"/>
<field name="functional_tool_name_id"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="install_tool_time" optional="hide"/>
<field name="on_board_time" optional="hide"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status"/>
<field name="alarm_time"/>
<field name="dispose_user"/>
<field name="dispose_time"/>
<field name="dispose_func"/>
<!-- <button name="enroll_functional_tool_warning" string="刀具预警注册" type="object"-->
<!-- class="btn-primary"/>-->
</tree>
</field>
</record>
<record id="view_sf_functional_tool_warning_search" model="ir.ui.view">
<field name="name">sf.functional.tool.warning.search</field>
<field name="model">sf.functional.tool.warning</field>
<field name="arch" type="xml">
<search string="功能刀具预警">
<field name="machine_tool_code"/>
<field name="cutter_spacing_code_id"/>
<field name="barcode_id"/>
<field name="rfid"/>
<field name="functional_tool_name_id"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="install_tool_time" optional="hide"/>
<field name="on_board_time" optional="hide"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status"/>
<field name="alarm_time"/>
<field name="dispose_user"/>
<field name="dispose_time"/>
<field name="dispose_func"/>
<field name="production_line_id" invisible="True"/>
<filter string="已归档" name="inactive" domain="[('active', '=', False)]"/>
<searchpanel>
<field name="production_line_id" icon="fa-building" enable_counters="1"/>
<field name="maintenance_equipment_id" icon="fa-building" enable_counters="1"/>
<field name="cutter_spacing_code_id" icon="fa-building" enable_counters="1"/>
<field name="functional_tool_status" icon="fa-building" enable_counters="1"/>
</searchpanel>
</search>
</field>
</record>
<record id="action_sf_functional_tool_warning" model="ir.actions.act_window">
<field name="name">功能刀具预警</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.functional.tool.warning</field>
<field name="view_mode">tree,search</field>
</record>
<!-- =====================================功能刀具安全库存=================================================== -->
<record id="sf_real_time_distribution_of_functional_tools_view_tree" model="ir.ui.view">
<field name="name">功能刀具安全库存</field>
<field name="model">sf.real.time.distribution.of.functional.tools</field>
<field name="arch" type="xml">
<tree>
<field name="name" invisible="1"/>
<field name="functional_name_id"/>
<field name="sf_cutting_tool_type_id" invisible="True"/>
<field name="tool_groups_id"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="coarse_middle_thin"/>
<field name="tool_stock_num"/>
<field name="side_shelf_num"/>
<field name="on_tool_stock_num"/>
<field name="tool_stock_total"/>
<field name="min_stock_num"/>
<field name="max_stock_num"/>
<field name="batch_replenishment_num"/>
<field name="unit"/>
</tree>
</field>
</record>
<record id="sf_real_time_distribution_of_functional_tools_view_form" model="ir.ui.view">
<field name="name">功能刀具安全库存</field>
<field name="model">sf.real.time.distribution.of.functional.tools</field>
<field name="arch" type="xml">
<form>
<!-- <header>-->
<!-- <button name="enroll_functional_tool_real_time_distribution" string="安全库存注册" type="object"-->
<!-- class="btn-primary"/>-->
<!-- </header>-->
<sheet>
<div class="oe_title">
<h1>
<field name="functional_name_id" placeholder="请选择"
attrs="{'readonly': [('status_create', '=', False)]}"/>
</h1>
</div>
<field name="name" invisible="1"/>
<field name="status_create" invisible="1"/>
<group>
<group>
<field name="sf_cutting_tool_type_id" class="custom_required"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="tool_groups_id" class="custom_required" options="{'no_create': True}"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="diameter" class="custom_required"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="knife_tip_r_angle" class="custom_required"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="coarse_middle_thin"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="whether_standard_knife"
attrs="{'readonly': [('status_create', '=', False)]}"/>
<field name="min_stock_num" class="custom_required"/>
<field name="max_stock_num" class="custom_required"/>
<field name="batch_replenishment_num"/>
</group>
<group>
<field name="image" widget='image'
attrs="{'readonly': [('status_create', '=', False)]}"/>
</group>
</group>
<group col="1">
<group string="适合加工方式">
<field name="suitable_machining_method_ids" string=""
widget="custom_many2many_checkboxes" readonly="1"
domain="[('id','in',suitable_machining_method_ids)]"/>
</group>
<group>
<group string="刀尖特征">
<field name="blade_tip_characteristics_id" string=""
widget="many2one_radio" readonly="1"
domain="[('id','=',blade_tip_characteristics_id)]"/>
</group>
<group string="柄部类型">
<field name="handle_type_id" string=""
widget="many2one_radio" readonly="1"
domain="[('id','=',handle_type_id)]"/>
</group>
</group>
<group>
<group string="走刀方向">
<field name="cutting_direction_ids" string="" widget="custom_many2many_checkboxes"
readonly="1"
domain="[('id','in',cutting_direction_ids)]"/>
</group>
<group string="适合冷却方式">
<field name="suitable_coolant_ids" string="" widget="custom_many2many_checkboxes"
readonly="1"
domain="[('id','in',suitable_coolant_ids)]"/>
</group>
</group>
</group>
<notebook>
<page string="刀具信息">
<field name="sf_functional_cutting_tool_entity_ids" widget="many2many">
<tree edit="0" create="0" delete="0">
<field name="rfid"/>
<field name="functional_tool_name_id"/>
<field name="new_former"/>
<field name="tool_loading_length" string="总长度(mm)"/>
<field name="functional_tool_length"/>
<field name="effective_length"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="sf_real_time_distribution_of_functional_tools_view_search" model="ir.ui.view">
<field name="name">功能刀具安全库存</field>
<field name="model">sf.real.time.distribution.of.functional.tools</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<field name="sf_cutting_tool_type_id" invisible="True"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="tool_stock_num"/>
<field name="side_shelf_num"/>
<field name="on_tool_stock_num"/>
<field name="tool_stock_total"/>
<field name="min_stock_num"/>
<field name="max_stock_num"/>
<field name="batch_replenishment_num"/>
<field name="unit"/>
<filter string="已归档" name="inactive" domain="[('active', '=', False)]"/>
<searchpanel>
<field name="sf_cutting_tool_type_id" enable_counters="1" icon="fa-building"/>
</searchpanel>
</search>
</field>
</record>
<record id="sf_real_time_distribution_of_functional_tools_view_act" model="ir.actions.act_window">
<field name="name">功能刀具安全库存</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.real.time.distribution.of.functional.tools</field>
<field name="view_mode">tree,form,search</field>
</record>
<!-- ========================================功能刀具出入库记录================================================================== -->
<record id="sf_inbound_and_outbound_records_of_functional_tools_view_tree" model="ir.ui.view">
<field name="name">功能刀具出入库记录</field>
<field name="model">stock.move.line</field>
<field name="arch" type="xml">
<tree string="功能刀具出入库记录" create="0" edit="0" delete="0">
<field name="reference" string="单据号"/>
<field name="lot_id" invisible="1"/>
<field name="rfid"/>
<field name="functional_tool_name_id" string="功能刀具名称"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="install_tool_time"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date"/>
<field name="qty_done" string="数量"/>
<field name="functional_tool_type_id" invisible="True"/>
<!-- <button name="enroll_functional_tool_move" string="安全库存注册" type="object" class="btn-primary"/>-->
</tree>
</field>
</record>
<record id="sf_inbound_and_outbound_records_of_functional_tools_view_search" model="ir.ui.view">
<field name="name">功能刀具出入库记录</field>
<field name="model">stock.move.line</field>
<field name="arch" type="xml">
<search>
<field name="reference"/>
<field name="lot_id"/>
<field name="rfid"/>
<field name="functional_tool_name_id"/>
<field name="diameter"/>
<field name="knife_tip_r_angle"/>
<field name="install_tool_time"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date"/>
<field name="qty_done"/>
<field name="functional_tool_type_id" invisible="True"/>
<searchpanel>
<field name="functional_tool_type_id" enable_counters="1" icon="fa-building"/>
</searchpanel>
</search>
</field>
</record>
<record id="sf_inbound_and_outbound_records_of_functional_tools_view_act" model="ir.actions.act_window">
<field name="name">功能刀具出入库记录</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.move.line</field>
<field name="view_mode">tree,search</field>
<field name="view_id"
ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_tree"/>
<field name="search_view_id"
ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_search"/>
<field name="domain">[('functional_tool_name_id', '!=', False)]</field>
</record>
<!--================================================机床换刀申请================================================--> <!--================================================机床换刀申请================================================-->
<record id="sf_machine_table_tool_changing_apply_tree" model="ir.ui.view"> <record id="sf_machine_table_tool_changing_apply_tree" model="ir.ui.view">
<field name="name">机床换刀申请</field> <field name="name">机床换刀申请</field>
@@ -998,7 +491,7 @@
<field name="name">功能刀具组装</field> <field name="name">功能刀具组装</field>
<field name="model">sf.functional.tool.assembly</field> <field name="model">sf.functional.tool.assembly</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form create="0" delete="0"> <form create="0" delete="0" edit="0">
<header> <header>
<button string="组装" <button string="组装"
name="%(sf_tool_management.sf_functional_tool_assembly_order_act)d" name="%(sf_tool_management.sf_functional_tool_assembly_order_act)d"
@@ -1096,41 +589,57 @@
</group> </group>
</group> </group>
<group> <group>
<group col="1"> <group col="1" attrs="{'invisible': [('handle_code_id', '=', False)]}">
<group col="1" attrs="{'invisible': [('handle_code_id', '=', False)]}"> <div>
<div> <separator string="刀柄:" style="font-size: 13px;"/>
<separator string="刀柄:" style="font-size: 13px;"/> </div>
</div> <group>
<field name="handle_code_id" string="序列号" placeholder="请选择"
options="{'no_create': True, 'no_quick_create': True}"/>
<field name="handle_freight_rfid" string="Rfid"/>
<field name="handle_product_id" string="名称"/>
<field name="cutting_tool_cutterhandle_model_id" string="型号"/>
<field name="handle_specification_id" string="规格"/>
<field name="sf_tool_brand_id_5" string="品牌"/>
</group>
</group>
<group col="1" attrs="{'invisible': [('chuck_freight_barcode', '=', False)]}">
<div>
<separator string="夹头:" style="font-size: 13px;"/>
</div>
<group>
<group> <group>
<field name="handle_code_id" string="序列号" placeholder="请选择" <field name="chuck_freight_barcode" string="货位"/>
options="{'no_create': True, 'no_quick_create': True}"/> <field name="chuck_product_id" string="名称"/>
<field name="handle_name" string="名称"/> <field name="cutting_tool_cutterhead_model_id" string="型号"/>
<field name="cutting_tool_cutterhandle_model_id" string="型号"/> <field name="chuck_specification_id" string="规格"/>
<field name="handle_specification_id" string="规格"/> <field name="sf_tool_brand_id_6" string="品牌"/>
<field name="sf_tool_brand_id_5" string="品牌"/>
</group> </group>
</group> </group>
<group col="1" attrs="{'invisible': [('integral_code_id', '=', False)]}"> </group>
</group>
<group>
<group col="1">
<group col="1"
attrs="{'invisible': [('integral_freight_barcode', '=', False)]}">
<div> <div>
<separator string="整体式刀具:" style="font-size: 13px;"/> <separator string="整体式刀具:" style="font-size: 13px;"/>
</div> </div>
<group> <group>
<field name="integral_code_id" placeholder="请选择" string="序列号" <field name="integral_freight_barcode" string="货位"/>
options="{'no_create': True, 'no_quick_create': True}"/> <field name="integral_product_id" string="名称"/>
<field name="integral_name" string="名称"/>
<field name="cutting_tool_integral_model_id" string="型号"/> <field name="cutting_tool_integral_model_id" string="型号"/>
<field name="integral_specification_id" string="规格"/> <field name="integral_specification_id" string="规格"/>
<field name="sf_tool_brand_id_1" string="品牌"/> <field name="sf_tool_brand_id_1" string="品牌"/>
</group> </group>
</group> </group>
<group col="1" attrs="{'invisible': [('blade_code_id', '=', False)]}"> <group col="1" attrs="{'invisible': [('blade_freight_barcode', '=', False)]}">
<div> <div>
<separator string="刀片:" style="font-size: 13px;"/> <separator string="刀片:" style="font-size: 13px;"/>
</div> </div>
<group> <group>
<field name="blade_code_id" placeholder="请选择" string="序列号" <field name="blade_freight_barcode" string="货位"/>
options="{'no_create': True, 'no_quick_create': True}"/> <field name="blade_product_id" string="名称"/>
<field name="blade_name" string="名称"/>
<field name="cutting_tool_blade_model_id" string="型号"/> <field name="cutting_tool_blade_model_id" string="型号"/>
<field name="blade_specification_id" string="规格"/> <field name="blade_specification_id" string="规格"/>
<field name="sf_tool_brand_id_2" string="品牌"/> <field name="sf_tool_brand_id_2" string="品牌"/>
@@ -1138,45 +647,28 @@
</group> </group>
</group> </group>
<group col="1"> <group col="1">
<group col="1" attrs="{'invisible': [('chuck_code_id', '=', False)]}"> <group col="1" attrs="{'invisible': [('bar_freight_barcode', '=', False)]}">
<div>
<separator string="夹头:" style="font-size: 13px;"/>
</div>
<group>
<group>
<field name="chuck_code_id" string="序列号" placeholder="请选择"
options="{'no_create': True, 'no_quick_create': True}"/>
<field name="chuck_name" string="名称"/>
<field name="cutting_tool_cutterhead_model_id" string="型号"/>
<field name="chuck_specification_id" string="规格"/>
<field name="sf_tool_brand_id_6" string="品牌"/>
</group>
</group>
</group>
<group col="1" attrs="{'invisible': [('bar_code_id', '=', False)]}">
<div> <div>
<separator string="刀杆:" style="font-size: 13px;"/> <separator string="刀杆:" style="font-size: 13px;"/>
</div> </div>
<group> <group>
<group> <group>
<field name="bar_code_id" placeholder="请选择" string="序列号" <field name="bar_freight_barcode" string="货位"/>
options="{'no_create': True, 'no_quick_create': True}"/> <field name="bar_product_id" string="名称"/>
<field name="bar_name" string="名称"/>
<field name="cutting_tool_cutterbar_model_id" string="型号"/> <field name="cutting_tool_cutterbar_model_id" string="型号"/>
<field name="bar_specification_id" string="规格"/> <field name="bar_specification_id" string="规格"/>
<field name="sf_tool_brand_id_3" string="品牌"/> <field name="sf_tool_brand_id_3" string="品牌"/>
</group> </group>
</group> </group>
</group> </group>
<group col="1" attrs="{'invisible': [('pad_code_id', '=', False)]}"> <group col="1" attrs="{'invisible': [('pad_freight_barcode', '=', False)]}">
<div> <div>
<separator string="刀盘:" style="font-size: 13px;"/> <separator string="刀盘:" style="font-size: 13px;"/>
</div> </div>
<group> <group>
<group> <group>
<field name="pad_code_id" placeholder="请选择" string="序列号" <field name="pad_freight_barcode" string="货位"/>
options="{'no_create': True, 'no_quick_create': True}"/> <field name="pad_product_id" string="名称"/>
<field name="pad_name" string="名称"/>
<field name="cutting_tool_cutterpad_model_id" string="型号"/> <field name="cutting_tool_cutterpad_model_id" string="型号"/>
<field name="pad_specification_id" string="规格"/> <field name="pad_specification_id" string="规格"/>
<field name="sf_tool_brand_id_4" string="品牌"/> <field name="sf_tool_brand_id_4" string="品牌"/>

View File

@@ -57,7 +57,7 @@
</group> </group>
</group> </group>
<notebook> <notebook>
<page string="序列号"> <page string="序列号" attrs="{'invisible': [('barcode_ids', '=', [])]}">
<field name="barcode_ids"> <field name="barcode_ids">
<tree> <tree>
<field name="name"/> <field name="name"/>

View File

@@ -221,12 +221,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
image = fields.Binary('图片') image = fields.Binary('图片')
@api.onchange('functional_tool_name')
def _onchange_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)])
if inventory:
item.after_name_id = inventory.id
# 功能刀具组装信息 # 功能刀具组装信息
# ===============整体式刀具型号================= # ===============整体式刀具型号=================
integral_freight_barcode = fields.Char('整体式刀具货位') integral_freight_barcode = fields.Char('整体式刀具货位')
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'),
('tool_material_status', '=', '可用')])
integral_product_id = fields.Many2one('product.product', string='整体式刀具名称', integral_product_id = fields.Many2one('product.product', string='整体式刀具名称',
compute='_compute_integral_product_id', store=True) compute='_compute_integral_product_id', store=True)
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
@@ -241,12 +246,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)]) location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
if location: if location:
self.integral_product_id = location.product_id.id self.integral_product_id = location.product_id.id
else:
self.integral_product_id = False
# ===============刀片型号==================== # ===============刀片型号====================
blade_freight_barcode = fields.Char('刀片货位') blade_freight_barcode = fields.Char('刀片货位')
blade_code_id = fields.Many2one('stock.lot', '刀片序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀片'),
('tool_material_status', '=', '可用')])
blade_product_id = fields.Many2one('product.product', string='刀片名称', compute='_compute_blade_product_id', blade_product_id = fields.Many2one('product.product', string='刀片名称', compute='_compute_blade_product_id',
store=True) store=True)
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
@@ -260,12 +264,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)]) location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
if location: if location:
self.blade_product_id = location.product_id.id self.blade_product_id = location.product_id.id
else:
self.blade_product_id = False
# ====================刀杆型号================== # ====================刀杆型号==================
bar_freight_barcode = fields.Char('刀杆货位') bar_freight_barcode = fields.Char('刀杆货位')
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆'),
('tool_material_status', '=', '可用')])
bar_product_id = fields.Many2one('product.product', string='刀杆名称', compute='_compute_bar_product_id', bar_product_id = fields.Many2one('product.product', string='刀杆名称', compute='_compute_bar_product_id',
store=True) store=True)
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
@@ -279,12 +282,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)]) location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
if location: if location:
self.bar_product_id = location.product_id.id self.bar_product_id = location.product_id.id
else:
self.bar_product_id = False
# ===============刀盘型号=================== # ===============刀盘型号===================
pad_freight_barcode = fields.Char('刀盘货位') pad_freight_barcode = fields.Char('刀盘货位')
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘'),
('tool_material_status', '=', '可用')])
pad_product_id = fields.Many2one('product.product', string='刀盘名称', compute='_compute_pad_product_id', pad_product_id = fields.Many2one('product.product', string='刀盘名称', compute='_compute_pad_product_id',
store=True) store=True)
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
@@ -298,23 +300,31 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)]) location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
if location: if location:
self.pad_product_id = location.product_id.id self.pad_product_id = location.product_id.id
else:
self.pad_product_id = False
# ================刀柄型号=============== # ================刀柄型号===============
handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_rfid')
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True, handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True,
domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄'), domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄'),
('tool_material_status', '=', '可用')]) ('tool_material_status', '=', '可用')])
handle_product_id = fields.Many2one('product.product', string='刀柄名称', related='handle_code_id.product_id') handle_product_id = fields.Many2one('product.product', string='刀柄名称', compute='_compute_handle_product_id',
store=True)
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
related='handle_code_id.product_id.cutting_tool_model_id') related='handle_code_id.product_id.cutting_tool_model_id')
handle_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀柄规格', handle_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀柄规格',
related='handle_code_id.product_id.specification_id') related='handle_code_id.product_id.specification_id')
sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', related='handle_code_id.product_id.brand_id') sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', related='handle_code_id.product_id.brand_id')
@api.depends('handle_code_id')
def _compute_handle_product_id(self):
if self.handle_code_id:
self.handle_product_id = self.handle_code_id.product_id.id
else:
self.pad_product_id = False
# =================夹头型号============== # =================夹头型号==============
chuck_freight_barcode = fields.Char('夹头货位', required=True) chuck_freight_barcode = fields.Char('夹头货位')
chuck_code_id = fields.Many2one('stock.lot', '夹头序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '夹头'),
('tool_material_status', '=', '可用')])
chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id', chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id',
store=True) store=True)
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
@@ -328,6 +338,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)]) location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
if location: if location:
self.chuck_product_id = location.product_id.id self.chuck_product_id = location.product_id.id
else:
self.chuck_product_id = False
# ======================================== # ========================================
@@ -349,16 +361,24 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', barcode)]) location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', barcode)])
if location: if location:
material_name = location.product_id.cutting_tool_material_id.name material_name = location.product_id.cutting_tool_material_id.name
if material_name == '整体式刀具': if material_name == '夹头':
record.chuck_freight_barcode = barcode
elif material_name == '整体式刀具':
record.integral_freight_barcode = barcode record.integral_freight_barcode = barcode
record.blade_freight_barcode = ''
record.bar_freight_barcode = ''
record.pad_freight_barcode = ''
elif material_name == '刀片': elif material_name == '刀片':
record.blade_freight_barcode = barcode record.blade_freight_barcode = barcode
record.integral_freight_barcode = ''
elif material_name == '刀杆': elif material_name == '刀杆':
record.bar_freight_barcode = barcode record.bar_freight_barcode = barcode
record.integral_freight_barcode = ''
record.pad_freight_barcode = ''
elif material_name == '刀盘': elif material_name == '刀盘':
record.pad_freight_barcode = barcode record.pad_freight_barcode = barcode
elif material_name == '夹头': record.integral_freight_barcode = ''
record.chuck_freight_barcode = barcode record.bar_freight_barcode = ''
else: else:
raise ValidationError('扫描的刀具物料不存在,请重新扫描!') raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
else: else:
@@ -369,18 +389,19 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
for item in self: for item in self:
if item: if item:
item.rfid = item.handle_code_id.rfid item.rfid = item.handle_code_id.rfid
item.handle_freight_rfid = item.handle_code_id.rfid
else: else:
item.rfid = None item.rfid = None
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='功能刀具名称', required=True)
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号') barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
rfid = fields.Char('Rfid', readonly=True, store=True, compute='_compute_rfid') rfid = fields.Char('Rfid', compute='_compute_rfid')
tool_code = fields.Char(string='功能刀具编码', readonly=True, compute='_compute_tool_code') tool_code = fields.Char(string='功能刀具编码', compute='_compute_tool_code')
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name', store=True) 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', after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
string='组装后功能刀具类型', string='组装后功能刀具类型')
compute='_compute_after_assembly_functional_tool_type_id')
after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)') after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)')
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)') after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)')
after_assembly_new_former = fields.Selection([('0', ''), ('1', '')], string='组装后新/旧', default='0') after_assembly_new_former = fields.Selection([('0', ''), ('1', '')], string='组装后新/旧', default='0')
@@ -399,6 +420,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
after_assembly_effective_length = fields.Float(string='组装后有效长(mm)') after_assembly_effective_length = fields.Float(string='组装后有效长(mm)')
L_D_number = fields.Float(string='L/D值(mm)', compute='_compute_l_d_number') L_D_number = fields.Float(string='L/D值(mm)', compute='_compute_l_d_number')
hiding_length = fields.Float(string='避空长(mm)') hiding_length = fields.Float(string='避空长(mm)')
after_tool_groups_id = fields.Many2one('sf.tool.groups', string='组装后刀具组')
@api.onchange('after_name_id')
def _onchange_number(self):
for item in self:
if item.after_name_id:
item.after_assembly_functional_tool_diameter = item.after_name_id.diameter
item.after_assembly_knife_tip_r_angle = item.after_name_id.angle
item.after_assembly_max_lifetime_value = item.after_name_id.life_span
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
item.after_tool_groups_id = item.tool_groups_id.id
# functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False) # functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False)
# res_partner_id = fields.Many2one('res.partner', '智能工厂', domain="[('is_factory', '=', True)]") # res_partner_id = fields.Many2one('res.partner', '智能工厂', domain="[('is_factory', '=', True)]")
@@ -409,30 +447,29 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
for obj in self: for obj in self:
str_1 = 'GNDJ-%s' % obj.after_assembly_functional_tool_type_id.code str_1 = 'GNDJ-%s' % obj.after_assembly_functional_tool_type_id.code
str_2 = '' str_2 = ''
num = None
if obj.handle_specification_id: if obj.handle_specification_id:
if obj.integral_specification_id: if obj.integral_specification_id:
str_2 = '%s-D%sL%sB%sH%s-' % ( str_2 = '%s-D%sL%sB%sH%s-' % (
str_1, obj.integral_specification_id.blade_diameter, obj.after_assembly_tool_loading_length, str_1, obj.integral_specification_id.blade_diameter, obj.after_assembly_tool_loading_length,
obj.integral_specification_id.blade_length, obj.handle_specification_id.total_length) obj.integral_specification_id.blade_length, obj.handle_specification_id.total_length)
num = self._get_code(str_2)
elif obj.bar_specification_id: elif obj.bar_specification_id:
str_2 = '%s-D%sL%sB%sH%s-' % ( str_2 = '%s-D%sL%sB%sH%s-' % (
str_1, obj.bar_specification_id.cutter_arbor_diameter, obj.after_assembly_tool_loading_length, str_1, obj.bar_specification_id.cutter_arbor_diameter, obj.after_assembly_tool_loading_length,
obj.bar_specification_id.blade_length, obj.handle_specification_id.total_length) obj.bar_specification_id.blade_length, obj.handle_specification_id.total_length)
num = self._get_code(str_2)
elif obj.pad_specification_id: elif obj.pad_specification_id:
str_2 = '%s-D%sL%sB%sH%s-' % ( str_2 = '%s-D%sL%sB%sH%s-' % (
str_1, obj.pad_specification_id.cutter_head_diameter, obj.after_assembly_tool_loading_length, str_1, obj.pad_specification_id.cutter_head_diameter, obj.after_assembly_tool_loading_length,
obj.pad_specification_id.cut_depth_max, obj.handle_specification_id.total_length, obj.pad_specification_id.cut_depth_max, obj.handle_specification_id.total_length,
) )
num = self._get_code(str_2) else:
obj.tool_code = str_2 + str(num) obj.tool_code = str_2
return True
obj.tool_code = str_2 + str(self._get_code(str_2))
else: else:
obj.tool_code = '' obj.tool_code = str_2
def _get_code(self, str_2): def _get_code(self, str_2):
functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().search( functional_tool_assembly = self.env['sf.functional.cutting.tool.entity'].sudo().search(
[('code', 'like', str_2)], [('code', 'like', str_2)],
limit=1, limit=1,
order="id desc" order="id desc"
@@ -455,27 +492,19 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
@api.onchange('integral_freight_barcode') @api.onchange('integral_freight_barcode')
def _onchange_after_assembly_functional_tool_diameter(self): def _onchange_after_assembly_functional_tool_diameter(self):
for obj in self: for obj in self:
if obj.integral_code_id: if obj.integral_product_id:
obj.after_assembly_functional_tool_diameter = obj.integral_code_id.product_id.cutting_tool_blade_diameter obj.after_assembly_functional_tool_diameter = obj.integral_product_id.cutting_tool_blade_diameter
else: else:
obj.after_assembly_functional_tool_diameter = 0 obj.after_assembly_functional_tool_diameter = 0
@api.onchange('blade_code_id') @api.onchange('blade_freight_barcode')
def _onchange_after_assembly_knife_tip_r_angle(self): def _onchange_after_assembly_knife_tip_r_angle(self):
for obj in self: for obj in self:
if obj.blade_code_id: if obj.blade_product_id:
obj.after_assembly_knife_tip_r_angle = obj.blade_code_id.product_id.cutting_tool_blade_tip_circular_arc_radius obj.after_assembly_knife_tip_r_angle = obj.blade_product_id.cutting_tool_blade_tip_circular_arc_radius
else: else:
obj.after_assembly_knife_tip_r_angle = 0 obj.after_assembly_knife_tip_r_angle = 0
@api.depends('functional_tool_type_id')
def _compute_after_assembly_functional_tool_type_id(self):
for obj in self:
if obj.functional_tool_type_id:
obj.after_assembly_functional_tool_type_id = obj.functional_tool_type_id
else:
obj.after_assembly_functional_tool_type_id = None
@api.depends('hiding_length', 'after_assembly_functional_tool_diameter') @api.depends('hiding_length', 'after_assembly_functional_tool_diameter')
def _compute_l_d_number(self): def _compute_l_d_number(self):
for record in self: for record in self:
@@ -524,18 +553,18 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 创建刀具组装入库单 # 创建刀具组装入库单
self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly, self) self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly, self)
# 刀具物料出库 # 刀具物料出库
if self.integral_code_id:
product_id.tool_material_stock_moves(self.integral_code_id)
if self.blade_code_id:
product_id.tool_material_stock_moves(self.blade_code_id)
if self.bar_code_id:
product_id.tool_material_stock_moves(self.bar_code_id)
if self.pad_code_id:
product_id.tool_material_stock_moves(self.pad_code_id)
if self.handle_code_id: if self.handle_code_id:
product_id.tool_material_stock_moves(self.handle_code_id) product_id.tool_material_stock_moves(self.handle_code_id)
if self.chuck_code_id: if self.integral_product_id:
product_id.tool_material_stock_moves(self.chuck_code_id) self.integral_product_id.material_stock_moves(self.integral_freight_barcode)
if self.blade_product_id:
self.blade_product_id.material_stock_moves(self.blade_freight_barcode)
if self.bar_product_id:
self.bar_product_id.material_stock_moves(self.bar_freight_barcode)
if self.pad_product_id:
self.pad_product_id.material_stock_moves(self.pad_freight_barcode)
if self.chuck_product_id:
self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode)
# ============================创建功能刀具列表、安全库存记录=============================== # ============================创建功能刀具列表、安全库存记录===============================
# 封装功能刀具数据 # 封装功能刀具数据
@@ -546,7 +575,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
self.env['sf.real.time.distribution.of.functional.tools'].create_or_edit_safety_stock({ self.env['sf.real.time.distribution.of.functional.tools'].create_or_edit_safety_stock({
'functional_name_id': self.after_name_id.id, 'functional_name_id': self.after_name_id.id,
'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id, 'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id,
'tool_groups_id': self.tool_groups_id.id, 'tool_groups_id': self.after_tool_groups_id.id,
'diameter': self.after_assembly_functional_tool_diameter, 'diameter': self.after_assembly_functional_tool_diameter,
'knife_tip_r_angle': self.after_assembly_knife_tip_r_angle, 'knife_tip_r_angle': self.after_assembly_knife_tip_r_angle,
'coarse_middle_thin': self.after_assembly_coarse_middle_thin, 'coarse_middle_thin': self.after_assembly_coarse_middle_thin,
@@ -575,25 +604,24 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
""" """
功能刀具组装物料必填判断 功能刀具组装物料必填判断
""" """
if not self.integral_code_id and not self.blade_code_id: if not self.integral_product_id and not self.blade_product_id:
raise ValidationError('【整体式刀具】和【刀片】必须填写一个!') raise ValidationError('【整体式刀具】和【刀片】必须填写一个!')
if self.blade_code_id: if self.blade_product_id:
if not self.bar_code_id and not self.pad_code_id: if not self.bar_product_id and not self.pad_product_id:
raise ValidationError('【刀盘】和【刀杆】必须填写一个!') raise ValidationError('【刀盘】和【刀杆】必须填写一个!')
def get_desc_1(self, stock_lot): def get_desc_1(self, stock_lot):
return { return {
'barcode_id': stock_lot.id, 'barcode_id': stock_lot.id,
'code': self.tool_code, 'code': self.tool_code,
'name': self.after_assembly_functional_tool_name,
'rfid': self.rfid, 'rfid': self.rfid,
'tool_groups_id': self.tool_groups_id.id, 'tool_groups_id': self.after_tool_groups_id.id,
'integral_product_id': self.integral_product_id.id, 'integral_freight_barcode': self.integral_freight_barcode,
'blade_product_id': self.blade_product_id.id, 'blade_freight_barcode': self.blade_freight_barcode,
'bar_product_id': self.bar_product_id.id, 'bar_freight_barcode': self.bar_freight_barcode,
'pad_product_id': self.pad_product_id.id, 'pad_freight_barcode': self.pad_freight_barcode,
'handle_code_id': self.handle_code_id.id, 'handle_code_id': self.handle_code_id.id,
'chuck_product_id': self.chuck_product_id.id, 'chuck_freight_barcode': self.chuck_freight_barcode,
'after_assembly_functional_tool_name': self.after_assembly_functional_tool_name, 'after_assembly_functional_tool_name': self.after_assembly_functional_tool_name,
'after_assembly_functional_tool_type_id': self.after_assembly_functional_tool_type_id.id, 'after_assembly_functional_tool_type_id': self.after_assembly_functional_tool_type_id.id,
@@ -623,9 +651,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
return { return {
'barcode_id': stock_lot.id, 'barcode_id': stock_lot.id,
'code': self.tool_code, 'code': self.tool_code,
'name': self.after_assembly_functional_tool_name, 'name': self.after_name_id.name,
'tool_name_id': self.after_name_id.id,
'rfid': self.rfid, 'rfid': self.rfid,
'tool_groups_id': self.tool_groups_id.id, 'tool_groups_id': self.after_tool_groups_id.id,
'functional_tool_name_id': functional_tool_assembly_id.id, 'functional_tool_name_id': functional_tool_assembly_id.id,
'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id, 'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id,
'cutting_tool_integral_model_id': self.integral_product_id.id, 'cutting_tool_integral_model_id': self.integral_product_id.id,
@@ -687,7 +716,7 @@ class StockPicking(models.Model):
'code': obj.tool_code, 'code': obj.tool_code,
'rfid': obj.rfid, 'rfid': obj.rfid,
'functional_tool_name': obj.after_assembly_functional_tool_name, 'functional_tool_name': obj.after_assembly_functional_tool_name,
'tool_groups_id': obj.tool_groups_id.id 'tool_groups_id': obj.after_tool_groups_id.id
}) })
# 将刀具组装入库单的状态更改为就绪 # 将刀具组装入库单的状态更改为就绪
picking_id.action_confirm() picking_id.action_confirm()
@@ -764,6 +793,32 @@ class ProductProduct(models.Model):
# 创建功能刀具该批次/序列号 库存移动和移动历史 # 创建功能刀具该批次/序列号 库存移动和移动历史
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装', False) tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装', False)
def material_stock_moves(self, shelf_location_barcode):
# 创建库存移动记录
stock_move_id = self.env['stock.move'].sudo().create({
'name': '功能刀具组装',
'product_id': self.id,
'location_id': self.env['stock.location'].search([('name', '=', '刀具房')]).id,
'location_dest_id': self.env['stock.location'].search([('name', '=', '刀具组装位置')]).id,
'product_uom_qty': 1.00,
'state': 'done'
})
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)])
# 创建移动历史记录
stock_move_line_id = self.env['stock.move.line'].sudo().create({
'product_id': self.id,
'move_id': stock_move_id.id,
'current_location_id': location.id,
'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0,
'state': 'done',
})
location.product_num = location.product_num - 1
return stock_move_id, stock_move_line_id
class StockLot(models.Model): class StockLot(models.Model):
_inherit = 'stock.lot' _inherit = 'stock.lot'
@@ -798,7 +853,7 @@ class StockLot(models.Model):
'code': '' if not obj else obj.tool_code, 'code': '' if not obj else obj.tool_code,
'rfid': '' if not obj else obj.rfid, 'rfid': '' if not obj else obj.rfid,
'functional_tool_name': '' if not obj else obj.after_assembly_functional_tool_name, 'functional_tool_name': '' if not obj else obj.after_assembly_functional_tool_name,
'tool_groups_id': False if not obj else obj.tool_groups_id.id 'tool_groups_id': False if not obj else obj.after_tool_groups_id.id
}) })
return stock_move_id, stock_move_line_id return stock_move_id, stock_move_line_id

View File

@@ -200,6 +200,31 @@
</group> </group>
<group string="组装物料信息" col="1"> <group string="组装物料信息" col="1">
<field name="_barcode_scanned" widget="barcode_handler"/> <field name="_barcode_scanned" widget="barcode_handler"/>
<group col="1">
<div>
<separator string="刀柄:" style="font-size: 13px;"/>
</div>
<group>
<group>
<field name="handle_code_id" string="序列号" placeholder="请选择"
class="custom_required"
options="{'no_create': True, 'no_quick_create': True}"/>
</group>
<group>
<field name="handle_freight_rfid" string="Rfid"/>
</group>
</group>
<group col="2">
<group>
<field name="handle_product_id" string="名称"/>
<field name="handle_specification_id" string="规格"/>
</group>
<group>
<field name="cutting_tool_cutterhandle_model_id" string="型号"/>
<field name="sf_tool_brand_id_5" string="品牌"/>
</group>
</group>
</group>
<group col="1" <group col="1"
attrs="{'invisible': ['|','|',('blade_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}"> attrs="{'invisible': ['|','|',('blade_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}">
<div> <div>
@@ -263,7 +288,7 @@
</group> </group>
</group> </group>
<group col="1" <group col="1"
attrs="{'invisible': ['|',('bar_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False)]}"> attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False)]}">
<div> <div>
<separator string="刀盘:" style="font-size: 13px;"/> <separator string="刀盘:" style="font-size: 13px;"/>
</div> </div>
@@ -283,28 +308,6 @@
</group> </group>
</group> </group>
</group> </group>
<group col="1">
<div>
<separator string="刀柄:" style="font-size: 13px;"/>
</div>
<group>
<group>
<field name="handle_code_id" string="序列号" placeholder="请选择"
class="custom_required"
options="{'no_create': True, 'no_quick_create': True}"/>
</group>
</group>
<group col="2">
<group>
<field name="handle_product_id" string="名称"/>
<field name="handle_specification_id" string="规格"/>
</group>
<group>
<field name="cutting_tool_cutterhandle_model_id" string="型号"/>
<field name="sf_tool_brand_id_5" string="品牌"/>
</group>
</group>
</group>
<group col="1"> <group col="1">
<div> <div>
<separator string="夹头:" style="font-size: 13px;"/> <separator string="夹头:" style="font-size: 13px;"/>
@@ -329,37 +332,46 @@
<group string="组装参数信息"> <group string="组装参数信息">
<group> <group>
<field name="barcode_id" invisible="True"/> <group>
<field name="tool_code" readonly="True"/> <field name="barcode_id" invisible="True"/>
<field name="rfid" placeholder="请输入rfid码" class="custom_required"/> <field name="tool_code" readonly="True"/>
<field name="after_name_id" string="功能刀具名称"/> <field name="rfid" class="custom_required"/>
<field name="after_assembly_functional_tool_name" string="功能刀具名称" invisible="1"/> <field name="after_name_id" string="功能刀具名称" placeholder="请选择功能刀具名称"
<field name="after_assembly_functional_tool_type_id" string="功能刀具类型" options="{'no_create': True, 'no_quick_create': True}"/>
options="{'no_create': True, 'no_quick_create': True}"/> <field name="after_assembly_functional_tool_name" string="功能刀具名称" invisible="1"/>
<field name="tool_groups_id"/> <field name="after_assembly_functional_tool_type_id" string="功能刀具类型"
<field name="after_assembly_functional_tool_diameter" string="刀具直径(mm)" options="{'no_create': True, 'no_quick_create': True}"/>
class="custom_required"/> <field name="after_tool_groups_id"
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)" options="{'no_create': True, 'no_quick_create': True}"/>
class="custom_required"/> <field name="after_assembly_functional_tool_diameter" string="刀具直径(mm)"
<field name="after_assembly_new_former" string="新/旧"/> class="custom_required"/>
<field name="cut_time" attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/> <field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"
<field name="cut_length" attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/> class="custom_required"/>
<field name="cut_number" attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/> <field name="after_assembly_new_former" string="新/旧"/>
<field name="cut_time" attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
<field name="cut_length"
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
<field name="cut_number"
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
</group>
</group> </group>
<group> <group>
<field name="after_assembly_whether_standard_knife" string="是否标准刀"/> <group>
<field name="after_assembly_coarse_middle_thin" string="粗/中/精"/> <field name="after_assembly_whether_standard_knife" string="是否标准刀"/>
<field name="after_assembly_max_lifetime_value" string="最大寿命值(min)" <field name="after_assembly_coarse_middle_thin" string="粗/中/精"/>
class="custom_required"/> <field name="after_assembly_max_lifetime_value" string="最大寿命值(min)"
<field name="after_assembly_alarm_value" string="报警值(min)" class="custom_required"/> class="custom_required"/>
<field name="after_assembly_used_value" string="已使用值(min)"/> <field name="after_assembly_alarm_value" string="报警值(min)" class="custom_required"/>
<field name="after_assembly_tool_loading_length" string="总长度(mm)" <field name="after_assembly_used_value" string="已使用值(min)"/>
class="custom_required"/> <field name="after_assembly_tool_loading_length" string="总长度(mm)"
<field name="after_assembly_functional_tool_length" string="伸出长(mm)" class="custom_required"/>
class="custom_required"/> <field name="after_assembly_functional_tool_length" string="伸出长(mm)"
<field name="after_assembly_effective_length" string="有效长(mm)" class="custom_required"/> class="custom_required"/>
<field name="hiding_length" class="custom_required"/> <field name="after_assembly_effective_length" string="有效长(mm)"
<field name="L_D_number"/> class="custom_required"/>
<field name="hiding_length" class="custom_required"/>
<field name="L_D_number"/>
</group>
</group> </group>
</group> </group>
</sheet> </sheet>

View File

@@ -1,2 +1,3 @@
# -*-coding:utf-8-*- # -*-coding:utf-8-*-
from . import models from . import models
from . import wizard

View File

@@ -15,6 +15,7 @@
'data/ir_cron_data.xml', 'data/ir_cron_data.xml',
'security/sf_stock_security.xml', 'security/sf_stock_security.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'wizard/wizard_view.xml',
'views/view.xml', 'views/view.xml',
'views/shelf_location.xml', 'views/shelf_location.xml',
'views/change_stock_move_views.xml', 'views/change_stock_move_views.xml',

View File

@@ -191,6 +191,7 @@ class SfLocation(models.Model):
# return res # return res
# 生成货位 # 生成货位
def create_location(self): def create_location(self):
""" """
当仓库类型为货架时,自动生成其下面的货位,数量为货架层数*层数容量 当仓库类型为货架时,自动生成其下面的货位,数量为货架层数*层数容量
@@ -222,11 +223,14 @@ class SfLocation(models.Model):
class SfShelf(models.Model): class SfShelf(models.Model):
_name = 'sf.shelf' _name = 'sf.shelf'
_inherit = ['printing.utils']
_description = '货架' _description = '货架'
_order = 'create_date desc' _order = 'create_date desc'
name = fields.Char('货架名称', required=True, size=20) name = fields.Char('货架名称', required=True, size=20)
active = fields.Boolean("有效", default=True)
barcode = fields.Char('编码', copy=False, size=15, required=True) barcode = fields.Char('编码', copy=False, size=15, required=True)
# 货位 # 货位
location_ids = fields.One2many('sf.shelf.location', 'shelf_id', string='货位') location_ids = fields.One2many('sf.shelf.location', 'shelf_id', string='货位')
@@ -300,10 +304,40 @@ class SfShelf(models.Model):
j_str = str(j + 1).zfill(3) # 确保是两位数如果不足两位左侧补0 j_str = str(j + 1).zfill(3) # 确保是两位数如果不足两位左侧补0
return area_type_barcode + self.channel + self.direction + '-' + self.barcode + '-' + i_str + '-' + j_str return area_type_barcode + self.channel + self.direction + '-' + self.barcode + '-' + i_str + '-' + j_str
def print_all_location_barcode(self):
"""
打印所有货位编码
"""
print('=======打印货架所有货位编码=========')
for record in self.location_ids:
print('record', record)
if not record.barcode:
continue
record.ensure_one()
# qr_code_data = record.lot_qr_code
# if not qr_code_data:
# raise UserError("没有找到二维码数据。")
barcode = record.barcode
# todo 待控制
if not barcode:
raise ValidationError("请先分配序列号")
# host = "192.168.50.110" # 可以根据实际情况修改
# port = 9100 # 可以根据实际情况修改
# 获取默认打印机配置
printer_config = self.env['printer.configuration'].sudo().search([('model', '=', self._name)], limit=1)
if not printer_config:
raise UserError('请先配置打印机')
host = printer_config.printer_id.ip_address
port = printer_config.printer_id.port
self.print_qr_code(barcode, host, port)
class ShelfLocation(models.Model): class ShelfLocation(models.Model):
_name = 'sf.shelf.location' _name = 'sf.shelf.location'
_inherit = ['printing.utils']
_description = '货位' _description = '货位'
_rec_name = 'barcode'
_order = 'id asc, create_date asc' _order = 'id asc, create_date asc'
# current_location_id = fields.Many2one('sf.shelf.location', string='当前位置') # current_location_id = fields.Many2one('sf.shelf.location', string='当前位置')
@@ -313,6 +347,7 @@ class ShelfLocation(models.Model):
destination_move_ids = fields.One2many('stock.move.line', 'destination_location_id', '目标位置调拨单') destination_move_ids = fields.One2many('stock.move.line', 'destination_location_id', '目标位置调拨单')
storage_time = fields.Datetime('入库时间', compute='_compute_location_status') storage_time = fields.Datetime('入库时间', compute='_compute_location_status')
production_id = fields.Many2one('mrp.production', string='制造订单') production_id = fields.Many2one('mrp.production', string='制造订单')
active = fields.Boolean("有效", default=True)
@api.depends('location_status') @api.depends('location_status')
def _compute_location_status(self): def _compute_location_status(self):
@@ -326,6 +361,8 @@ class ShelfLocation(models.Model):
name = fields.Char('货位名称', required=True, size=20) name = fields.Char('货位名称', required=True, size=20)
barcode = fields.Char('货位编码', copy=False, size=50) barcode = fields.Char('货位编码', copy=False, size=50)
qr_code = fields.Binary(string='二维码', compute='_compute_location_qr_code', store=True)
# 货架 # 货架
shelf_id = fields.Many2one('sf.shelf', string='货架') shelf_id = fields.Many2one('sf.shelf', string='货架')
@@ -337,6 +374,62 @@ class ShelfLocation(models.Model):
def action_check(self): def action_check(self):
self.check_state = 'enable' self.check_state = 'enable'
@api.depends('barcode')
def _compute_location_qr_code(self):
for record in self:
if record.barcode:
# 创建一个QRCode对象
qr = qrcode.QRCode(
version=1, # 设置版本, 1-40控制二维码的大小
error_correction=qrcode.constants.ERROR_CORRECT_L, # 设置错误校正等级
box_size=10, # 设置每个格子的像素大小
border=4, # 设置边框的格子宽度
)
# 添加数据
qr.add_data(record.barcode)
qr.make(fit=True)
# 创建二维码图像
img = qr.make_image(fill_color="black", back_color="white")
# 创建一个内存文件
buffer = io.BytesIO()
img.save(buffer, format="PNG") # 将图像保存到内存文件中
# 获取二进制数据
binary_data = buffer.getvalue()
# 使用Base64编码这些二进制数据
data = base64.b64encode(binary_data)
self.qr_code = data
else:
record.qr_code = False
def print_single_location_qr_code(self):
self.ensure_one()
qr_code_data = self.qr_code
if not qr_code_data:
raise UserError("没有找到二维码数据。")
barcode = self.barcode
# host = "192.168.50.110" # 可以根据实际情况修改
# port = 9100 # 可以根据实际情况修改
# 获取默认打印机配置
printer_config = self.env['printer.configuration'].sudo().search([('model', '=', self._name)], limit=1)
if not printer_config:
raise UserError('请先配置打印机')
host = printer_config.printer_id.ip_address
port = printer_config.printer_id.port
self.print_qr_code(barcode, host, port)
# 获取当前wizard的视图ID或其他标识信息
view_id = self.env.context.get('view_id')
# 构造返回wizard页面的action字典
action = {
'type': 'ir.actions.act_window',
'name': '返回 Wizard',
'res_model': 'sf.shelf', # 替换为你的wizard模型名称
'view_mode': 'form',
'view_id': view_id, # 如果需要基于特定的视图返回
'target': 'new', # 如果需要在新的窗口或标签页打开
'res_id': self.shelf_id, # 如果你想要返回当前记录的视图
}
return action
# # 仓库类别selection库区、库位、货位 # # 仓库类别selection库区、库位、货位
# location_type = fields.Selection([ # location_type = fields.Selection([
# ('货架', '货架'), # ('货架', '货架'),
@@ -423,6 +516,19 @@ class ShelfLocation(models.Model):
else: else:
raise UserError("该库位无产品") raise UserError("该库位无产品")
@api.model_create_multi
def create(self, vals_list):
# 编码重复校验
barcode_list = []
for val in vals_list:
location = self.search([('barcode', '=', val['barcode'])])
if location:
barcode_list.append(val['name'])
if barcode_list:
raise UserError("货位编码【%s】存在重复" % barcode_list)
records = super(ShelfLocation, self).create(vals_list)
return records
class Sf_stock_move_line(models.Model): class Sf_stock_move_line(models.Model):
_name = 'stock.move.line' _name = 'stock.move.line'
@@ -438,7 +544,13 @@ class Sf_stock_move_line(models.Model):
current_product_id = fields.Integer(compute='_compute_location_dest_id_value', store=True) current_product_id = fields.Integer(compute='_compute_location_dest_id_value', store=True)
there_is_no_sn = fields.Boolean('是否有序列号', default=False) there_is_no_sn = fields.Boolean('是否有序列号', default=False)
rfid = fields.Char('Rfid', readonly=True) rfid = fields.Char('Rfid')
rfid_barcode = fields.Char('Rfid', compute='_compute_rfid')
@api.depends('lot_id')
def _compute_rfid(self):
for item in self:
item.rfid_barcode = item.lot_id.rfid
def action_revert_inventory(self): def action_revert_inventory(self):
# 检查用户是否有执行操作的权限 # 检查用户是否有执行操作的权限
@@ -446,7 +558,7 @@ class Sf_stock_move_line(models.Model):
raise UserError(_('抱歉,只有库管人员可以执行此动作')) raise UserError(_('抱歉,只有库管人员可以执行此动作'))
# 如果用户有权限,调用父类方法 # 如果用户有权限,调用父类方法
return super(CustomStockMoveLine, self).action_revert_inventory() return super().action_revert_inventory()
@api.depends('lot_name') @api.depends('lot_name')
def _compute_lot_qr_code(self): def _compute_lot_qr_code(self):
@@ -713,35 +825,39 @@ class Sf_stock_move_line(models.Model):
destination_location_id = fields.Many2one( destination_location_id = fields.Many2one(
'sf.shelf.location', string='目标货位') 'sf.shelf.location', string='目标货位')
@api.onchange('destination_location_id') def compute_destination_location_id(self):
def _compute_destination_location_id(self):
for record in self: for record in self:
obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)])
if record.lot_id: if record.lot_id:
shelf_location_obj = self.env['sf.shelf.location'].search( shelf_location_obj = self.env['sf.shelf.location'].search(
[('product_sn_id', '=', record.lot_id.id)]) [('product_sn_id', '=', record.lot_id.id)])
if shelf_location_obj: if shelf_location_obj:
shelf_location_obj.product_sn_id = False shelf_location_obj.product_sn_id = False
# obj = self.env['sf.shelf.location'].search([('location_id', '=',
# self.destination_location_id.id)])
obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)])
if obj: if obj:
obj.product_sn_id = record.lot_id.id obj.product_sn_id = record.lot_id.id
else:
pass
else: else:
obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)])
if obj: if obj:
obj.product_sn_id = record.lot_id.id obj.product_sn_id = record.lot_id.id
else: else:
obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)])
if obj: if obj:
obj.product_id = record.product_id.id obj.product_id = record.product_id.id
# obj.location_status = '占用' # obj.location_status = '占用'
obj.product_num += record.reserved_uom_qty obj.product_num += record.reserved_uom_qty
@api.onchange('destination_location_id')
def _check_destination_location_id(self):
for item in self:
if item:
i = 0
barcode = item.destination_location_id.barcode
for line in item.picking_id.move_line_ids_without_package:
if barcode and barcode == line.destination_location_id.barcode:
i += 1
if i > 1:
raise ValidationError(
'%s】货位已经被占用,请重新选择!!!' % item.destination_location_id.barcode)
class SfStockPicking(models.Model): class SfStockPicking(models.Model):
_inherit = 'stock.picking' _inherit = 'stock.picking'
@@ -764,12 +880,15 @@ class SfStockPicking(models.Model):
res = super(SfStockPicking, self).button_validate() res = super(SfStockPicking, self).button_validate()
for line in self.move_line_ids: for line in self.move_line_ids:
if line: if line:
# 调用入库方法进行入库
line.compute_destination_location_id()
if line.current_location_id: if line.current_location_id:
if line.current_location_id.product_sn_id: if line.current_location_id.product_sn_id:
line.current_location_id.product_sn_id = False line.current_location_id.product_sn_id = False
# line.current_location_id.location_status = '空闲' # line.current_location_id.location_status = '空闲'
line.current_location_id.product_num = 0 line.current_location_id.product_num = 0
# 对入库作业的刀柄和托盘进行Rfid绑定校验
for move in self.move_ids: for move in self.move_ids:
if move and move.product_id.cutting_tool_material_id.name == '刀柄' or '托盘' in ( if move and move.product_id.cutting_tool_material_id.name == '刀柄' or '托盘' in (
move.product_id.fixture_material_id.name or ''): move.product_id.fixture_material_id.name or ''):
@@ -859,15 +978,27 @@ class SfProcurementGroup(models.Model):
return res return res
# class SfPickingType(models.Model):
# _inherit = 'stock.picking.type'
#
# def _default_show_operations(self):
# return self.user_has_groups('stock.group_production_lot,'
# 'stock.group_stock_multi_locations,'
# 'stock.group_tracking_lot',
# 'sf_warehouse.group_sf_stock_user',
# 'sf_warehouse.group_sf_stock_manager')
class SfPickingType(models.Model): class SfPickingType(models.Model):
_inherit = 'stock.picking.type' _inherit = 'stock.picking.type'
def _default_show_operations(self): def _default_show_operations(self):
return self.user_has_groups('stock.group_production_lot,' return self.user_has_groups(
'stock.group_stock_multi_locations,' 'stock.group_production_lot,'
'stock.group_tracking_lot', 'stock.group_stock_multi_locations,'
'sf_warehouse.group_sf_stock_user', 'stock.group_tracking_lot,'
'sf_warehouse.group_sf_stock_manager') 'sf_warehouse.group_sf_stock_user,'
'sf_warehouse.group_sf_stock_manager'
)
class CustomStockMove(models.Model): class CustomStockMove(models.Model):

View File

@@ -132,6 +132,9 @@ access_sf_cutting_tool_material_group_sf_stock_manager,sf_cutting_tool_material_
access_sf_cutting_tool_standard_library_group_sf_stock_manager,sf_cutting_tool_standard_library_group_sf_stock_manager,sf_base.model_sf_cutting_tool_standard_library,sf_warehouse.group_sf_stock_manager,1,0,1,0 access_sf_cutting_tool_standard_library_group_sf_stock_manager,sf_cutting_tool_standard_library_group_sf_stock_manager,sf_base.model_sf_cutting_tool_standard_library,sf_warehouse.group_sf_stock_manager,1,0,1,0
access_sf_tool_materials_basic_parameters_group_sf_stock_manager,sf_tool_materials_basic_parameters_group_sf_stock_manager,sf_base.model_sf_tool_materials_basic_parameters,sf_warehouse.group_sf_stock_manager,1,0,1,0 access_sf_tool_materials_basic_parameters_group_sf_stock_manager,sf_tool_materials_basic_parameters_group_sf_stock_manager,sf_base.model_sf_tool_materials_basic_parameters,sf_warehouse.group_sf_stock_manager,1,0,1,0
access_sf_shelf_location_wizard_group_plan_dispatch,sf_shelf_location_wizard_group_plan_dispatch,model_sf_shelf_location_wizard,sf_base.group_plan_dispatch,1,0,0,0
access_sf_shelf_location_wizard_group_sf_stock_user_group_sf_stock_user,sf_shelf_location_wizard_group_sf_stock_user_group_sf_stock_user,model_sf_shelf_location_wizard,sf_warehouse.group_sf_stock_user,1,0,0,0
access_sf_shelf_location_wizard_group_sf_stock_manager,sf_shelf_location_wizard_group_sf_stock_manager,model_sf_shelf_location_wizard,sf_warehouse.group_sf_stock_manager,1,1,1,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
132
133
134
135
136
137
138
139
140

View File

@@ -19,8 +19,8 @@
<!-- ]"/> --> <!-- ]"/> -->
<field name="destination_location_id" domain="[('location_id', '=', location_dest_id_value), '|', <field name="destination_location_id" domain="[('location_id', '=', location_dest_id_value), '|',
('location_status', '=', '空闲'), ('product_id', '=', current_product_id), ('product_sn_id', ('location_status', '=', '空闲'), ('product_id', '=', current_product_id), ('product_sn_id',
'=', there_is_no_sn)]"/> '=', there_is_no_sn)]" options="{'no_create': True,'no_create_edit':True}"/>
<field name="rfid_barcode" string="Rfid"/>
<!-- <field name="location_dest_id_product_type"/> --> <!-- <field name="location_dest_id_product_type"/> -->
<!-- <field name="location_dest_id"/> --> <!-- <field name="location_dest_id"/> -->

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<data> <data>
<!-- 货架视图 --> <!-- 货架视图 -->
<record id="view_sf_shelf" model="ir.ui.view"> <record id="view_sf_shelf" model="ir.ui.view">
<field name="name">Sf Shelf</field> <field name="name">Sf Shelf</field>
<field name="model">sf.shelf</field> <field name="model">sf.shelf</field>
@@ -9,7 +9,8 @@
<form string="Sf Shelf"> <form string="Sf Shelf">
<header> <header>
<field name="is_there_area" invisible="1"/> <field name="is_there_area" invisible="1"/>
<button string="生成货位" name="create_location" type="object" class="oe_highlight" attrs="{'invisible': [('is_there_area', '=', True)]}"/> <button string="生成货位" name="create_location" type="object" class="oe_highlight"
attrs="{'invisible': [('is_there_area', '=', True)]}"/>
</header> </header>
<sheet> <sheet>
<group> <group>
@@ -23,12 +24,21 @@
<field name="shelf_layer" string="货架层数"/> <field name="shelf_layer" string="货架层数"/>
<field name="layer_capacity" string="层数容量"/> <field name="layer_capacity" string="层数容量"/>
</group> </group>
<field name="location_ids" widget="one2many_list"> <notebook>
<tree string="Shelf Location"> <page string="货位">
<field name="barcode" string="编码"/> <button name="print_all_location_barcode" type="object" string="一键打印"
<field name="name" string="名称"/> class="oe_highlight"/>
</tree> <field name="location_ids" widget="one2many_list">
</field> <tree string="Shelf Location">
<field name="barcode" string="编码"/>
<field name="name" string="名称"/>
<field name="qr_code" string="条码" widget="image"/>
<button string="打印" name="print_single_location_qr_code" type="object"
class="oe_highlight"/>
</tree>
</field>
</page>
</notebook>
</sheet> </sheet>
</form> </form>
</field> </field>
@@ -46,23 +56,23 @@
</field> </field>
</record> </record>
<!-- 货架action --> <!-- 货架action -->
<record id="sf_shelf_action" model="ir.actions.act_window"> <record id="sf_shelf_action" model="ir.actions.act_window">
<field name="name">货架</field> <field name="name">货架</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.shelf</field> <field name="res_model">sf.shelf</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<!-- <field name="view_id" ref="view_sf_shelf_tree"/> --> <!-- <field name="view_id" ref="view_sf_shelf_tree"/> -->
</record> </record>
<!-- 货架菜单 --> <!-- 货架菜单 -->
<menuitem <menuitem
id="sf_shelf_menu" id="sf_shelf_menu"
name="货架" name="货架"
parent="stock.menu_warehouse_config" parent="stock.menu_warehouse_config"
sequence="19" sequence="19"
action="sf_shelf_action" action="sf_shelf_action"
groups="sf_warehouse.group_sf_stock_user"/> groups="sf_warehouse.group_sf_stock_user"/>
<record id="view_shelf_location_tree" model="ir.ui.view"> <record id="view_shelf_location_tree" model="ir.ui.view">
@@ -116,13 +126,25 @@
<field name="name">Shelf Location form</field> <field name="name">Shelf Location form</field>
<field name="model">sf.shelf.location</field> <field name="model">sf.shelf.location</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Shelf Location"> <form string="Shelf Location" create="0">
<header> <header>
<button string="货位变更"
name="%(sf_warehouse.sf_shelf_location_wizard_act)d"
type="action"
context="{'default_name':name,
'default_current_name':name,
'default_current_shelf_id':shelf_id,
'default_current_location_id':location_id,
'default_current_barcode':barcode,
'default_current_product_id':product_id,
}"
class="btn-primary"/>
<field name="location_status" invisible="1"/> <field name="location_status" invisible="1"/>
<button string="禁用货位" name="action_location_status_disable" type="object" class="oe_highlight" <button string="禁用货位" name="action_location_status_disable" type="object"
class="oe_highlight"
attrs="{'invisible': [('location_status', '!=', '空闲')]}"/> attrs="{'invisible': [('location_status', '!=', '空闲')]}"/>
<button string="启用货位" name="action_location_status_enable" type="object" class="oe_highlight" <button string="启用货位" name="action_location_status_enable" type="object"
class="oe_highlight"
attrs="{'invisible': [('location_status', '!=', '禁用')]}"/> attrs="{'invisible': [('location_status', '!=', '禁用')]}"/>
</header> </header>
<sheet> <sheet>
@@ -143,11 +165,11 @@
</button> </button>
</div> </div>
<group> <group>
<field name="barcode"/> <field name="barcode" readonly="1"/>
<field name="name"/> <field name="name" readonly="1"/>
<field name="shelf_id"/> <field name="shelf_id" readonly="1"/>
<field name="location_id"/> <field name="location_id" readonly="1"/>
<field name="product_sn_id"/> <field name="product_sn_id" options="{'no_create': True}"/>
<field name="product_id"/> <field name="product_id"/>
<field name="product_num" readonly="1"/> <field name="product_num" readonly="1"/>
<field name="location_status"/> <field name="location_status"/>
@@ -163,20 +185,20 @@
<field name="name">shelf.location.kanban</field> <field name="name">shelf.location.kanban</field>
<field name="model">sf.shelf.location</field> <field name="model">sf.shelf.location</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<kanban class="o_kanban_mobile" js_class="custom_kanban"> <kanban class="o_kanban_mobile" js_class="custom_kanban" create="0">
<templates> <templates>
<t t-name="kanban-box"> <t t-name="kanban-box">
<div t-attf-class="oe_kanban_card oe_kanban_global_click <div t-attf-class="oe_kanban_card oe_kanban_global_click
#{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''} #{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''}
#{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''} #{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''}
#{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}"> #{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}">
<!-- 标题 --> <!-- 标题 -->
<div class="o_kanban_card_header"> <div class="o_kanban_card_header">
<div class="o_kanban_card_header_title"> <div class="o_kanban_card_header_title">
<field name="name"/> <field name="name"/>
</div> </div>
</div> </div>
<!-- 内容 --> <!-- 内容 -->
<div class="o_kanban_record_bottom"> <div class="o_kanban_record_bottom">
<field name="location_status"/> <field name="location_status"/>
</div> </div>
@@ -187,31 +209,31 @@
</div> </div>
</div> </div>
</t> </t>
<!-- <t t-name="kanban-box"> --> <!-- <t t-name="kanban-box"> -->
<!-- <div t-attf-class="oe_kanban_card oe_kanban_global_click --> <!-- <div t-attf-class="oe_kanban_card oe_kanban_global_click -->
<!-- #{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''} --> <!-- #{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''} -->
<!-- #{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''} --> <!-- #{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''} -->
<!-- #{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}"> --> <!-- #{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}"> -->
<!-- 看板内容 --> <!-- 看板内容 -->
<!-- </div> --> <!-- </div> -->
<!-- <div t-attf-class="oe_kanban_card"> --> <!-- <div t-attf-class="oe_kanban_card"> -->
<!-- 标题 --> <!-- 标题 -->
<!-- <div class="o_kanban_card_header"> --> <!-- <div class="o_kanban_card_header"> -->
<!-- <div class="o_kanban_card_header_title"> --> <!-- <div class="o_kanban_card_header_title"> -->
<!-- <field name="name"/> --> <!-- <field name="name"/> -->
<!-- </div> --> <!-- </div> -->
<!-- </div> --> <!-- </div> -->
<!-- 内容 --> <!-- 内容 -->
<!-- <div class="o_kanban_record_bottom"> --> <!-- <div class="o_kanban_record_bottom"> -->
<!-- <field name="location_status"/> --> <!-- <field name="location_status"/> -->
<!-- </div> --> <!-- </div> -->
<!-- <div class="o_kanban_record_bottom"> --> <!-- <div class="o_kanban_record_bottom"> -->
<!-- <field name="product_sn_id"/> --> <!-- <field name="product_sn_id"/> -->
<!-- <span> | </span> --> <!-- <span> | </span> -->
<!-- <field name="product_id"/> --> <!-- <field name="product_id"/> -->
<!-- </div> --> <!-- </div> -->
<!-- </div> --> <!-- </div> -->
<!-- </t> --> <!-- </t> -->
</templates> </templates>
</kanban> </kanban>
</field> </field>
@@ -225,7 +247,7 @@
<search string="货位"> <search string="货位">
<searchpanel class="account_root"> <searchpanel class="account_root">
<!-- <field name="location_type" icon="fa-filter"/> --> <!-- <field name="location_type" icon="fa-filter"/> -->
<!-- <field name="location_id" select="multi" icon="fa-filter"/> --> <!-- <field name="location_id" select="multi" icon="fa-filter"/> -->
<field name="location_id" string="所属库区" icon="fa-filter"/> <field name="location_id" string="所属库区" icon="fa-filter"/>
<field name="shelf_id" string="货架"/> <field name="shelf_id" string="货架"/>
<!-- <field name="location_status" icon="fa-filter"/> --> <!-- <field name="location_status" icon="fa-filter"/> -->
@@ -239,7 +261,7 @@
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.shelf.location</field> <field name="res_model">sf.shelf.location</field>
<field name="view_mode">kanban,form</field> <field name="view_mode">kanban,form</field>
<!-- <field name="domain">[('check_state','=','enable')]</field> --> <!-- <field name="domain">[('check_state','=','enable')]</field> -->
</record> </record>
<!-- <record id="example_action" model="ir.actions.act_window"> --> <!-- <record id="example_action" model="ir.actions.act_window"> -->

View File

@@ -0,0 +1 @@
from . import wizard

View File

@@ -0,0 +1,64 @@
from odoo import fields, models, api
from odoo.exceptions import UserError, ValidationError
class ShelfLocationWizard(models.TransientModel):
_name = 'sf.shelf.location.wizard'
_description = '货位变更'
name = fields.Char('')
current_location_id = fields.Many2one('stock.location', string='所属库区', readonly=True)
current_shelf_id = fields.Many2one('sf.shelf', string='当前货架', readonly=True)
current_barcode = fields.Char('当前货位编码', readonly=True)
current_name = fields.Char('当前货位名称', readonly=True)
current_product_id = fields.Many2one('product.product', string='产品', readonly=True)
destination_shelf_id = fields.Many2one('sf.shelf', string='目标货架', compute='_compute_destination_name')
destination_barcode_id = fields.Many2one('sf.shelf.location', string='目标货位编码', required=True,
domain="")
destination_name = fields.Char('目标货位名称', compute='_compute_destination_name')
def return_domain(self):
val = [('location_status', '=', '空闲')]
if self.current_product_id:
val = ['|', ('location_status', '=', '空闲'), ('product_id', '=', self.current_product_id)]
if self.destination_shelf_id:
val.append(('shelf_id', '=', self.destination_shelf_id))
return "%s" % val
@api.depends('destination_barcode_id')
def _compute_destination_name(self):
if self.destination_barcode_id:
self.destination_name = self.destination_barcode_id.name
self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
else:
self.destination_name = ''
self.destination_shelf_id = False
#
# @api.onchange('destination_barcode_id')
# def _onchange_destination_shelf_id(self):
# if self.destination_barcode_id:
# self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
def confirm_the_change(self):
shelf_location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.current_barcode)])
# 变更货位
if self.destination_barcode_id and shelf_location:
if self.destination_barcode_id.product_id and self.destination_barcode_id.product_id == shelf_location.current_product_id and not self.destination_barcode_id.product_sn_id:
self.destination_barcode_id.product_num += shelf_location.product_num
else:
self.destination_barcode_id.product_sn_id = shelf_location.product_sn_id.id
self.destination_barcode_id.product_id = shelf_location.product_id.id
self.destination_barcode_id.product_num = shelf_location.product_num
shelf_location.product_sn_id = False
shelf_location.product_id = False
shelf_location.product_num = 0
else:
raise ValidationError('目标货位出错,请联系管理员!')
# 关闭弹出窗口
return {'type': 'ir.actions.act_window_close'}

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="sf_shelf_location_wizard_form" model="ir.ui.view">
<field name="name">货位变更</field>
<field name="model">sf.shelf.location.wizard</field>
<field name="arch" type="xml">
<form string="货位变更">
<sheet>
<group>
<group string="初始货位">
<group>
<field name="current_location_id"/>
<field name="current_shelf_id" string="货架"/>
<field name="current_barcode" string="编码"/>
<field name="current_name" string="名称"/>
</group>
</group>
<group string="目标货位">
<group>
<field name="current_location_id"/>
<field name="destination_shelf_id" string="货架" options="{'no_create': True}"
placeholder="请选择目标货架"/>
<field name="destination_barcode_id" string="编码" options="{'no_create': True}"
placeholder="请选择目标货位"
domain="['|', ('location_status', '=', '空闲'), ('product_id', '=', current_product_id)]"/>
<field name="destination_name" string="名称"/>
<field name="current_product_id" invisible="1"/>
</group>
</group>
</group>
</sheet>
<footer>
<button string="确定" name="confirm_the_change" type="object" class="btn-primary"
confirm="是否确认变更货位"/>
<button string="取消" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="sf_shelf_location_wizard_act" model="ir.actions.act_window">
<field name="name">货位变更</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.shelf.location.wizard</field>
<field name="view_mode">form</field>
<field name="view_id" ref="sf_shelf_location_wizard_form"/>
<field name="target">new</field>
</record>
</odoo>