Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/前端样式修改
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
'views/mrp_workcenter_views.xml',
|
||||
'views/mrp_workorder_view.xml',
|
||||
'views/model_type_view.xml',
|
||||
'views/agv_setting_views.xml',
|
||||
'views/sf_maintenance_equipment.xml',
|
||||
|
||||
],
|
||||
|
||||
@@ -431,17 +431,17 @@ class Manufacturing_Connect(http.Controller):
|
||||
if 'DeviceId' in ret:
|
||||
logging.info('DeviceId:%s' % ret['DeviceId'])
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('feeder_station_destination', '=', ret['DeviceId'])])
|
||||
[('feeder_station_start_id.name', '=', ret['DeviceId']),
|
||||
('status', '=', '已配送'), ('type', '=', '上产线')], order='id asc')
|
||||
if workpiece_delivery:
|
||||
for wd in workpiece_delivery:
|
||||
logging.info('wd.workorder_id:%s' % wd.workorder_id.name)
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '待上产线':
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||
wd.production_id.write({'production_line_state': '已上产线'})
|
||||
wd.write({'production_line_state': '已上产线'})
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
|
||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的已配送工件数据'}
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传DeviceId字段'}
|
||||
except Exception as e:
|
||||
@@ -466,26 +466,16 @@ class Manufacturing_Connect(http.Controller):
|
||||
if 'DeviceId' in ret:
|
||||
logging.info('DeviceId:%s' % ret['DeviceId'])
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('feeder_station_destination', '=', ret['DeviceId'])])
|
||||
[('feeder_station_start_id.name', '=', ret['DeviceId']),
|
||||
('status', '=', '已配送'), ('type', '=', '下产线')], order='id asc')
|
||||
if workpiece_delivery:
|
||||
for wd in workpiece_delivery:
|
||||
logging.info('wd.workorder_id:%s' % wd.workorder_id.name)
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||
workpiece_delivery_off=request.env['sf.workpiece.delivery'].create({
|
||||
'production_id': wd.production_id.id,
|
||||
'feeder_station_start': ret['DeviceId'],
|
||||
'feeder_station_destination': '',
|
||||
'workorder_id': workpiece_delivery.workorder_id,
|
||||
'workpiece_code': workpiece_delivery.workpiece_code,
|
||||
'production_line_id': workpiece_delivery.production_line_id,
|
||||
'task_delivery_time': datetime.now(),
|
||||
'production_line_state': '已下产线'
|
||||
})
|
||||
wd.production_id.write({'production_line_state': '已下产线'})
|
||||
logging.info('开始向agv下发下产线任务')
|
||||
workpiece_delivery_off._delivery_avg()
|
||||
wd._delivery_avg()
|
||||
logging.info('agv下发下产线任务已配送')
|
||||
|
||||
else:
|
||||
|
||||
@@ -25,9 +25,14 @@ class Workpiece(http.Controller):
|
||||
if 'method' in ret:
|
||||
if ret['method'] == 'end':
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('production_id.name', '=', ret['reqCode'])])
|
||||
[('production_id.name', '=', ret['reqCode']), ('agv_task_code'), '=', ret['taskCode']])
|
||||
if workpiece_delivery:
|
||||
workpiece_delivery.write({'status': '已配送', 'task_completion_time': ret['reqTime']})
|
||||
if workpiece_delivery.type == '下产线':
|
||||
workpiece_delivery_clear = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('production_id.name', '=', ret['reqCode']), ('type', '=', '运送空料架')])
|
||||
if workpiece_delivery_clear:
|
||||
workpiece_delivery_clear._delivery_avg()
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该reqCode暂未查到对应的工件配送记录'}
|
||||
else:
|
||||
|
||||
@@ -8,3 +8,4 @@ from . import mrp_routing_workcenter
|
||||
from . import stock
|
||||
from . import res_user
|
||||
from . import production_line_base
|
||||
from . import agv_setting
|
||||
|
||||
54
sf_manufacturing/models/agv_setting.py
Normal file
54
sf_manufacturing/models/agv_setting.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import requests
|
||||
import logging
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AgvSetting(models.Model):
|
||||
_name = 'sf.agv.site'
|
||||
_description = 'agv站点'
|
||||
|
||||
number = fields.Integer('序号')
|
||||
name = fields.Char('位置编号')
|
||||
owning_region = fields.Char('所属区域')
|
||||
state = fields.Selection([
|
||||
('占用', '占用'),
|
||||
('空闲', '空闲')], string='状态')
|
||||
divide_the_work = fields.Char('主要分工')
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
def update_site_state(self):
|
||||
# 调取中控的接驳站接口并修改对应站点的状态
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
|
||||
headers = {'Authorization': config['center_control_Authorization']}
|
||||
center_control_url = config['center_control_url'] + "/AutoDeviceApi/GetAgvStationState"
|
||||
center_control_r = requests.get(center_control_url, params={}, headers=headers)
|
||||
ret = center_control_r.json()
|
||||
logging.info('工件配送-请求中控站点信息:%s' % ret)
|
||||
datas = ret['Datas']
|
||||
for item in self:
|
||||
for da in datas:
|
||||
if da['DeviceId'] == item.name:
|
||||
if da['AtHome'] is True:
|
||||
item.state = '占用'
|
||||
|
||||
|
||||
class AgvTaskRoute(models.Model):
|
||||
_name = 'sf.agv.task.route'
|
||||
_description = 'agv任务路线'
|
||||
|
||||
name = fields.Char('名称')
|
||||
type = fields.Selection([
|
||||
('F01', '搬运'), ], string='类型', default="F01")
|
||||
start_site_id = fields.Many2one('sf.agv.site', '起点接驳站位置编号')
|
||||
end_site_id = fields.Many2one('sf.agv.site', '终点接驳站位置编号')
|
||||
destination_production_line_id = fields.Many2one('sf.production.line', '目的生产线')
|
||||
priority = fields.Selection([
|
||||
('0', '正常'),
|
||||
('1', '低'),
|
||||
('2', '中'),
|
||||
('3', '高'),
|
||||
('4', '紧急'),
|
||||
], string='优先级', default='0')
|
||||
active = fields.Boolean('有效', default=True)
|
||||
@@ -135,7 +135,8 @@ class MrpProduction(models.Model):
|
||||
# cnc程序获取
|
||||
def fetchCNC(self):
|
||||
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
|
||||
quick_order = self.env['quick.easy.order'].search([('id', '=', cnc.product_id.id)])
|
||||
quick_order = self.env['quick.easy.order'].search(
|
||||
[('name', '=', cnc.product_id.default_code.rsplit('-', 1)[0])])
|
||||
programme_way = False
|
||||
if cnc.manual_quotation is True:
|
||||
programme_way = 'manual operation'
|
||||
@@ -157,7 +158,6 @@ class MrpProduction(models.Model):
|
||||
'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,
|
||||
'order_no': cnc.origin,
|
||||
'quick_order_no': quick_order.name if quick_order else False,
|
||||
'model_order_no': cnc.product_id.default_code,
|
||||
'user': cnc.env.user.name,
|
||||
'programme_way': programme_way,
|
||||
|
||||
@@ -106,7 +106,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工程序")
|
||||
cmm_ids = fields.One2many("sf.cmm.program", 'workorder_id', string="CMM程序")
|
||||
tray_code = fields.Char(string="托盘编码")
|
||||
glb_file = fields.Binary("glb模型文件")
|
||||
glb_file = fields.Binary("glb模型文件", related='production_id.model_file')
|
||||
is_subcontract = fields.Boolean(string='是否外协')
|
||||
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
||||
picking_in_id = fields.Many2one('stock.picking', string='外协入库单')
|
||||
@@ -397,8 +397,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
def button_workpiece_delivery(self):
|
||||
if self.routing_type == '装夹预调':
|
||||
for item in self.workpiece_delivery_ids:
|
||||
if not item.feeder_station_start:
|
||||
raise UserError('【工件配送】明细中请输入起点接驳站')
|
||||
if not item.route_id:
|
||||
raise UserError('【工件配送】明细中请选择【任务路线】')
|
||||
# if not item.workpiece_code:
|
||||
# raise UserError('请对【同运工件】进行扫描')
|
||||
else:
|
||||
@@ -458,12 +458,18 @@ class ResMrpWorkOrder(models.Model):
|
||||
'date_planned_finished': False,
|
||||
'duration_expected': duration_expected,
|
||||
'duration': 0,
|
||||
'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self.env[
|
||||
'sf.workpiece.delivery'].create(
|
||||
{'production_id': production.id})
|
||||
'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list(
|
||||
production)
|
||||
}]
|
||||
return workorders_values_str
|
||||
|
||||
def _json_workpiece_delivery_list(self, production):
|
||||
return [
|
||||
[0, '', {'production_id': production.id, 'type': '上产线'}],
|
||||
[0, '', {'production_id': production.id, 'type': '下产线'}],
|
||||
[0, '', {'production_id': production.id, 'type': '运送空料架'}],
|
||||
]
|
||||
|
||||
# 拼接工单对象属性值(表面工艺)
|
||||
def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id):
|
||||
workorders_values_str = [0, '', {
|
||||
@@ -652,47 +658,6 @@ class ResMrpWorkOrder(models.Model):
|
||||
else:
|
||||
self.results = '合格'
|
||||
|
||||
# cnc程序获取
|
||||
def fetchCNC(self):
|
||||
try:
|
||||
cnc = self.env['mrp.workorder'].search(
|
||||
[('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1)
|
||||
res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code,
|
||||
'production_no': self.production_id.name,
|
||||
'machine_tool_code': cnc.workcenter_id.equipment_id.code,
|
||||
'material_code': cnc.env['sf.production.materials'].search(
|
||||
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
|
||||
'material_type_code': cnc.env['sf.materials.model'].search(
|
||||
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
|
||||
'machining_processing_panel': cnc.product_id.model_processing_panel,
|
||||
'machining_precision': cnc.product_id.model_machining_precision,
|
||||
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
|
||||
'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,
|
||||
'order_no': cnc.production_id.origin,
|
||||
'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0],
|
||||
'user': self.env.user.name,
|
||||
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
|
||||
cnc.product_id.model_file).decode('utf-8')
|
||||
}
|
||||
logging.info('res:%s' % res)
|
||||
configsettings = self.env['res.config.settings'].get_values()
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
url = '/api/intelligent_programming/create'
|
||||
config_url = configsettings['sf_url'] + url
|
||||
# res_str = json.dumps(res)
|
||||
ret = requests.post(config_url, json={}, data=res, headers=config_header)
|
||||
ret = ret.json()
|
||||
logging.info('fetchCNC-ret:%s' % ret)
|
||||
if ret['status'] == 1:
|
||||
self.write(
|
||||
{'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'})
|
||||
else:
|
||||
raise UserError(ret['message'])
|
||||
except Exception as e:
|
||||
logging.info('fetchCNC error:%s' % e)
|
||||
raise UserError("cnc程序获取编程单失败,请联系管理员")
|
||||
|
||||
def json_workorder_str1(self, k, production, route):
|
||||
workorders_values_str = [0, '', {
|
||||
'product_uom_id': production.product_uom_id.id,
|
||||
@@ -724,6 +689,12 @@ class ResMrpWorkOrder(models.Model):
|
||||
picking_out.write({'state': 'assigned'})
|
||||
if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress':
|
||||
self.move_raw_ids = self.production_id.move_raw_ids
|
||||
self.move_raw_ids[0].write({
|
||||
'materiel_length': self.move_raw_ids[0].product_id.length,
|
||||
'materiel_width': self.move_raw_ids[0].product_id.width,
|
||||
'materiel_height': self.move_raw_ids[0].product_id.height
|
||||
})
|
||||
|
||||
self.ensure_one()
|
||||
if any(not time.date_end for time in self.time_ids.filtered(lambda t: t.user_id.id == self.env.user.id)):
|
||||
return True
|
||||
@@ -937,7 +908,7 @@ class CNCprocessing(models.Model):
|
||||
# 将FTP的nc文件下载到临时目录
|
||||
def download_file_tmp(self, production_no, processing_panel):
|
||||
remotepath = os.path.join('/NC', production_no, 'return', processing_panel)
|
||||
serverdir = os.pat.join('/tmp', production_no, 'return', processing_panel)
|
||||
serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
|
||||
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_resconfig['ftp_password'])
|
||||
@@ -991,7 +962,7 @@ class SfWorkOrderBarcodes(models.Model):
|
||||
# [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)])
|
||||
workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)])
|
||||
if workorder_old:
|
||||
raise UserError('该托盘已绑定工件,请先解除绑定!!!')
|
||||
raise UserError('该托盘已绑定【%s】制造订单,请先解除绑定!!!' % workorder_old.production_id.name)
|
||||
if workorder:
|
||||
if workorder.routing_type == '装夹预调':
|
||||
if workorder.state in ['done']:
|
||||
@@ -1114,10 +1085,13 @@ class WorkPieceDelivery(models.Model):
|
||||
store=True)
|
||||
plan_start_processing_time = fields.Datetime('计划开始加工时间', readonly=True)
|
||||
workpiece_code = fields.Char('同运工件编码')
|
||||
feeder_station_start = fields.Char('起点接驳站')
|
||||
feeder_station_destination = fields.Char('目的接驳站')
|
||||
route_id = fields.Many2one('sf.agv.task.route', '任务路线')
|
||||
feeder_station_start_id = fields.Many2one('sf.agv.site', '起点接驳站')
|
||||
feeder_station_destination_id = fields.Many2one('sf.agv.site', '目的接驳站')
|
||||
task_delivery_time = fields.Datetime('任务下发时间')
|
||||
task_completion_time = fields.Datetime('任务完成时间')
|
||||
type = fields.Selection(
|
||||
[('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型')
|
||||
delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration')
|
||||
status = fields.Selection(
|
||||
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态',
|
||||
@@ -1127,41 +1101,52 @@ class WorkPieceDelivery(models.Model):
|
||||
string='上/下产线', default='待上产线')
|
||||
cnc_program_down_state = fields.Selection([('待下发', '待下发'), ('已下发', '已下发')],
|
||||
string='CNC程序下发状态', default='待下发')
|
||||
agv_task_code = fields.Char('agv任务单号')
|
||||
|
||||
@api.onchange('route_id')
|
||||
def onchage_route(self):
|
||||
if self.route_id:
|
||||
self.feeder_station_start_id = self.route_id.start_site_id
|
||||
self.feeder_station_destination_id = self.route_id.end_site_id
|
||||
|
||||
# 工件配送
|
||||
def button_delivery(self):
|
||||
if self.cnc_program_down_state == '待下发':
|
||||
if self.status == '待下发':
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_delivery_id': self.id,
|
||||
}}
|
||||
if self.route_id:
|
||||
if self.status == '待下发':
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_delivery_id': self.id,
|
||||
}}
|
||||
else:
|
||||
raise UserError('状态为【待下发】的工件记录可进行配送')
|
||||
else:
|
||||
raise UserError('状态为【待下发】的工件记录可进行配送')
|
||||
raise UserError('请选择任务路线再进行配送')
|
||||
else:
|
||||
raise UserError(_("该制造订单还未下发CNC程序单,无法进行工件配送"))
|
||||
|
||||
# 配送至avg小车
|
||||
def _delivery_avg(self):
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
site_production_line = False
|
||||
if self.production_line_state == '待上产线':
|
||||
site_production_line = [('production_line_status', '=', '已上产线')]
|
||||
elif self.production_line_state == '已下产线':
|
||||
site_production_line = [('production_line_status', '=', '已下产线')]
|
||||
agv_site = self.env['res.agv.site'].search(site_production_line, order="number asc")
|
||||
positionCode_Arr = []
|
||||
agv_site = self.env['sf.agv.site'].search([])
|
||||
if agv_site:
|
||||
for item in agv_site:
|
||||
positionCode_Arr.append({
|
||||
'positionCode': item.content,
|
||||
'code': item.type
|
||||
})
|
||||
agv_site.update_site_state()
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
positionCode_Arr = []
|
||||
if self.feeder_station_start_id:
|
||||
positionCode_Arr.append({
|
||||
'positionCode': self.feeder_station_start_id.name,
|
||||
'code': '00'
|
||||
})
|
||||
if self.feeder_station_destination_id:
|
||||
positionCode_Arr.append({
|
||||
'positionCode': self.feeder_station_destination_id.name,
|
||||
'code': '00'
|
||||
})
|
||||
res = {'reqCode': self.production_id.name, 'reqTime': '', 'clientCode': '', 'tokenCode': '',
|
||||
'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': config['wbcode'],
|
||||
'positionCodePath': positionCode_Arr,
|
||||
@@ -1169,17 +1154,17 @@ class WorkPieceDelivery(models.Model):
|
||||
'podDir': '', 'materialLot': '', 'priority': '', 'taskCode': '', 'agvCode': '', 'materialLot': '',
|
||||
'data': ''}
|
||||
try:
|
||||
config['agv_rcs_url'] = 'http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask'
|
||||
# config['agv_rcs_url'] = 'http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask'
|
||||
logging.info('AGV请求路径:%s' % config['agv_rcs_url'])
|
||||
logging.info('AGV-json:%s' % res)
|
||||
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
ret = requests.post((config['agv_rcs_url']), json=res, headers=headers)
|
||||
ret = ret.json()
|
||||
logging.info('config-ret:%s' % ret)
|
||||
if ret['code'] == 0:
|
||||
if self.production_id.name == ret['reqCode']:
|
||||
self.write({'task_delivery_time': fields.Datetime.now(), 'status': '待配送'})
|
||||
self.write(
|
||||
{'task_delivery_time': fields.Datetime.now(), 'status': '待配送', 'agv_task_code': ret['data']})
|
||||
else:
|
||||
raise UserError(ret['message'])
|
||||
except Exception as e:
|
||||
|
||||
BIN
sf_manufacturing/security/img.png
Normal file
BIN
sf_manufacturing/security/img.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -129,4 +129,7 @@ access_sf_cmm_program_group_plan_dispatch,sf_cmm_program_group_plan_dispatch,mod
|
||||
access_mrp_workcenter_productivity,mrp.workcenter.productivity,mrp.model_mrp_workcenter_productivity,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_maintenance_equipment_tool_group_plan_dispatch,maintenance.equipment.tool,sf_manufacturing.model_maintenance_equipment_tool,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_workpiece_delivery_group_plan_dispatch,sf.workpiece.delivery,sf_manufacturing.model_sf_workpiece_delivery,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_workpiece_delivery_group_plan_dispatch,sf.workpiece.delivery,sf_manufacturing.model_sf_workpiece_delivery,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_agv_site_group_sf_order_user,sf_agv_site_group_sf_order_user,model_sf_agv_site,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_sf_agv_task_route_group_sf_order_user,sf_agv_task_route_group_sf_order_user,model_sf_agv_task_route,sf_base.group_sf_order_user,1,1,1,0
|
||||
|
59
sf_manufacturing/views/agv_setting_views.xml
Normal file
59
sf_manufacturing/views/agv_setting_views.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- agv站点 -->
|
||||
<record id="view_agv_site_tree" model="ir.ui.view">
|
||||
<field name="name">agv站点</field>
|
||||
<field name="model">sf.agv.site</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="bottom">
|
||||
<field name="number" required="1"/>
|
||||
<field name="name" required="1"/>
|
||||
<field name="owning_region" required="1"/>
|
||||
<field name="state" required="1"/>
|
||||
<field name="divide_the_work" required="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_agv_site_form" model="ir.actions.act_window">
|
||||
<field name="name">AGV站点</field>
|
||||
<field name="res_model">sf.agv.site</field>
|
||||
<field name="view_mode">tree</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_action_agv_site"
|
||||
parent="sf_base.menu_sf_base"
|
||||
name="AGV站点"
|
||||
sequence="12"
|
||||
action="action_agv_site_form"/>
|
||||
|
||||
<!-- agv任务路线 -->
|
||||
<record id="view_agv_task_route_tree" model="ir.ui.view">
|
||||
<field name="name">AGV任务路线</field>
|
||||
<field name="model">sf.agv.task.route</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="bottom">
|
||||
<field name="name" required="1"/>
|
||||
<field name="type" readonly="1"/>
|
||||
<field name="start_site_id" required="1" options="{'no_create': True}" string="起点接驳站"/>
|
||||
<field name="end_site_id" required="1" options="{'no_create': True}" string="终点接驳站"/>
|
||||
<field name="destination_production_line_id" required="1" options="{'no_create': True}"/>
|
||||
<field name="priority" widget="priority"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_agv_task_route_form" model="ir.actions.act_window">
|
||||
<field name="name">AGV任务路线</field>
|
||||
<field name="res_model">sf.agv.task.route</field>
|
||||
<field name="view_mode">tree</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_action_agv_task_route"
|
||||
parent="sf_base.menu_sf_base"
|
||||
name="AGV任务路线"
|
||||
sequence="13"
|
||||
action="action_agv_task_route_form"/>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -109,16 +109,18 @@
|
||||
<field name='is_delivery' invisible="1"/>
|
||||
<!-- 工单form页面的开始停工按钮等 -->
|
||||
<button name="button_start" type="object" string="开始" class="btn-success"
|
||||
|
||||
attrs="{'invisible': ['|', ('production_state', '!=', 'pending_processing'), ('state','!=','ready')]}"
|
||||
groups="sf_base.group_sf_mrp_user"/>
|
||||
<button name="button_pending" type="object" string="暂停" class="btn-warning"
|
||||
attrs="{'invisible': ['|', ('production_state', '!=', 'pending_processing'), ('state','!=','progress')]}"
|
||||
groups="sf_base.group_sf_mrp_user"/>
|
||||
<button name="button_finish" type="object" string="完成" class="btn-success"
|
||||
attrs="{'invisible': ['|', ('production_state', '!=', 'pending_processing'), ('state','!=','progress')]}"
|
||||
groups="sf_base.group_sf_mrp_user" confirm="是否确认完工"/>
|
||||
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="停工"
|
||||
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
|
||||
groups="sf_base.group_sf_mrp_user"
|
||||
attrs="{'invisible': ['|', '|','|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'),('user_permissions','=',False),('state','=','done'), ('routing_type', '=', 'CNC加工')]}"/>
|
||||
attrs="{'invisible': ['|', ('production_state', '!=', 'pending_processing'), ('state','!=','progress')]}"/>
|
||||
<button name="button_unblock" type="object" string="Unblock"
|
||||
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
|
||||
groups="sf_base.group_sf_mrp_user"
|
||||
@@ -208,12 +210,12 @@
|
||||
<field name="programming_state" readonly="1"
|
||||
attrs='{"invisible": [("programming_no","=",False)]}'/>
|
||||
</group>
|
||||
<group>
|
||||
<div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">
|
||||
<button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"
|
||||
/>
|
||||
</div>
|
||||
</group>
|
||||
<!-- <group>-->
|
||||
<!-- <div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">-->
|
||||
<!-- <button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"-->
|
||||
<!-- />-->
|
||||
<!-- </div>-->
|
||||
<!-- </group>-->
|
||||
</page>
|
||||
</xpath>
|
||||
<!-- <page string="Components" name="components">-->
|
||||
@@ -423,8 +425,9 @@
|
||||
<tree editable="bottom">
|
||||
<field name="production_id" invisible="1"/>
|
||||
<field name="workpiece_code"/>
|
||||
<field name="feeder_station_start" force_save="1"/>
|
||||
<field name="feeder_station_destination" force_save="1"/>
|
||||
<field name="route_id" options="{'no_create': True}"/>
|
||||
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
||||
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
|
||||
<field name="cnc_program_down_state" readonly="1"/>
|
||||
<field name="production_line_id"/>
|
||||
<field name="task_delivery_time" readonly="1"/>
|
||||
@@ -524,7 +527,8 @@
|
||||
<field name="is_ok"/>
|
||||
<field name="processing_user_id"/>
|
||||
<field name="inspection_user_id"/>
|
||||
<field name="save_name" widget="CopyClipboardChar"/>
|
||||
<field name="save_name" widget="CopyClipboardChar"
|
||||
attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -555,7 +559,7 @@
|
||||
<field name="name">工件配送</field>
|
||||
<field name="model">sf.workpiece.delivery</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="工件配送">
|
||||
<tree string="工件配送" editable="bottom" class="center" create="0" delete="0">
|
||||
<header>
|
||||
<button name="button_delivery" type="object" string="配送" class="oe_highlight"/>
|
||||
</header>
|
||||
@@ -565,12 +569,13 @@
|
||||
decoration-danger="status == '待配送'"/>
|
||||
<field name="production_id" string="工件编码"/>
|
||||
<field name="workpiece_code"/>
|
||||
<field name="production_line_id"/>
|
||||
<field name="feeder_station_start"/>
|
||||
<field name="feeder_station_destination"/>
|
||||
<field name="cnc_program_down_state"/>
|
||||
<field name="task_delivery_time"/>
|
||||
<field name="task_completion_time"/>
|
||||
<field name="production_line_id" options="{'no_create': True}"/>
|
||||
<field name="route_id" options="{'no_create': True}"/>
|
||||
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
||||
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
|
||||
<field name="cnc_program_down_state" readonly="1"/>
|
||||
<field name="task_delivery_time" readonly="1"/>
|
||||
<field name="task_completion_time" readonly="1"/>
|
||||
<field name="delivery_duration" widget="float_time"/>
|
||||
</tree>
|
||||
</field>
|
||||
@@ -583,10 +588,10 @@
|
||||
<search string="工件配送">
|
||||
<field name="production_id"/>
|
||||
<field name="workpiece_code"/>
|
||||
<field name="feeder_station_start"/>
|
||||
<field name="feeder_station_start_id"/>
|
||||
<field name="production_line_id"/>
|
||||
<field name="task_delivery_time"/>
|
||||
<field name="feeder_station_destination"/>
|
||||
<field name="feeder_station_destination_id"/>
|
||||
<field name="task_completion_time"/>
|
||||
<field name="delivery_duration"/>
|
||||
<field name="status"/>
|
||||
|
||||
@@ -5,12 +5,9 @@
|
||||
<field name="model">sf.workpiece.delivery.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<field name="delivery_id" invisible="True"/>
|
||||
<field name="workorder_id" invisible="True"/>
|
||||
|
||||
<div>
|
||||
是否确定配送?
|
||||
</div>
|
||||
<field name="delivery_id" invisible="True"/>
|
||||
<field name="workorder_id" invisible="True"/>
|
||||
<div>是否确定配送?</div>
|
||||
<footer>
|
||||
<button string="确认" name="confirm" type="object" class="oe_highlight"/>
|
||||
<button string="取消" class="btn btn-secondary" special="cancel"/>
|
||||
|
||||
@@ -17,4 +17,3 @@ class WorkpieceDeliveryWizard(models.TransientModel):
|
||||
self.workorder_id.workpiece_delivery_ids._delivery_avg()
|
||||
else:
|
||||
self.delivery_id._delivery_avg()
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'])])
|
||||
logging.info('制造订单号:%s' % cnc_production.name)
|
||||
if cnc_production:
|
||||
if ret['glb_file']:
|
||||
cnc_production.glb_file = base64.b64encode(ret['glb_file'])
|
||||
# if ret['glb_file']:
|
||||
# cnc_production.glb_file = base64.b64encode(ret['glb_file'])
|
||||
# 拉取所有加工面的程序文件
|
||||
# i = 1
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ class ResConfigSettings(models.TransientModel):
|
||||
sf_url = fields.Char(string='访问地址', default='https://sf.cs.jikimo.com')
|
||||
agv_rcs_url = fields.Char(string='avg_rcs访问地址',
|
||||
default='http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask')
|
||||
center_control_url = fields.Char(string='中控访问地址',
|
||||
default='http://172.16.21.50:8001')
|
||||
center_control_Authorization = fields.Char(string='中控访问认证')
|
||||
wbcode = fields.Char('地码')
|
||||
agv_code = fields.Char(string='agv编号')
|
||||
task_type_no = fields.Char('任务单类型编号')
|
||||
@@ -99,7 +102,8 @@ class ResConfigSettings(models.TransientModel):
|
||||
agv_rcs_url = config.get_param('agv_rcs_url', default='')
|
||||
wbcode = config.get_param('wbcode', default='')
|
||||
agv_code = config.get_param('agv_code', default='')
|
||||
task_type_no = config.get_param('task_type_no', default='')
|
||||
center_control_url = config.get_param('center_control_url', default='')
|
||||
center_control_Authorization = config.get_param('center_control_Authorization', default='')
|
||||
ftp_host = config.get_param('ftp_host', default='')
|
||||
ftp_port = config.get_param('ftp_port', default='')
|
||||
ftp_user = config.get_param('ftp_user', default='')
|
||||
@@ -112,7 +116,8 @@ class ResConfigSettings(models.TransientModel):
|
||||
agv_rcs_url=agv_rcs_url,
|
||||
wbcode=wbcode,
|
||||
agv_code=agv_code,
|
||||
task_type_no=task_type_no,
|
||||
center_control_url=center_control_url,
|
||||
center_control_Authorization=center_control_Authorization,
|
||||
ftp_host=ftp_host,
|
||||
ftp_port=ftp_port,
|
||||
ftp_user=ftp_user,
|
||||
@@ -129,31 +134,9 @@ class ResConfigSettings(models.TransientModel):
|
||||
ir_config.set_param("agv_rcs_url", self.agv_rcs_url or "")
|
||||
ir_config.set_param("wbcode", self.wbcode or "")
|
||||
ir_config.set_param("agv_code", self.agv_code or "")
|
||||
ir_config.set_param("task_type_no", self.task_type_no or "")
|
||||
ir_config.set_param("center_control_url", self.center_control_url or "")
|
||||
ir_config.set_param("center_control_Authorization", self.center_control_Authorization or "")
|
||||
ir_config.set_param("ftp_host", self.ftp_host or "")
|
||||
ir_config.set_param("ftp_port", self.ftp_port or "")
|
||||
ir_config.set_param("ftp_user", self.ftp_user or "")
|
||||
ir_config.set_param("ftp_password", self.ftp_password or "")
|
||||
|
||||
|
||||
class ResAgvSite(models.Model):
|
||||
_name = 'res.agv.site'
|
||||
_description = 'agv站点'
|
||||
|
||||
number = fields.Integer('编号')
|
||||
type = fields.Selection([('00', '位置编号'), ('01', '库区编号'), ('02', '货架编号')], '类型')
|
||||
content = fields.Char('内容')
|
||||
site_prop = fields.Selection([('上产线', '上产线'), ('下产线', '下产线')], '属性')
|
||||
state_status = fields.Selection([('占用', '占用'), ('空闲', '空闲')], '状态')
|
||||
# remark = fields.Char
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
# @api.model
|
||||
# def create(self, vals):
|
||||
# if vals.get('number', 'new') == 'new':
|
||||
# vals['number'] = self.env['ir.sequence'].next_by_code('res.agv.site') or '/'
|
||||
# return super(ResAgvSite, self).create(vals)
|
||||
|
||||
def unlink(self):
|
||||
for item in self:
|
||||
item.active == True
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_sf_static_resource_datasync,sf_static_resource_datasync,model_sf_static_resource_datasync,base.group_user,1,1,1,1
|
||||
access_res_agv_site,access_res_agv_site,model_res_agv_site,base.group_system,1,1,1,1
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,28 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="view_agv_site_tree" model="ir.ui.view">
|
||||
<field name="name">agv站点集合</field>
|
||||
<field name="model">res.agv.site</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="bottom">
|
||||
<field name="number"/>
|
||||
<field name="type"/>
|
||||
<field name="content"/>
|
||||
<field name="state_status"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_agv_site_form" model="ir.actions.act_window">
|
||||
<field name="name">站点集合</field>
|
||||
<field name="res_model">res.agv.site</field>
|
||||
<field name="view_mode">tree</field>
|
||||
</record>
|
||||
<menuitem id="menu_action_agv_site_form" action="sf_mrs_connect.action_agv_site_form" name="站点集合"
|
||||
sequence="11"/>
|
||||
|
||||
|
||||
<record id="res_config_settings_view_form_sf_sync" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.inherit.sf_sync</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
@@ -106,10 +84,6 @@
|
||||
<label for="agv_rcs_url" string="访问地址"/>
|
||||
<field name="agv_rcs_url"/>
|
||||
</div>
|
||||
<div class="text-muted">
|
||||
<label for="task_type_no"/>
|
||||
<field name="task_type_no"/>
|
||||
</div>
|
||||
<div class="text-muted">
|
||||
<label for="agv_code" string="车辆编号"/>
|
||||
<field name="agv_code"/>
|
||||
@@ -118,9 +92,23 @@
|
||||
<label for="wbcode"/>
|
||||
<field name="wbcode"/>
|
||||
</div>
|
||||
<div class="mt8">
|
||||
<button type="action" name="%(sf_mrs_connect.action_agv_site_form)d"
|
||||
string="站点集合" class="btn-link" icon="fa-arrow-right"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h2>中控参数配置</h2>
|
||||
<div class="row mt16 o_settings_container">
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<div class="o_setting_left_pane"/>
|
||||
<div class="o_setting_right_pane">
|
||||
<div class="text-muted">
|
||||
<label for="center_control_url" string="访问地址"/>
|
||||
<field name="center_control_url"/>
|
||||
</div>
|
||||
<div class="text-muted">
|
||||
<label for="center_control_Authorization" string="身份认证"/>
|
||||
<field name="center_control_Authorization"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -12,13 +12,10 @@ class QualityCheck(models.Model):
|
||||
|
||||
# ==========零件特采接口==========
|
||||
def _register_quality_check(self):
|
||||
# create_url = '/AutoDeviceApi/PartSpecProc'
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'}
|
||||
crea_url = "https://x24467i973.zicp.fun/AutoDeviceApi/PartSpecProc"
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
|
||||
headers = {'Authorization': config['center_control_Authorization']}
|
||||
crea_url = config['center_control_url'] + "/AutoDeviceApi/GetToolInfos"
|
||||
origin = self.picking_id.origin
|
||||
production_id = self.env['mrp.production'].sudo().search([('name', '=', origin)])
|
||||
rfid = '' if not production_id.workorder_ids else production_id.workorder_ids[-1].rfid_code or ''
|
||||
|
||||
@@ -128,18 +128,18 @@ class QuickEasyOrder(models.Model):
|
||||
# # 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('C:/Users/43484/Desktop/机企猫工作文档', str(model_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
|
||||
# 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('C:/Users/43484/Desktop/机企猫工作文档', str(model_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)
|
||||
@@ -189,6 +189,7 @@ class QuickEasyOrder(models.Model):
|
||||
'number': item.quantity,
|
||||
'total_amount': item.price,
|
||||
'remark': '',
|
||||
'manual_quotation': True,
|
||||
'barcode': barcode
|
||||
})
|
||||
# res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list'])
|
||||
@@ -291,8 +292,8 @@ class QuickEasyOrder(models.Model):
|
||||
'model_width': order.model_width,
|
||||
'model_height': order.model_height,
|
||||
'model_volume': order.model_volume,
|
||||
'color_model_path': '/tmp/' + str(model_code) + ".step",
|
||||
'model_order_no': order.name,
|
||||
'model_color_path': '/tmp/' + str(model_code) + ".step",
|
||||
'model_order_no': '%s-%s' % (order.name, 1),
|
||||
'remark': '订单号:%s 客户:%s' % (order.name, order.customer_id.name)
|
||||
}
|
||||
try:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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_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,0,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_director,quick_easy_order_group_sale_director,model_quick_easy_order,sf_base.group_sale_director,1,1,1,0
|
||||
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_director,sale_order_director,model_sale_order,sf_base.group_sale_director,1,1,1,0
|
||||
|
||||
|
@@ -94,7 +94,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}
|
||||
['approved'])]}
|
||||
</attribute>
|
||||
</xpath>
|
||||
<field name="partner_ref" position="attributes">
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="customer_id" context="{'is_customer': True }"
|
||||
options="{'no_create': True}"/>
|
||||
options="{'no_create': True}" required="1"/>
|
||||
<field name="upload_model_file" widget="many2many_binary"/>
|
||||
<field name="model_file" widget="Viewer3D" string="模型" readonly="1" force_save="1"
|
||||
attrs="{'invisible': [('model_file', '=', False)]}"/>
|
||||
@@ -68,12 +68,12 @@
|
||||
</div>
|
||||
<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="material_id" options="{'no_create': True}" required="1"/>
|
||||
<field name="material_model_id" options="{'no_create': True}" required="1"/>
|
||||
<!-- <field name="process_id"/>-->
|
||||
<field name="parameter_ids" widget="many2many_tags" string="表面工艺参数"
|
||||
options="{'no_create': True}"/>
|
||||
<field name="machining_precision"/>
|
||||
options="{'no_create': True}" required="1"/>
|
||||
<field name="machining_precision" required="1"/>
|
||||
<field name="processing_time"/>
|
||||
<field name="quantity" options="{'format': false}"/>
|
||||
<field name="unit_price"/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
|
||||
import logging
|
||||
|
||||
from datetime import timedelta
|
||||
@@ -423,7 +425,8 @@ class FunctionalToolAssembly(models.Model):
|
||||
def _compute_integral_product_id(self):
|
||||
for item in self:
|
||||
if item.integral_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.integral_freight_barcode)])
|
||||
location = self.env['sf.shelf.location'].sudo().search(
|
||||
[('barcode', '=', item.integral_freight_barcode)])
|
||||
if location:
|
||||
item.integral_product_id = location.product_id.id
|
||||
else:
|
||||
@@ -442,7 +445,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
@api.depends('blade_freight_barcode')
|
||||
def _compute_blade_product_id(self):
|
||||
for item in self:
|
||||
if item.integral_freight_barcode:
|
||||
if item.blade_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.blade_freight_barcode)])
|
||||
if location:
|
||||
item.blade_product_id = location.product_id.id
|
||||
@@ -462,7 +465,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
@api.depends('bar_freight_barcode')
|
||||
def _compute_bar_product_id(self):
|
||||
for item in self:
|
||||
if item.integral_freight_barcode:
|
||||
if item.bar_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.bar_freight_barcode)])
|
||||
if location:
|
||||
item.bar_product_id = location.product_id.id
|
||||
@@ -482,7 +485,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
@api.depends('pad_freight_barcode')
|
||||
def _compute_pad_product_id(self):
|
||||
for item in self:
|
||||
if item.integral_freight_barcode:
|
||||
if item.pad_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.pad_freight_barcode)])
|
||||
if location:
|
||||
item.pad_product_id = location.product_id.id
|
||||
@@ -523,7 +526,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
@api.depends('chuck_freight_barcode')
|
||||
def _compute_chuck_product_id(self):
|
||||
for item in self:
|
||||
if item.integral_freight_barcode:
|
||||
if item.chuck_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.chuck_freight_barcode)])
|
||||
if location:
|
||||
item.chuck_product_id = location.product_id.id
|
||||
@@ -631,3 +634,285 @@ class FunctionalToolAssembly(models.Model):
|
||||
code = self._get_code(obj.loading_task_source)
|
||||
obj.assembly_order_code = code
|
||||
return obj
|
||||
|
||||
|
||||
class FunctionalToolDismantle(models.Model):
|
||||
_name = 'sf.functional.tool.dismantle'
|
||||
_inherit = ["barcodes.barcode_events_mixin"]
|
||||
_description = '功能刀具拆解'
|
||||
|
||||
def on_barcode_scanned(self, barcode):
|
||||
"""
|
||||
扫码
|
||||
"""
|
||||
# 对barcode进行校验是否为货位编码
|
||||
if not re.match(r'^[A-Za-z0-9]+-[A-Za-z0-9]+-\d{3}-\d{3}$', barcode):
|
||||
tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
||||
[('rfid', '=', barcode), ('functional_tool_status', '!=', '已拆除')])
|
||||
if tool_id:
|
||||
self.functional_tool_id = tool_id.id
|
||||
else:
|
||||
raise ValidationError('Rfid为【%s】的功能刀具不存在,请重新扫描!' % barcode)
|
||||
else:
|
||||
if self.dismantle_cause == '更换为其他刀具':
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', barcode)])
|
||||
if not location:
|
||||
raise ValidationError('【%s】该货位不存在,请重新扫码!' % barcode)
|
||||
else:
|
||||
if not location.product_id:
|
||||
# 判断功能刀具存在哪些刀具物料需要录入库位
|
||||
if self.chuck_product_id: # 夹头
|
||||
if not self.chuck_freight_id:
|
||||
self.chuck_freight_id = location.id
|
||||
return True
|
||||
if self.integral_product_id: # 整体式刀具
|
||||
if not self.integral_freight_id:
|
||||
self.integral_freight_id = location.id
|
||||
return True
|
||||
elif self.blade_product_id: # 刀片
|
||||
if not self.blade_freight_id:
|
||||
self.blade_freight_id = location.id
|
||||
return True
|
||||
if self.bar_product_id: # 刀杆
|
||||
if not self.bar_freight_id:
|
||||
self.bar_freight_id = location.id
|
||||
return True
|
||||
elif self.pad_product_id: # 刀盘
|
||||
if not self.pad_freight_id:
|
||||
self.pad_freight_id = location.id
|
||||
return True
|
||||
else:
|
||||
# 判断货位存放的是那个刀具物料产品
|
||||
if self.integral_product_id == location.product_id: # 整体式刀具
|
||||
self.integral_freight_id = location.id
|
||||
elif self.blade_product_id == location.product_id: # 刀片
|
||||
self.blade_freight_id = location.id
|
||||
elif self.bar_product_id == location.product_id: # 刀杆
|
||||
self.bar_freight_id = location.id
|
||||
elif self.pad_product_id == location.product_id: # 刀盘
|
||||
self.pad_freight_id = location.id
|
||||
elif self.chuck_product_id == location.product_id: # 夹头
|
||||
self.chuck_freight_id = location.id
|
||||
elif self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
|
||||
raise ValidationError('该功能刀具因为%s拆解,无需录入库位' % self.dismantle_cause)
|
||||
else:
|
||||
raise ValidationError('该功能刀具因为%s拆解,无需录入库位' % self.dismantle_cause)
|
||||
|
||||
name = fields.Char('名称', related='functional_tool_id.name')
|
||||
|
||||
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
|
||||
domain=[('functional_tool_status', '!=', '已拆除')])
|
||||
tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
|
||||
compute='_compute_functional_tool_num')
|
||||
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_functional_tool_num', store=True)
|
||||
diameter = fields.Integer(string='刀具直径(mm)', compute='_compute_functional_tool_num', store=True)
|
||||
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', compute='_compute_functional_tool_num', store=True)
|
||||
rfid = fields.Char('Rfid', compute='_compute_functional_tool_num', store=True)
|
||||
rfid_dismantle = fields.Char('Rfid(已拆解)', readonly=True)
|
||||
|
||||
dismantle_cause = fields.Selection(
|
||||
[('寿命到期报废', '寿命到期报废'), ('崩刀报废', '崩刀报废'), ('更换为其他刀具', '更换为其他刀具'),
|
||||
('刀具需磨削', '刀具需磨削')], string='拆解原因', required=True)
|
||||
dismantle_data = fields.Datetime('拆解日期', readonly=True)
|
||||
dismantle_person = fields.Char('拆解人', readonly=True)
|
||||
image = fields.Binary('图片', readonly=True)
|
||||
|
||||
scrap_id = fields.Char('报废单号', readonly=True)
|
||||
grinding_id = fields.Char('磨削单号', readonly=True)
|
||||
|
||||
state = fields.Selection([('待拆解', '待拆解'), ('已拆解', '已拆解')], default='待拆解')
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
# 刀柄
|
||||
handle_product_id = fields.Many2one('product.product', string='刀柄', compute='_compute_functional_tool_num',
|
||||
store=True)
|
||||
handle_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
|
||||
related='handle_product_id.cutting_tool_model_id')
|
||||
handle_brand_id = fields.Many2one('sf.machine.brand', string='刀柄品牌', related='handle_product_id.brand_id')
|
||||
handle_rfid = fields.Char(string='刀柄Rfid', compute='_compute_functional_tool_num', store=True)
|
||||
scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False)
|
||||
|
||||
# 整体式
|
||||
integral_product_id = fields.Many2one('product.product', string='整体式刀具',
|
||||
compute='_compute_functional_tool_num', store=True)
|
||||
integral_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
|
||||
related='integral_product_id.cutting_tool_model_id')
|
||||
integral_brand_id = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
|
||||
related='integral_product_id.brand_id')
|
||||
integral_freight_id = fields.Many2one('sf.shelf.location', '整体式刀具目标货位',
|
||||
domain="[('product_id', 'in', (integral_product_id, False))]")
|
||||
|
||||
# 刀片
|
||||
blade_product_id = fields.Many2one('product.product', string='刀片', compute='_compute_functional_tool_num',
|
||||
store=True)
|
||||
blade_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
|
||||
related='blade_product_id.cutting_tool_model_id')
|
||||
blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id')
|
||||
blade_freight_id = fields.Many2one('sf.shelf.location', '刀片目标货位',
|
||||
domain="[('product_id', 'in', (blade_product_id, False))]")
|
||||
|
||||
# 刀杆
|
||||
bar_product_id = fields.Many2one('product.product', string='刀杆', compute='_compute_functional_tool_num',
|
||||
store=True)
|
||||
bar_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
|
||||
related='bar_product_id.cutting_tool_model_id')
|
||||
bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id')
|
||||
bar_freight_id = fields.Many2one('sf.shelf.location', '刀杆目标货位',
|
||||
domain="[('product_id', 'in', (bar_product_id, False))]")
|
||||
|
||||
# 刀盘
|
||||
pad_product_id = fields.Many2one('product.product', string='刀盘', compute='_compute_functional_tool_num',
|
||||
store=True)
|
||||
pad_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
|
||||
related='pad_product_id.cutting_tool_model_id')
|
||||
pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id')
|
||||
pad_freight_id = fields.Many2one('sf.shelf.location', '刀盘目标货位',
|
||||
domain="[('product_id', 'in', (pad_product_id, False))]")
|
||||
|
||||
# 夹头
|
||||
chuck_product_id = fields.Many2one('product.product', string='夹头', compute='_compute_functional_tool_num',
|
||||
store=True)
|
||||
chuck_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
|
||||
related='chuck_product_id.cutting_tool_model_id')
|
||||
chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id')
|
||||
chuck_freight_id = fields.Many2one('sf.shelf.location', '夹头目标货位',
|
||||
domain="[('product_id', 'in', (chuck_product_id, False))]")
|
||||
|
||||
@api.depends('functional_tool_id')
|
||||
def _compute_functional_tool_num(self):
|
||||
for item in self:
|
||||
if item.functional_tool_id:
|
||||
item.tool_groups_id = item.functional_tool_id.tool_groups_id.id
|
||||
item.tool_type_id = item.functional_tool_id.sf_cutting_tool_type_id.id
|
||||
item.diameter = item.functional_tool_id.functional_tool_diameter
|
||||
item.knife_tip_r_angle = item.functional_tool_id.knife_tip_r_angle
|
||||
item.rfid = item.functional_tool_id.rfid
|
||||
item.handle_rfid = item.functional_tool_id.rfid
|
||||
|
||||
item.handle_product_id = item.functional_tool_id.functional_tool_name_id.handle_product_id.id
|
||||
item.integral_product_id = item.functional_tool_id.functional_tool_name_id.integral_product_id.id
|
||||
item.blade_product_id = item.functional_tool_id.functional_tool_name_id.blade_product_id.id
|
||||
item.bar_product_id = item.functional_tool_id.functional_tool_name_id.bar_product_id.id
|
||||
item.pad_product_id = item.functional_tool_id.functional_tool_name_id.pad_product_id.id
|
||||
item.chuck_product_id = item.functional_tool_id.functional_tool_name_id.chuck_product_id.id
|
||||
else:
|
||||
item.tool_groups_id = False
|
||||
item.tool_type_id = False
|
||||
item.diameter = 0
|
||||
item.knife_tip_r_angle = 0
|
||||
item.rfid = ''
|
||||
item.handle_rfid = ''
|
||||
|
||||
item.handle_product_id = False
|
||||
item.integral_product_id = False
|
||||
item.blade_product_id = False
|
||||
item.bar_product_id = False
|
||||
item.pad_product_id = False
|
||||
item.chuck_product_id = False
|
||||
|
||||
def confirmation_disassembly(self):
|
||||
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
||||
if self.functional_tool_id.functional_tool_status == '已拆除':
|
||||
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
|
||||
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
||||
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
|
||||
# =================刀柄是否报废拆解=======
|
||||
location_dest_scrap = self.env['stock.location'].search([('name', '=', 'Scrap')])
|
||||
if self.handle_rfid:
|
||||
lot = self.env['stock.lot'].sudo().search([('rfid', '=', self.handle_rfid)])
|
||||
functional_tool_assembly = self.functional_tool_id.functional_tool_name_id
|
||||
if self.scrap_boolean:
|
||||
# 刀柄报废 入库到Scrap
|
||||
lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, '功能刀具拆解',
|
||||
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
|
||||
else:
|
||||
# 刀柄不报废 入库到刀具房
|
||||
lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, '功能刀具拆解',
|
||||
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
|
||||
# ==============功能刀具报废拆解================
|
||||
if self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
|
||||
# 除刀柄外物料报废 入库到Scrap
|
||||
if self.integral_freight_id:
|
||||
self.integral_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
||||
elif self.blade_freight_id:
|
||||
self.blade_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
||||
if self.bar_freight_id:
|
||||
self.bar_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
||||
elif self.pad_freight_id:
|
||||
self.pad_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
||||
if self.chuck_freight_id:
|
||||
self.chuck_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
||||
# ===========功能刀具磨削拆解==============
|
||||
elif self.dismantle_cause in ['刀具需磨削']:
|
||||
location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
|
||||
# 除刀柄外物料拆解 入库到具体库位
|
||||
if self.integral_freight_id:
|
||||
self.integral_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
elif self.blade_freight_id:
|
||||
self.blade_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
if self.bar_freight_id:
|
||||
self.bar_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
elif self.pad_freight_id:
|
||||
self.pad_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
if self.chuck_freight_id:
|
||||
self.chuck_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
# ==============功能刀具更换拆解==============
|
||||
elif self.dismantle_cause in ['更换为其他刀具']:
|
||||
# 除刀柄外物料拆解 入库到具体库位
|
||||
if self.integral_freight_id:
|
||||
self.integral_product_id.dismantle_stock_moves(self.integral_freight_id.barcode, location,
|
||||
location_dest)
|
||||
elif self.blade_freight_id:
|
||||
self.blade_product_id.dismantle_stock_moves(self.blade_freight_id.barcode, location, location_dest)
|
||||
if self.bar_freight_id:
|
||||
self.bar_product_id.dismantle_stock_moves(self.bar_freight_id.barcode, location, location_dest)
|
||||
elif self.pad_freight_id:
|
||||
self.pad_product_id.dismantle_stock_moves(self.pad_freight_id.barcode, location, location_dest)
|
||||
if self.chuck_freight_id:
|
||||
self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id.barcode, location, location_dest)
|
||||
# ===============删除功能刀具的Rfid字段的值, 赋值给Rfid(已拆解)字段=====
|
||||
self.functional_tool_id.write({
|
||||
'rfid_dismantle': self.functional_tool_id.rfid,
|
||||
'rfid': '',
|
||||
'functional_tool_status': '已拆除'
|
||||
})
|
||||
# 修改拆解单的值
|
||||
self.write({
|
||||
'rfid_dismantle': self.rfid,
|
||||
'dismantle_data': fields.Datetime.now(),
|
||||
'dismantle_person': self.env.user.name,
|
||||
'rfid': '',
|
||||
'state': '已拆解'
|
||||
})
|
||||
logging.info('刀具拆解成功!')
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
def dismantle_stock_moves(self, shelf_location_barcode, location_id, location_dest_id):
|
||||
# 创建功能刀具拆解单产品库存移动记录
|
||||
stock_move_id = self.env['stock.move'].sudo().create({
|
||||
'name': '功能刀具拆解',
|
||||
'product_id': self.id,
|
||||
'location_id': location_id.id,
|
||||
'location_dest_id': location_dest_id.id,
|
||||
'product_uom_qty': 1.00,
|
||||
'state': 'done'
|
||||
})
|
||||
if shelf_location_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)])
|
||||
location.product_num = location.product_num + 1
|
||||
else:
|
||||
location = False
|
||||
# 创建移动历史记录
|
||||
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 or False,
|
||||
'install_tool_time': fields.Datetime.now(),
|
||||
'qty_done': 1.0,
|
||||
'state': 'done',
|
||||
})
|
||||
|
||||
return stock_move_id, stock_move_line_id
|
||||
|
||||
@@ -14,6 +14,7 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
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)
|
||||
rfid_dismantle = 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='刀具型号')
|
||||
@@ -44,7 +45,7 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
@api.depends('barcode_id.quant_ids')
|
||||
@api.depends('barcode_id.quant_ids', 'functional_tool_status')
|
||||
def _compute_current_location_id(self):
|
||||
for record in self:
|
||||
if record.barcode_id.quant_ids:
|
||||
@@ -60,6 +61,12 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
else:
|
||||
record.current_location_id = False
|
||||
record.current_location = False
|
||||
if record.functional_tool_status == '已拆除':
|
||||
record.current_location_id = False
|
||||
record.current_location = False
|
||||
record.tool_room_num = 0
|
||||
record.line_edge_knife_library_num = 0
|
||||
record.machine_knife_library_num = 0
|
||||
|
||||
def get_location_num(self):
|
||||
"""
|
||||
@@ -184,7 +191,8 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
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)
|
||||
self.functional_tool_name_id.id, '机床装刀', self.functional_tool_name_id,
|
||||
self.functional_tool_name_id.tool_groups_id)
|
||||
|
||||
# ==========刀具组接口==========
|
||||
# def _register_functional_tool_groups(self, obj):
|
||||
|
||||
@@ -43,12 +43,10 @@ class SfMaintenanceEquipment(models.Model):
|
||||
|
||||
# ==========机床当前刀库实时信息接口==========
|
||||
def register_equipment_tool(self):
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'}
|
||||
crea_url = "https://x24467i973.zicp.fun/AutoDeviceApi/GetToolInfos"
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
|
||||
headers = {'Authorization': config['center_control_Authorization']}
|
||||
crea_url = config['center_control_url'] + "/AutoDeviceApi/GetToolInfos"
|
||||
params = {"DeviceId": self.name}
|
||||
r = requests.get(crea_url, params=params, headers=headers)
|
||||
ret = r.json()
|
||||
@@ -112,6 +110,8 @@ class StockLot(models.Model):
|
||||
record.tool_material_status = '可用'
|
||||
elif record.quant_ids[-1].location_id.name == '刀具组装位置':
|
||||
record.tool_material_status = '在用'
|
||||
elif record.quant_ids[-1].location_id.name == 'Scrap':
|
||||
record.tool_material_status = '报废'
|
||||
else:
|
||||
record.tool_material_status = '未入库'
|
||||
if record.tool_material_search_id:
|
||||
|
||||
@@ -12,18 +12,16 @@ class CNCprocessing(models.Model):
|
||||
|
||||
# ==========MES装刀指令接口==========
|
||||
def register_cnc_processing(self, knife_plan):
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'}
|
||||
strurl = "https://x24467i973.zicp.fun/AutoDeviceApi/ToolLoadInstruct"
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
|
||||
headers = {'Authorization': config['center_control_Authorization']}
|
||||
crea_url = config['center_control_url'] + "/AutoDeviceApi/GetToolInfos"
|
||||
val = {
|
||||
'DeviceId': knife_plan.machine_table_name,
|
||||
'RfidCode': knife_plan.sf_functional_tool_assembly_id.rfid,
|
||||
'ToolId': int(knife_plan.cutter_spacing_code_id.code[1:])
|
||||
}
|
||||
r = requests.post(strurl, json=val, headers=headers)
|
||||
r = requests.post(crea_url, json=val, headers=headers)
|
||||
ret = r.json()
|
||||
logging.info('register_cnc_processing:%s' % ret)
|
||||
if ret['Succeed']:
|
||||
|
||||
@@ -39,9 +39,7 @@ class ToolMaterial(models.Model):
|
||||
usable_num += quant.quantity
|
||||
elif location == '刀具组装位置':
|
||||
have_been_used_num += quant.quantity
|
||||
elif location == '进货':
|
||||
pass
|
||||
elif location != 'Vendors':
|
||||
elif location == 'Scrap':
|
||||
scrap_num += quant.quantity
|
||||
record.usable_num = usable_num
|
||||
record.have_been_used_num = have_been_used_num
|
||||
|
||||
@@ -30,4 +30,8 @@ access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_se
|
||||
access_sf_tool_material_search_group_plan_dispatch,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_fixture_material_search,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_sf_order_user,1,0,0,0
|
||||
access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
|
||||
access_sf_functional_tool_dismantle_group_sf_tool_user,sf.functional.tool.dismantle,model_sf_functional_tool_dismantle,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_functional_tool_dismantle_group_plan_dispatch,sf.functional.tool.dismantle,model_sf_functional_tool_dismantle,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
|
@@ -85,7 +85,10 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="barcode_id" invisible="1"/>
|
||||
<field name="rfid" readonly="1"/>
|
||||
<field name="rfid" readonly="1"
|
||||
attrs="{'invisible': [('functional_tool_status', '=', '已拆除')]}"/>
|
||||
<field name="rfid_dismantle" readonly="1"
|
||||
attrs="{'invisible': [('functional_tool_status', '!=', '已拆除')]}"/>
|
||||
<field name="tool_name_id" invisible="0"
|
||||
placeholder="请输入20字以内的名称"/>
|
||||
<field name="sf_cutting_tool_type_id"/>
|
||||
@@ -202,6 +205,9 @@
|
||||
|
||||
<field name="current_location_id" invisible="True"/>
|
||||
<field name="sf_cutting_tool_type_id" invisible="True"/>
|
||||
<filter string="未拆除" name="no_state_removed" domain="[('functional_tool_status', '!=', '已拆除')]"/>
|
||||
<filter string="已拆除" name="state_removed" domain="[('functional_tool_status', '=', '已拆除')]"/>
|
||||
<separator/>
|
||||
<filter string="已归档" name="inactive" domain="[('active', '=', False)]"/>
|
||||
<searchpanel>
|
||||
<field name="sf_cutting_tool_type_id" icon="fa-building" enable_counters="1"/>
|
||||
@@ -218,6 +224,8 @@
|
||||
<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"/>
|
||||
<field name="search_view_id" ref="view_functional_cutting_tool_list_search"/>
|
||||
<field name="context">{'search_default_no_state_removed':1}</field>
|
||||
</record>
|
||||
|
||||
<!-- ======================================== 功能刀具预警========================================-->
|
||||
|
||||
@@ -14,69 +14,111 @@
|
||||
parent="mrp.menu_mrp_root"
|
||||
sequence="20"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_sf_functional_cutting_tool"
|
||||
parent="menu_sf_tool_manage"
|
||||
name="功能刀具"
|
||||
sequence="2"
|
||||
action="sf_function_tool_entry_list_view_act"
|
||||
/>
|
||||
|
||||
|
||||
<menuitem
|
||||
id="menu_sf_functional_tool_warning"
|
||||
parent="menu_sf_tool_manage"
|
||||
name="功能刀具预警"
|
||||
sequence="5"
|
||||
action="action_sf_functional_tool_warning"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
sequence="10"
|
||||
name="功能刀具安全库存"
|
||||
id="menu_sf_functional_tool_real_time_distribution"
|
||||
action="sf_real_time_distribution_of_functional_tools_view_act"
|
||||
parent="menu_sf_tool_manage"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
sequence="6"
|
||||
name="功能刀具出入库"
|
||||
id="menu_sf_function_tool_entry_exit_records"
|
||||
action="sf_inbound_and_outbound_records_of_functional_tools_view_act"
|
||||
parent="menu_sf_tool_manage"
|
||||
/>
|
||||
|
||||
<!-- =================计划菜单============== -->
|
||||
<menuitem
|
||||
sequence="0"
|
||||
name="功能刀具计划"
|
||||
name="计划"
|
||||
id="menu_sf_function_tool_plan"
|
||||
parent="menu_sf_tool_manage"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
sequence="10"
|
||||
name="机床换刀申请"
|
||||
id="menu_sf_machine_table_tool_changing_apply"
|
||||
action="sf_machine_table_tool_changing_apply_view_act"
|
||||
parent="menu_sf_function_tool_plan"
|
||||
/>
|
||||
<menuitem
|
||||
sequence="20"
|
||||
name="CAM工单程序用刀计划"
|
||||
id="menu_sf_cam_work_order_program_knife_plan"
|
||||
action="sf_cam_work_order_program_knife_plan_view_act"
|
||||
parent="menu_sf_function_tool_plan"
|
||||
/>
|
||||
|
||||
|
||||
<!-- ================功能菜单================= -->
|
||||
<menuitem
|
||||
sequence="0"
|
||||
name="机床换刀申请"
|
||||
id="menu_sf_machine_table_tool_changing_apply"
|
||||
action="sf_machine_table_tool_changing_apply_view_act"
|
||||
parent="menu_sf_function_tool_plan"
|
||||
sequence="5"
|
||||
name="功能"
|
||||
id="menu_sf_function_tool_function"
|
||||
parent="menu_sf_tool_manage"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
sequence="4"
|
||||
sequence="10"
|
||||
name="功能刀具组装"
|
||||
id="menu_sf_functional_tool_assembly"
|
||||
action="sf_functional_tool_assembly_view_act"
|
||||
parent="menu_sf_function_tool_function"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
sequence="20"
|
||||
name="功能刀具拆解"
|
||||
id="menu_sf_functional_tool_dismantle"
|
||||
action="sf_functional_tool_dismantle_view_act"
|
||||
parent="menu_sf_function_tool_function"
|
||||
/>
|
||||
|
||||
|
||||
<!-- ================功能刀具菜单=============== -->
|
||||
<menuitem
|
||||
sequence="10"
|
||||
name="功能刀具"
|
||||
id="menu_sf_function_tool"
|
||||
parent="menu_sf_tool_manage"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
id="menu_sf_functional_cutting_tool"
|
||||
parent="menu_sf_function_tool"
|
||||
name="功能刀具"
|
||||
sequence="10"
|
||||
action="sf_function_tool_entry_list_view_act"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
id="menu_sf_functional_tool_warning"
|
||||
parent="menu_sf_function_tool"
|
||||
name="功能刀具预警"
|
||||
sequence="20"
|
||||
action="action_sf_functional_tool_warning"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
sequence="30"
|
||||
name="功能刀具出入库"
|
||||
id="menu_sf_function_tool_entry_exit_records"
|
||||
action="sf_inbound_and_outbound_records_of_functional_tools_view_act"
|
||||
parent="menu_sf_function_tool"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
sequence="40"
|
||||
name="功能刀具安全库存"
|
||||
id="menu_sf_functional_tool_real_time_distribution"
|
||||
action="sf_real_time_distribution_of_functional_tools_view_act"
|
||||
parent="menu_sf_function_tool"
|
||||
/>
|
||||
|
||||
<!-- ===============刀具物料菜单================ -->
|
||||
<menuitem
|
||||
sequence="15"
|
||||
name="刀具物料"
|
||||
id="menu_sf_tool_material"
|
||||
parent="menu_sf_tool_manage"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
sequence="10"
|
||||
name="刀具物料查询"
|
||||
id="menu_sf_tool_material_search"
|
||||
action="action_sf_tool_material_search"
|
||||
parent="menu_sf_tool_material"
|
||||
/>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -766,5 +766,187 @@
|
||||
<field name="search_view_id" ref="sf_functional_tool_assembly_search"/>
|
||||
<field name="context">{'search_default_no_assemble_status':1}</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!--================================================功能刀具拆解================================================-->
|
||||
<record id="sf_functional_tool_dismantle_tree" model="ir.ui.view">
|
||||
<field name="name">功能刀具拆解</field>
|
||||
<field name="model">sf.functional.tool.dismantle</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree create="1">
|
||||
<field name="rfid"/>
|
||||
<field name="functional_tool_id"/>
|
||||
<field name="tool_type_id" invisible="1"/>
|
||||
<field name="tool_groups_id"/>
|
||||
<field name="diameter"/>
|
||||
<field name="knife_tip_r_angle"/>
|
||||
<field name="dismantle_cause"/>
|
||||
<field name="dismantle_data"/>
|
||||
<field name="dismantle_person"/>
|
||||
<field name="state" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_functional_tool_dismantle_form" model="ir.ui.view">
|
||||
<field name="name">功能刀具拆解</field>
|
||||
<field name="model">sf.functional.tool.dismantle</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<header>
|
||||
<button string="确认拆解" name="confirmation_disassembly" type="object" class="btn-primary"
|
||||
confirm="是否确认拆解" attrs="{'invisible': [('state', '=', '已拆解')]}"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="待拆解,已拆解"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<field name="functional_tool_id" placeholder="请选择将要拆解的功能刀具"
|
||||
options="{'no_create': True}" attrs="{'readonly': [('state', '=', '已拆解')]}"/>
|
||||
</h1>
|
||||
</div>
|
||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||
<group>
|
||||
<group>
|
||||
<field name="rfid" attrs="{'invisible': [('state', '=', '已拆解')]}"/>
|
||||
<field name="rfid_dismantle" attrs="{'invisible': [('state', '!=', '已拆解')]}"/>
|
||||
<field name="tool_type_id"/>
|
||||
<field name="tool_groups_id"/>
|
||||
<field name="diameter"/>
|
||||
<field name="knife_tip_r_angle"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="image"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group>
|
||||
<group>
|
||||
<field name="dismantle_cause" placeholder="请选择拆解原因"
|
||||
attrs="{'readonly': [('state', '=', '已拆解')]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="scrap_id"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['寿命到期报废','崩刀报废'])]}"/>
|
||||
<field name="grinding_id"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['刀具需磨削'])]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="物料组装信息">
|
||||
<group>
|
||||
<group string="刀柄" attrs="{'invisible': [('handle_product_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="handle_product_id" string="名称"/>
|
||||
<field name="handle_type_id" string="型号"/>
|
||||
<field name="handle_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="handle_rfid" string="Rfid"/>
|
||||
<field name="scrap_boolean" string="是否报废"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['寿命到期报废','崩刀报废'])], 'readonly': [('state', '=', '已拆解')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="夹头" attrs="{'invisible': [('chuck_product_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="chuck_product_id" string="名称"/>
|
||||
<field name="chuck_type_id" string="型号"/>
|
||||
<field name="chuck_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="chuck_freight_id" string="目标货位"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group attrs="{'invisible': [('integral_product_id', '=', False)]}">
|
||||
<group string="整体式刀具">
|
||||
<group>
|
||||
<field name="integral_product_id" string="名称"/>
|
||||
<field name="integral_type_id" string="型号"/>
|
||||
<field name="integral_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="integral_freight_id" string="目标货位"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')]}"/>
|
||||
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group string="刀片" attrs="{'invisible': [('blade_product_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="blade_product_id" string="名称"/>
|
||||
<field name="blade_type_id" string="型号"/>
|
||||
<field name="blade_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="blade_freight_id" string="目标货位"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="刀杆" attrs="{'invisible': [('bar_product_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="bar_product_id" string="名称"/>
|
||||
<field name="bar_type_id" string="型号"/>
|
||||
<field name="bar_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="bar_freight_id" string="目标货位"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="刀盘" attrs="{'invisible': [('pad_product_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="pad_product_id" string="名称"/>
|
||||
<field name="pad_type_id" string="型号"/>
|
||||
<field name="pad_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="pad_freight_id" string="目标货位"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_functional_tool_dismantle_search" model="ir.ui.view">
|
||||
<field name="model">sf.functional.tool.dismantle</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="functional_tool_id"/>
|
||||
<filter name="no_dismantle_state" string="未拆解" domain="[('state','!=','已拆解')]"/>
|
||||
<filter name="dismantle_state" string="已拆解" domain="[('state','=','已拆解')]"/>
|
||||
<separator/>
|
||||
<filter name="on_active" string="已归档" domain="[('active','=',False)]"/>
|
||||
<searchpanel>
|
||||
<field name="tool_groups_id" enable_counters="1" icon="fa-filter"/>
|
||||
<field name="tool_type_id" enable_counters="1" icon="fa-filter"/>
|
||||
</searchpanel>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_functional_tool_dismantle_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.tool.dismantle</field>
|
||||
<field name="view_mode">tree,form,search</field>
|
||||
<field name="search_view_id" ref="sf_functional_tool_dismantle_search"/>
|
||||
<field name="context">{'search_default_no_dismantle_state':1}</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -94,12 +94,5 @@
|
||||
<field name="res_model">sf.tool.material.search</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
sequence="20"
|
||||
name="刀具物料查询"
|
||||
id="menu_sf_tool_material_search"
|
||||
action="action_sf_tool_material_search"
|
||||
parent="menu_sf_tool_manage"
|
||||
/>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -243,11 +243,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
@api.depends('integral_freight_barcode')
|
||||
def _compute_integral_product_id(self):
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
|
||||
if location:
|
||||
self.integral_product_id = location.product_id.id
|
||||
else:
|
||||
self.integral_product_id = False
|
||||
if self.integral_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
|
||||
if location:
|
||||
self.integral_product_id = location.product_id.id
|
||||
else:
|
||||
self.integral_product_id = False
|
||||
|
||||
# ===============刀片型号====================
|
||||
blade_freight_barcode = fields.Char('刀片货位')
|
||||
@@ -261,11 +262,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
@api.depends('blade_freight_barcode')
|
||||
def _compute_blade_product_id(self):
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
|
||||
if location:
|
||||
self.blade_product_id = location.product_id.id
|
||||
else:
|
||||
self.blade_product_id = False
|
||||
if self.blade_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
|
||||
if location:
|
||||
self.blade_product_id = location.product_id.id
|
||||
else:
|
||||
self.blade_product_id = False
|
||||
|
||||
# ====================刀杆型号==================
|
||||
bar_freight_barcode = fields.Char('刀杆货位')
|
||||
@@ -279,11 +281,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
@api.depends('bar_freight_barcode')
|
||||
def _compute_bar_product_id(self):
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
|
||||
if location:
|
||||
self.bar_product_id = location.product_id.id
|
||||
else:
|
||||
self.bar_product_id = False
|
||||
if self.bar_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
|
||||
if location:
|
||||
self.bar_product_id = location.product_id.id
|
||||
else:
|
||||
self.bar_product_id = False
|
||||
|
||||
# ===============刀盘型号===================
|
||||
pad_freight_barcode = fields.Char('刀盘货位')
|
||||
@@ -297,11 +300,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
@api.depends('pad_freight_barcode')
|
||||
def _compute_pad_product_id(self):
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
|
||||
if location:
|
||||
self.pad_product_id = location.product_id.id
|
||||
else:
|
||||
self.pad_product_id = False
|
||||
if self.pad_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
|
||||
if location:
|
||||
self.pad_product_id = location.product_id.id
|
||||
else:
|
||||
self.pad_product_id = False
|
||||
|
||||
# ================刀柄型号===============
|
||||
handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_rfid')
|
||||
@@ -335,11 +339,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
@api.depends('chuck_freight_barcode')
|
||||
def _compute_chuck_product_id(self):
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
|
||||
if location:
|
||||
self.chuck_product_id = location.product_id.id
|
||||
else:
|
||||
self.chuck_product_id = False
|
||||
if self.chuck_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
|
||||
if location:
|
||||
self.chuck_product_id = location.product_id.id
|
||||
else:
|
||||
self.chuck_product_id = False
|
||||
|
||||
# ========================================
|
||||
|
||||
@@ -398,7 +403,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
after_name_id = fields.Many2one('sf.tool.inventory', string='功能刀具名称', required=True)
|
||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
|
||||
rfid = fields.Char('Rfid', compute='_compute_rfid')
|
||||
tool_code = fields.Char(string='功能刀具编码', compute='_compute_tool_code')
|
||||
code = fields.Char(string='功能刀具编码', compute='_compute_code')
|
||||
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name', store=True)
|
||||
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
|
||||
string='组装后功能刀具类型')
|
||||
@@ -443,7 +448,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
@api.depends('after_assembly_functional_tool_type_id', 'integral_specification_id', 'bar_specification_id',
|
||||
'pad_specification_id', 'handle_specification_id', 'after_assembly_tool_loading_length')
|
||||
def _compute_tool_code(self):
|
||||
def _compute_code(self):
|
||||
for obj in self:
|
||||
str_1 = 'GNDJ-%s' % obj.after_assembly_functional_tool_type_id.code
|
||||
str_2 = ''
|
||||
@@ -462,11 +467,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
obj.pad_specification_id.cut_depth_max, obj.handle_specification_id.total_length,
|
||||
)
|
||||
else:
|
||||
obj.tool_code = str_2
|
||||
obj.code = str_2
|
||||
return True
|
||||
obj.tool_code = str_2 + str(self._get_code(str_2))
|
||||
obj.code = str_2 + str(self._get_code(str_2))
|
||||
else:
|
||||
obj.tool_code = str_2
|
||||
obj.code = str_2
|
||||
|
||||
def _get_code(self, str_2):
|
||||
functional_tool_assembly = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
||||
@@ -613,7 +618,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
def get_desc_1(self, stock_lot):
|
||||
return {
|
||||
'barcode_id': stock_lot.id,
|
||||
'code': self.tool_code,
|
||||
'code': self.code,
|
||||
'rfid': self.rfid,
|
||||
'tool_groups_id': self.after_tool_groups_id.id,
|
||||
'integral_freight_barcode': self.integral_freight_barcode,
|
||||
@@ -650,7 +655,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
def get_desc_2(self, stock_lot, functional_tool_assembly_id):
|
||||
return {
|
||||
'barcode_id': stock_lot.id,
|
||||
'code': self.tool_code,
|
||||
'code': self.code,
|
||||
'name': self.after_name_id.name,
|
||||
'tool_name_id': self.after_name_id.id,
|
||||
'rfid': self.rfid,
|
||||
@@ -713,7 +718,7 @@ class StockPicking(models.Model):
|
||||
'functional_tool_type_id': obj.functional_tool_type_id.id,
|
||||
'diameter': obj.after_assembly_functional_tool_diameter,
|
||||
'knife_tip_r_angle': obj.after_assembly_knife_tip_r_angle,
|
||||
'code': obj.tool_code,
|
||||
'code': obj.code,
|
||||
'rfid': obj.rfid,
|
||||
'functional_tool_name': obj.after_assembly_functional_tool_name,
|
||||
'tool_groups_id': obj.after_tool_groups_id.id
|
||||
@@ -757,7 +762,7 @@ class ProductProduct(models.Model):
|
||||
stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')])
|
||||
# 创建功能刀具该批次/序列号 库存移动和移动历史
|
||||
stock_lot.create_stock_quant(location_inventory_id, stock_location_id, functional_tool_assembly.id,
|
||||
'功能刀具组装', obj)
|
||||
'功能刀具组装', obj, obj.after_tool_groups_id)
|
||||
|
||||
return stock_lot
|
||||
|
||||
@@ -791,7 +796,7 @@ class ProductProduct(models.Model):
|
||||
location_inventory_id = tool_material.quant_ids.location_id[-1]
|
||||
stock_location_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
||||
# 创建功能刀具该批次/序列号 库存移动和移动历史
|
||||
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, False)
|
||||
|
||||
def material_stock_moves(self, shelf_location_barcode):
|
||||
# 创建库存移动记录
|
||||
@@ -814,16 +819,19 @@ class ProductProduct(models.Model):
|
||||
'qty_done': 1.0,
|
||||
'state': 'done',
|
||||
})
|
||||
|
||||
location.product_num = location.product_num - 1
|
||||
|
||||
if location.product_num > 0:
|
||||
location.product_num = location.product_num - 1
|
||||
else:
|
||||
raise ValidationError(
|
||||
'【%s】货位的【%s】产品库存数量为零,请采购入库后再重新组装!' % (location.barcode, location.product_id.name))
|
||||
return stock_move_id, stock_move_line_id
|
||||
|
||||
|
||||
class StockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
|
||||
def create_stock_quant(self, location_inventory_id, stock_location_id, functional_tool_assembly_id, name, obj):
|
||||
def create_stock_quant(self, location_inventory_id, stock_location_id, functional_tool_assembly_id, name, obj,
|
||||
tool_groups_id):
|
||||
"""
|
||||
对功能刀具组装过程的功能刀具和刀具物料进行库存移动,以及创建移动历史
|
||||
"""
|
||||
@@ -850,10 +858,10 @@ class StockLot(models.Model):
|
||||
'functional_tool_type_id': False if not obj else obj.functional_tool_type_id.id,
|
||||
'diameter': None if not obj else obj.after_assembly_functional_tool_diameter,
|
||||
'knife_tip_r_angle': None if not obj else obj.after_assembly_knife_tip_r_angle,
|
||||
'code': '' if not obj else obj.tool_code,
|
||||
'code': '' if not obj else obj.code,
|
||||
'rfid': '' if not obj else obj.rfid,
|
||||
'functional_tool_name': '' if not obj else obj.after_assembly_functional_tool_name,
|
||||
'tool_groups_id': False if not obj else obj.after_tool_groups_id.id
|
||||
'tool_groups_id': False if not tool_groups_id else tool_groups_id.id
|
||||
})
|
||||
return stock_move_id, stock_move_line_id
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="barcode_id" invisible="True"/>
|
||||
<field name="tool_code" readonly="True"/>
|
||||
<field name="code" readonly="True"/>
|
||||
<field name="rfid" class="custom_required"/>
|
||||
<field name="after_name_id" string="功能刀具名称" placeholder="请选择功能刀具名称"
|
||||
options="{'no_create': True, 'no_quick_create': True}"/>
|
||||
|
||||
Reference in New Issue
Block a user