Compare commits
39 Commits
master_sf_
...
release/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ad7e72b15 | ||
|
|
07c7ed6dba | ||
|
|
42cded8c64 | ||
|
|
469839f38e | ||
|
|
7d7f0348d2 | ||
|
|
bae947bdca | ||
|
|
14d823ab6e | ||
|
|
ae953c7ad6 | ||
|
|
2065625cd6 | ||
|
|
206fc7bb21 | ||
|
|
07b1c3cceb | ||
|
|
f9c697d2a7 | ||
|
|
2eaec4fa58 | ||
|
|
8a1a06c3ad | ||
|
|
f4926820fe | ||
|
|
2055d70e27 | ||
|
|
5361fa7678 | ||
|
|
edf8e1004e | ||
|
|
17e2a3ffc3 | ||
|
|
7a539d7916 | ||
|
|
e258e43b51 | ||
|
|
d2f4e5495e | ||
|
|
ba2b833aa8 | ||
|
|
cf0afd6c64 | ||
|
|
b6acbb8357 | ||
|
|
19799aefe4 | ||
|
|
d47dcc7611 | ||
|
|
f33d7b79fc | ||
|
|
3882d3a3cb | ||
|
|
e9ab57854e | ||
|
|
b70ec36365 | ||
|
|
67c4f64d08 | ||
|
|
3738b8d72b | ||
|
|
5fb9326d8b | ||
|
|
2ab9f37062 | ||
|
|
a7102c81d4 | ||
|
|
7d6fb4f0e3 | ||
|
|
1d4aaa40cd | ||
|
|
683e9631fa |
@@ -31,9 +31,11 @@
|
|||||||
options="{'no_create': True}"
|
options="{'no_create': True}"
|
||||||
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}"
|
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}"
|
||||||
placeholder="请选择"/>
|
placeholder="请选择"/>
|
||||||
|
<field name="brand_id" options="{'no_create': True}" placeholder="请选择"
|
||||||
|
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}"/>
|
||||||
<field name="cutting_tool_model_id" placeholder="请选择" class="custom_required"
|
<field name="cutting_tool_model_id" placeholder="请选择" class="custom_required"
|
||||||
options="{'no_create': True}"
|
options="{'no_create': True}"
|
||||||
domain="[('cutting_tool_material_id','=',cutting_tool_material_id)]"
|
domain="[('cutting_tool_material_id','=',cutting_tool_material_id),('brand_id', '=', brand_id)]"
|
||||||
context="{'default_cutting_tool_material_id': cutting_tool_material_id}"
|
context="{'default_cutting_tool_material_id': cutting_tool_material_id}"
|
||||||
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}">
|
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}">
|
||||||
</field>
|
</field>
|
||||||
@@ -47,10 +49,10 @@
|
|||||||
<field name="fixture_material_id"
|
<field name="fixture_material_id"
|
||||||
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
||||||
placeholder="请选择" options="{'no_create': True}"/>
|
placeholder="请选择" options="{'no_create': True}"/>
|
||||||
<field name="fixture_model_id" string="型号" placeholder="请选择" options="{'no_create': True}"
|
<field name="fixture_model_id" string="型号名称" placeholder="请选择" options="{'no_create': True}"
|
||||||
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
||||||
domain="[('fixture_material_id','=',fixture_material_id)]"/>
|
domain="[('fixture_material_id','=',fixture_material_id)]"/>
|
||||||
<field name="specification_fixture_id" string="规格" placeholder="请选择"
|
<field name="specification_fixture_id" string="物料号" placeholder="请选择"
|
||||||
options="{'no_create': True}"
|
options="{'no_create': True}"
|
||||||
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
||||||
domain="[('fixture_model_id','=',fixture_model_id)]"/>
|
domain="[('fixture_model_id','=',fixture_model_id)]"/>
|
||||||
@@ -95,6 +97,16 @@
|
|||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='name']" position="attributes">
|
||||||
|
<attribute name="attrs">{'readonly': ['|',('id','!=',False),('categ_type', '=',
|
||||||
|
'刀具')], 'required': True}
|
||||||
|
</attribute>
|
||||||
|
</xpath>
|
||||||
|
<!-- <xpath expr="//field[@name='default_code']" position="attributes">-->
|
||||||
|
<!-- <attribute name="attrs">{'readonly': [('categ_type', '=', '刀具')], 'invisible':-->
|
||||||
|
<!-- [('product_variant_count', '>' , 1)]}-->
|
||||||
|
<!-- </attribute>-->
|
||||||
|
<!-- </xpath>-->
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -455,7 +467,8 @@
|
|||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<!-- <field name="cutting_speed"-->
|
<!-- <field name="cutting_speed"-->
|
||||||
<!-- attrs="{'readonly': [('materials_type_id','!=',False)]}"/>-->
|
<!-- attrs="{'readonly': [('materials_type_id','!=',False)]}"/>-->
|
||||||
<field name="materials_type_id" options="{'no_create': True}" placeholder="请选择"/>
|
<field name="materials_type_id" options="{'no_create': True}"
|
||||||
|
placeholder="请选择"/>
|
||||||
<field name="blade_diameter"/>
|
<field name="blade_diameter"/>
|
||||||
<field name="feed_per_tooth"/>
|
<field name="feed_per_tooth"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|||||||
@@ -166,11 +166,13 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
if not workorder:
|
if not workorder:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'}
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
logging.info('workorder_state:%s' % workorder.state)
|
||||||
if workorder.state != 'ready':
|
if workorder.state != 'ready':
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '工单未就绪'}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '工单未就绪'}
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
work_equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', equipment_id)],
|
work_equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', equipment_id)],
|
||||||
limit=1)
|
limit=1)
|
||||||
|
logging.info('work_equipment_id:%s' % work_equipment_id.name)
|
||||||
if not work_equipment_id:
|
if not work_equipment_id:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有找到该加工设备'}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有找到该加工设备'}
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
@@ -457,20 +459,21 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
rfid_code = ret[f'RfidCode{i}']
|
rfid_code = ret[f'RfidCode{i}']
|
||||||
logging.info('RfidCode:%s' % rfid_code)
|
logging.info('RfidCode:%s' % rfid_code)
|
||||||
domain = [
|
domain = [
|
||||||
('feeder_station_destination_id.name', '=', ret['DeviceId']),
|
('rfid_code', '=', rfid_code),
|
||||||
('workorder_id.rfid_code', '=', rfid_code),
|
('routing_type', '=', 'CNC加工')
|
||||||
('status', '=', '已配送'),
|
|
||||||
('type', '=', '上产线')
|
|
||||||
]
|
]
|
||||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain,
|
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
|
||||||
order='id asc')
|
if workorder:
|
||||||
if workpiece_delivery:
|
for order in workorder:
|
||||||
for wd in workpiece_delivery:
|
if order.production_id.production_line_state == '待上产线':
|
||||||
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(
|
logging.info(
|
||||||
'wd.production_line_state:%s' % wd.production_id.production_line_state)
|
'制造订单产线状态:%s' % order.production_id.production_line_state)
|
||||||
wd.production_id.write({'production_line_state': '已上产线'})
|
order.production_id.write({'production_line_state': '已上产线'})
|
||||||
|
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search([
|
||||||
|
('rfid_code', '=', rfid_code), ('type', '=', '上产线'),
|
||||||
|
('production_id', '=', order.production_id.id)])
|
||||||
|
if workpiece_delivery.status == '待下发':
|
||||||
|
workpiece_delivery.write({'is_manual_work': True})
|
||||||
else:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 204,
|
res = {'Succeed': False, 'ErrorCode': 204,
|
||||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||||
@@ -511,20 +514,20 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
rfid_code = ret[f'RfidCode{i}']
|
rfid_code = ret[f'RfidCode{i}']
|
||||||
logging.info('RfidCode:%s' % rfid_code)
|
logging.info('RfidCode:%s' % rfid_code)
|
||||||
domain = [
|
domain = [
|
||||||
('workorder_id.rfid_code', '=', rfid_code),
|
('rfid_code', '=', rfid_code),
|
||||||
('status', '=', '待下发'),
|
('routing_type', '=', 'CNC加工')
|
||||||
('type', '=', '下产线')
|
|
||||||
]
|
]
|
||||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain,
|
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
|
||||||
order='id asc')
|
if workorder:
|
||||||
if workpiece_delivery:
|
for order in workorder:
|
||||||
for wd in workpiece_delivery:
|
if order.production_id.production_line_state == '已上产线':
|
||||||
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(
|
logging.info(
|
||||||
'wd.production_line_state:%s' % wd.production_id.production_line_state)
|
'制造订单产线状态:%s' % order.production_id.production_line_state)
|
||||||
wd.production_id.write({'production_line_state': '已下产线'})
|
order.production_id.write({'production_line_state': '已下产线'})
|
||||||
delivery_Arr.append(wd.id)
|
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search([
|
||||||
|
('rfid_code', '=', rfid_code), ('type', '=', '下产线'),
|
||||||
|
('production_id', '=', order.production_id.id)])
|
||||||
|
delivery_Arr.append(workpiece_delivery.id)
|
||||||
else:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 204,
|
res = {'Succeed': False, 'ErrorCode': 204,
|
||||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||||
@@ -534,10 +537,14 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
[('id', 'in', delivery_Arr)])
|
[('id', 'in', delivery_Arr)])
|
||||||
if delivery_workpiece:
|
if delivery_workpiece:
|
||||||
logging.info('开始向agv下发下产线任务')
|
logging.info('开始向agv下发下产线任务')
|
||||||
is_free = delivery_workpiece._check_avgsite_state()
|
agv_site = request.env['sf.agv.site'].sudo().search([])
|
||||||
if is_free is True:
|
if agv_site:
|
||||||
delivery_workpiece._delivery_avg()
|
has_site = agv_site.update_site_state()
|
||||||
logging.info('agv下发下产线任务下发完成')
|
if has_site is True:
|
||||||
|
is_free = delivery_workpiece._check_avgsite_state()
|
||||||
|
if is_free is True:
|
||||||
|
delivery_workpiece._delivery_avg()
|
||||||
|
logging.info('agv下发下产线任务下发完成')
|
||||||
else:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -26,20 +26,28 @@ class AgvSetting(models.Model):
|
|||||||
timestamp = int(time.time())
|
timestamp = int(time.time())
|
||||||
center_control_url += str(timestamp)
|
center_control_url += str(timestamp)
|
||||||
logging.info('工件配送-请求中控地址:%s' % center_control_url)
|
logging.info('工件配送-请求中控地址:%s' % center_control_url)
|
||||||
center_control_r = requests.get(center_control_url, params={}, headers=headers)
|
try:
|
||||||
ret = center_control_r.json()
|
center_control_r = requests.get(center_control_url, headers=headers, timeout=10) # 设置超时为60秒
|
||||||
logging.info('工件配送-请求中控站点信息:%s' % ret)
|
ret = center_control_r.json()
|
||||||
self.env['center_control.interface.log'].sudo().create(
|
logging.info('工件配送-请求中控站点信息:%s' % ret)
|
||||||
{'content': ret, 'name': 'AutoDeviceApi/GetAgvStationState?date=%s' % str(timestamp)})
|
self.env['center_control.interface.log'].sudo().create(
|
||||||
if ret['Succeed'] is True:
|
{'content': ret, 'name': 'AutoDeviceApi/GetAgvStationState?date=%s' % str(timestamp)})
|
||||||
datas = ret['Datas']
|
if ret['Succeed'] is True:
|
||||||
for item in self:
|
datas = ret['Datas']
|
||||||
for da in datas:
|
for item in self:
|
||||||
if da['DeviceId'] == item.name:
|
for da in datas:
|
||||||
if da['AtHome'] is True:
|
if da['DeviceId'] == item.name:
|
||||||
item.state = '占用'
|
if da['AtHome'] is True:
|
||||||
else:
|
item.state = '占用'
|
||||||
item.state = '空闲'
|
else:
|
||||||
|
item.state = '空闲'
|
||||||
|
return True
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
logging.error('工件配送-请求中控接口超时')
|
||||||
|
return False
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
logging.error('工件配送-请求中控接口错误: %s', e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class AgvTaskRoute(models.Model):
|
class AgvTaskRoute(models.Model):
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
('已完工', '已完工'),
|
('已完工', '已完工'),
|
||||||
], string='工序状态', default='待装夹', readonly='True')
|
], string='工序状态', default='待装夹', readonly='True')
|
||||||
# 加工图纸
|
# 加工图纸
|
||||||
processing_drawing = fields.Binary(string='加工图纸', related='production_id.part_drawing')
|
processing_drawing = fields.Binary(string='加工图纸')
|
||||||
|
|
||||||
@api.depends('production_id')
|
@api.depends('production_id')
|
||||||
def _compute_save_name(self):
|
def _compute_save_name(self):
|
||||||
@@ -1039,10 +1039,8 @@ class CNCprocessing(models.Model):
|
|||||||
for f in files:
|
for f in files:
|
||||||
if os.path.splitext(f)[1] == ".pdf":
|
if os.path.splitext(f)[1] == ".pdf":
|
||||||
full_path = os.path.join(serverdir, root, f)
|
full_path = os.path.join(serverdir, root, f)
|
||||||
if full_path is not False:
|
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
||||||
if not cnc_processing.workorder_id.cnc_worksheet:
|
open(full_path, 'rb').read())
|
||||||
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
|
||||||
open(full_path, 'rb').read())
|
|
||||||
else:
|
else:
|
||||||
if f in program_path:
|
if f in program_path:
|
||||||
# if cnc_processing.program_name == f.split('.')[0]:
|
# if cnc_processing.program_name == f.split('.')[0]:
|
||||||
@@ -1229,15 +1227,25 @@ class WorkPieceDelivery(models.Model):
|
|||||||
status = fields.Selection(
|
status = fields.Selection(
|
||||||
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发')
|
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发')
|
||||||
is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
|
is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
|
||||||
|
is_manual_work = fields.Boolean('人工操作', default=False)
|
||||||
active = fields.Boolean(string="有效", default=True)
|
active = fields.Boolean(string="有效", default=True)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
if vals.get('name', '/') == '/' or vals.get('name', '/') is False:
|
if vals.get('name', '/') == '/' or vals.get('name', '/') is False:
|
||||||
vals['name'] = self.env['ir.sequence'].next_by_code('sf.workpiece.delivery') or '/'
|
vals['name'] = self.env['ir.sequence'].next_by_code('sf.workpiece.delivery') or '/'
|
||||||
|
else:
|
||||||
|
vals['type'] = '运送空料架'
|
||||||
obj = super(WorkPieceDelivery, self).create(vals)
|
obj = super(WorkPieceDelivery, self).create(vals)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
@api.constrains('name')
|
||||||
|
def _check_name(self):
|
||||||
|
if self.type == '运送空料架':
|
||||||
|
wd = self.sudo().search([('name', '=', self.name), ('id', '!=', self.id)])
|
||||||
|
if wd:
|
||||||
|
raise UserError("该名称已存在")
|
||||||
|
|
||||||
def action_delivery_history(self):
|
def action_delivery_history(self):
|
||||||
return {
|
return {
|
||||||
'name': _('配送历史'),
|
'name': _('配送历史'),
|
||||||
@@ -1287,6 +1295,8 @@ class WorkPieceDelivery(models.Model):
|
|||||||
is_not_route += 1
|
is_not_route += 1
|
||||||
# else:
|
# else:
|
||||||
# raise UserError('请选择【任务路线】再进行配送')
|
# raise UserError('请选择【任务路线】再进行配送')
|
||||||
|
# if item.production_id.production_line_state == '已下产线' and item.state == '待下发' and item.type == '下产线':
|
||||||
|
# raise UserError('该制造订单已下产线,无需配送')
|
||||||
if production_type != item.type:
|
if production_type != item.type:
|
||||||
raise UserError('请选择类型为%s的制造订单进行配送' % production_type)
|
raise UserError('请选择类型为%s的制造订单进行配送' % production_type)
|
||||||
if down_status != item.status:
|
if down_status != item.status:
|
||||||
@@ -1340,22 +1350,25 @@ class WorkPieceDelivery(models.Model):
|
|||||||
is_free = False
|
is_free = False
|
||||||
agv_site = self.env['sf.agv.site'].search([])
|
agv_site = self.env['sf.agv.site'].search([])
|
||||||
if agv_site:
|
if agv_site:
|
||||||
agv_site.update_site_state()
|
has_site = agv_site.update_site_state()
|
||||||
for item in self:
|
if has_site is True:
|
||||||
logging.info('工件配送-起点状态:%s-%s' % (
|
for item in self:
|
||||||
item.feeder_station_start_id.name, item.feeder_station_start_id.state))
|
if item.type in ['上产线', '下产线']:
|
||||||
logging.info('工件配送-终点状态:%s-%s' % (
|
logging.info('工件配送-起点状态:%s-%s' % (
|
||||||
item.feeder_station_destination_id.name, item.feeder_station_destination_id.state))
|
item.feeder_station_start_id.name, item.feeder_station_start_id.state))
|
||||||
if item.type in ['上产线', '下产线']:
|
logging.info('工件配送-终点状态:%s-%s' % (
|
||||||
if (
|
item.feeder_station_destination_id.name, item.feeder_station_destination_id.state))
|
||||||
item.feeder_station_start_id.state == '占用' and item.feeder_station_destination_id.state == '空闲') or (
|
if (
|
||||||
item.feeder_station_start_id.state == '空闲' and item.feeder_station_destination_id.state == '空闲'):
|
item.feeder_station_start_id.state == '占用' and item.feeder_station_destination_id.state == '空闲') or (
|
||||||
is_free = True
|
item.feeder_station_start_id.state == '空闲' and item.feeder_station_destination_id.state == '空闲'):
|
||||||
|
is_free = True
|
||||||
|
else:
|
||||||
|
if item.feeder_station_destination_id.state == '空闲':
|
||||||
|
is_free = True
|
||||||
|
logging.info('is_free:%s' % is_free)
|
||||||
|
return is_free
|
||||||
else:
|
else:
|
||||||
if item.feeder_station_destination_id.state == '空闲':
|
raise UserError("接驳站暂未反馈站点实时状态,请稍后再试")
|
||||||
is_free = True
|
|
||||||
logging.info('is_free:%s' % is_free)
|
|
||||||
return is_free
|
|
||||||
|
|
||||||
# 配送至avg小车
|
# 配送至avg小车
|
||||||
def _delivery_avg(self):
|
def _delivery_avg(self):
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ class ResProductMo(models.Model):
|
|||||||
cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', string='刀具物料')
|
cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', string='刀具物料')
|
||||||
cutting_tool_type = fields.Char(string="刀具物料类型", related='cutting_tool_material_id.name', store=True)
|
cutting_tool_type = fields.Char(string="刀具物料类型", related='cutting_tool_material_id.name', store=True)
|
||||||
|
|
||||||
cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='型号')
|
cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='型号名称')
|
||||||
specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='规格')
|
specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='物料号')
|
||||||
|
|
||||||
cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='类型',
|
cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='类型',
|
||||||
domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]")
|
domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]")
|
||||||
@@ -104,6 +104,15 @@ class ResProductMo(models.Model):
|
|||||||
compaction_way_id = fields.Many2one('maintenance.equipment.image',
|
compaction_way_id = fields.Many2one('maintenance.equipment.image',
|
||||||
'压紧方式', domain=[('type', '=', '压紧方式')])
|
'压紧方式', domain=[('type', '=', '压紧方式')])
|
||||||
|
|
||||||
|
name = fields.Char('产品名称', compute='_compute_tool_name', store=True, required=False)
|
||||||
|
|
||||||
|
@api.depends('cutting_tool_model_id', 'specification_id')
|
||||||
|
def _compute_tool_name(self):
|
||||||
|
for item in self:
|
||||||
|
if item.cutting_tool_model_id and item.specification_id:
|
||||||
|
name = '%s%s' % (item.cutting_tool_model_id.name, item.specification_id.name)
|
||||||
|
item.name = name
|
||||||
|
|
||||||
@api.onchange('cutting_tool_model_id')
|
@api.onchange('cutting_tool_model_id')
|
||||||
def _onchange_cutting_tool_model_id(self):
|
def _onchange_cutting_tool_model_id(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
@@ -721,6 +730,10 @@ class ResProductMo(models.Model):
|
|||||||
logging.info('create-model_file:%s' % len(vals['model_file']))
|
logging.info('create-model_file:%s' % len(vals['model_file']))
|
||||||
self._sanitize_vals(vals)
|
self._sanitize_vals(vals)
|
||||||
templates = super(ResProductMo, self).create(vals_list)
|
templates = super(ResProductMo, self).create(vals_list)
|
||||||
|
# 产品名称唯一性校验
|
||||||
|
for item in templates:
|
||||||
|
if len(self.search([('name', '=', item.name)])) > 1:
|
||||||
|
raise ValidationError('产品名称【%s】已存在' % item.name)
|
||||||
if "create_product_product" not in self._context:
|
if "create_product_product" not in self._context:
|
||||||
templates._create_variant_ids()
|
templates._create_variant_ids()
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import base64
|
|||||||
import qrcode
|
import qrcode
|
||||||
from collections import defaultdict, namedtuple
|
from collections import defaultdict, namedtuple
|
||||||
import logging
|
import logging
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
from re import split as regex_split
|
from re import split as regex_split
|
||||||
from re import findall as regex_findall
|
from re import findall as regex_findall
|
||||||
@@ -492,7 +493,7 @@ class StockPicking(models.Model):
|
|||||||
|
|
||||||
# 设置外协出入单的名称
|
# 设置外协出入单的名称
|
||||||
def _get_name_Res(self, rescode):
|
def _get_name_Res(self, rescode):
|
||||||
last_picking = self.sudo().search([('name', 'like', rescode)], order='create_date DESC', limit=1)
|
last_picking = self.sudo().search([('name', 'like', rescode)], order='create_date desc,id desc', limit=1)
|
||||||
if not last_picking:
|
if not last_picking:
|
||||||
num = "%04d" % 1
|
num = "%04d" % 1
|
||||||
else:
|
else:
|
||||||
@@ -668,12 +669,14 @@ class ReStockMove(models.Model):
|
|||||||
else:
|
else:
|
||||||
view = self.env.ref('stock.view_stock_move_nosuggest_operations')
|
view = self.env.ref('stock.view_stock_move_nosuggest_operations')
|
||||||
|
|
||||||
if self.product_id.tracking == "serial" and self.state == "assigned":
|
if self.state == "assigned":
|
||||||
print(self.origin)
|
if self.product_id.tracking == "serial":
|
||||||
if self.product_id.categ_id.name == '刀具':
|
if self.product_id.categ_id.name == '刀具':
|
||||||
self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
|
self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
|
||||||
else:
|
else:
|
||||||
self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
|
self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
|
||||||
|
elif self.product_id.tracking == "lot":
|
||||||
|
self._put_tool_lot(self.company_id, self.product_id, self.origin)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'name': _('Detailed Operations'),
|
'name': _('Detailed Operations'),
|
||||||
@@ -698,6 +701,35 @@ class ReStockMove(models.Model):
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _put_tool_lot(self, company, product, origin):
|
||||||
|
if product.tracking == "lot" and self.product_id.categ_id.name == '刀具':
|
||||||
|
if not self.move_line_nosuggest_ids:
|
||||||
|
lot_names = self.env['stock.lot'].generate_lot_names(
|
||||||
|
'%s-%s-%s' % ('%s-T-DJWL-%s' % (
|
||||||
|
product.cutting_tool_model_id.code.split('-')[0], product.cutting_tool_material_id.code),
|
||||||
|
datetime.now().strftime("%Y%m%d"), origin), 1)
|
||||||
|
move_lines_commands = self._generate_serial_move_line_commands_tool_lot(lot_names)
|
||||||
|
self.write({'move_line_nosuggest_ids': move_lines_commands})
|
||||||
|
for item in self.move_line_nosuggest_ids:
|
||||||
|
if item.lot_name:
|
||||||
|
item.lot_qr_code = self.compute_lot_qr_code(item.lot_name)
|
||||||
|
|
||||||
|
def compute_lot_qr_code(self, lot_name):
|
||||||
|
qr = qrcode.QRCode(
|
||||||
|
version=1,
|
||||||
|
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
||||||
|
box_size=10,
|
||||||
|
border=4,
|
||||||
|
)
|
||||||
|
qr.add_data(lot_name)
|
||||||
|
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()
|
||||||
|
data = base64.b64encode(binary_data).decode() # 确保返回的是字符串形式的数据
|
||||||
|
return data
|
||||||
|
|
||||||
def _get_tool_next_serial(self, company, product, origin):
|
def _get_tool_next_serial(self, company, product, origin):
|
||||||
"""Return the next serial number to be attributed to the product."""
|
"""Return the next serial number to be attributed to the product."""
|
||||||
if product.tracking == "serial":
|
if product.tracking == "serial":
|
||||||
@@ -711,6 +743,67 @@ class ReStockMove(models.Model):
|
|||||||
else:
|
else:
|
||||||
return "%s-T-%s-%s-%03d" % (split_codes[0], origin, product.specification_id.name, 1)
|
return "%s-T-%s-%s-%03d" % (split_codes[0], origin, product.specification_id.name, 1)
|
||||||
|
|
||||||
|
def _generate_serial_move_line_commands_tool_lot(self, lot_names, origin_move_line=None):
|
||||||
|
"""Return a list of commands to update the move lines (write on
|
||||||
|
existing ones or create new ones).
|
||||||
|
Called when user want to create and assign multiple serial numbers in
|
||||||
|
one time (using the button/wizard or copy-paste a list in the field).
|
||||||
|
|
||||||
|
:param lot_names: A list containing all serial number to assign.
|
||||||
|
:type lot_names: list
|
||||||
|
:param origin_move_line: A move line to duplicate the value from, default to None
|
||||||
|
:type origin_move_line: record of :class:`stock.move.line`
|
||||||
|
:return: A list of commands to create/update :class:`stock.move.line`
|
||||||
|
:rtype: list
|
||||||
|
"""
|
||||||
|
self.ensure_one()
|
||||||
|
|
||||||
|
# Select the right move lines depending of the picking type configuration.
|
||||||
|
move_lines = self.env['stock.move.line']
|
||||||
|
if self.picking_type_id.show_reserved:
|
||||||
|
move_lines = self.move_line_ids.filtered(lambda ml: not ml.lot_id and not ml.lot_name)
|
||||||
|
else:
|
||||||
|
move_lines = self.move_line_nosuggest_ids.filtered(lambda ml: not ml.lot_id and not ml.lot_name)
|
||||||
|
|
||||||
|
loc_dest = origin_move_line and origin_move_line.location_dest_id
|
||||||
|
move_line_vals = {
|
||||||
|
'picking_id': self.picking_id.id,
|
||||||
|
'location_id': self.location_id.id,
|
||||||
|
'product_id': self.product_id.id,
|
||||||
|
'product_uom_id': self.product_id.uom_id.id,
|
||||||
|
'qty_done': self.product_uom_qty,
|
||||||
|
}
|
||||||
|
if origin_move_line:
|
||||||
|
# `owner_id` and `package_id` are taken only in the case we create
|
||||||
|
# new move lines from an existing move line. Also, updates the
|
||||||
|
# `qty_done` because it could be usefull for products tracked by lot.
|
||||||
|
move_line_vals.update({
|
||||||
|
'owner_id': origin_move_line.owner_id.id,
|
||||||
|
'package_id': origin_move_line.package_id.id,
|
||||||
|
'qty_done': origin_move_line.qty_done or 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
move_lines_commands = []
|
||||||
|
qty_by_location = defaultdict(float)
|
||||||
|
for lot_name in lot_names:
|
||||||
|
# We write the lot name on an existing move line (if we have still one)...
|
||||||
|
if move_lines:
|
||||||
|
move_lines_commands.append((1, move_lines[0].id, {
|
||||||
|
'lot_name': lot_name,
|
||||||
|
'qty_done': 1,
|
||||||
|
}))
|
||||||
|
qty_by_location[move_lines[0].location_dest_id.id] += 1
|
||||||
|
move_lines = move_lines[1:]
|
||||||
|
# ... or create a new move line with the serial name.
|
||||||
|
else:
|
||||||
|
loc = loc_dest or self.location_dest_id._get_putaway_strategy(self.product_id, quantity=1,
|
||||||
|
packaging=self.product_packaging_id,
|
||||||
|
additional_qty=qty_by_location)
|
||||||
|
move_line_cmd = dict(move_line_vals, lot_name=lot_name, location_dest_id=loc.id)
|
||||||
|
move_lines_commands.append((0, 0, move_line_cmd))
|
||||||
|
qty_by_location[loc.id] += 1
|
||||||
|
return move_lines_commands
|
||||||
|
|
||||||
|
|
||||||
class ReStockQuant(models.Model):
|
class ReStockQuant(models.Model):
|
||||||
_inherit = 'stock.quant'
|
_inherit = 'stock.quant'
|
||||||
|
|||||||
@@ -659,7 +659,9 @@
|
|||||||
<field name="search_view_id" ref="sf_workpiece_delivery_search"/>
|
<field name="search_view_id" ref="sf_workpiece_delivery_search"/>
|
||||||
<field name="context">{'search_default_on_up':1}</field>
|
<field name="context">{'search_default_on_up':1}</field>
|
||||||
<field name="view_mode">tree,search</field>
|
<field name="view_mode">tree,search</field>
|
||||||
<field name="domain">[('type','in',['上产线','下产线']),('workorder_state','=','done')]</field>
|
<field name="domain">
|
||||||
|
[('type','in',['上产线','下产线']),('workorder_state','=','done'),('is_manual_work','=',false)]
|
||||||
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
@@ -668,14 +670,18 @@
|
|||||||
<field name="name">空料架配送</field>
|
<field name="name">空料架配送</field>
|
||||||
<field name="model">sf.workpiece.delivery</field>
|
<field name="model">sf.workpiece.delivery</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="工件配送" class="center" create="0" edit="0" delete="0">
|
<tree string="工件配送" editable="bottom" class="center" delete="0" create="1">
|
||||||
<header>
|
<header>
|
||||||
<button name="button_delivery" type="object" string="配送" class="oe_highlight"/>
|
<button name="button_delivery" type="object" string="配送" class="oe_highlight"/>
|
||||||
</header>
|
</header>
|
||||||
<field name="name" string="路线名称" readonly="1"/>
|
<field name="name" string="路线名称" attrs="{'readonly': [('id', '!=', False)]}"
|
||||||
<field name="route_id" options="{'no_create': True}"/>
|
placeholder="例如:运送空料架路线:G01-A01" required="1" force_save="1"/>
|
||||||
<field name="feeder_station_start_id" readonly="1"/>
|
<field name="route_id" options="{'no_create': True}" required="1"
|
||||||
<field name="feeder_station_destination_id" readonly="1"/>
|
attrs="{'readonly': [('id', '!=', False)]}" domain="[('route_type', '=', '运送空料架')]"
|
||||||
|
force_save="1"/>
|
||||||
|
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
||||||
|
<!-- <field name="type" readonly="1"/>-->
|
||||||
|
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
|
||||||
<button name="action_delivery_history" type="object" class="btn btn-link text-info" icon="fa-history"
|
<button name="action_delivery_history" type="object" class="btn btn-link text-info" icon="fa-history"
|
||||||
string="历史"/>
|
string="历史"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|||||||
@@ -24,12 +24,22 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
ret = json.loads(ret['result'])
|
ret = json.loads(ret['result'])
|
||||||
logging.info('下发编程单:%s' % ret)
|
logging.info('下发编程单:%s' % ret)
|
||||||
|
is_delete_file = False
|
||||||
# 查询状态为进行中且类型为获取CNC加工程序的工单
|
# 查询状态为进行中且类型为获取CNC加工程序的工单
|
||||||
cnc_production = request.env['mrp.production'].with_user(
|
cnc_production = request.env['mrp.production'].with_user(
|
||||||
request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'].split(',')[0])])
|
request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'].split(',')[0])])
|
||||||
cnc_program = request.env['mrp.production'].with_user(
|
cnc_program = request.env['mrp.production'].with_user(
|
||||||
request.env.ref("base.user_admin")).search(
|
request.env.ref("base.user_admin")).search(
|
||||||
[('programming_no', '=', cnc_production.programming_no), ('id', '!=', cnc_production.id)])
|
[('programming_no', '=', cnc_production.programming_no), ('id', '!=', cnc_production.id)])
|
||||||
|
if cnc_production.workorder_ids.filtered(lambda a: a.routing_type == 'CNC加工').cnc_ids:
|
||||||
|
is_delete_file = True
|
||||||
|
cnc_production.workorder_ids.filtered(
|
||||||
|
lambda a1: a1.routing_type == 'CNC加工').cnc_ids.sudo().unlink()
|
||||||
|
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_production)
|
||||||
|
if cnc_program.workorder_ids.filtered(lambda c: c.routing_type == 'CNC加工').cnc_ids:
|
||||||
|
cnc_program.workorder_ids.filtered(
|
||||||
|
lambda c1: c1.routing_type == 'CNC加工').cnc_ids.sudo().unlink()
|
||||||
|
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_program)
|
||||||
# cnc_program = request.env['mrp.production'].with_user(
|
# cnc_program = request.env['mrp.production'].with_user(
|
||||||
# request.env.ref("base.user_admin")).search([('programming_no', '=', cnc_production.programming_no)])
|
# request.env.ref("base.user_admin")).search([('programming_no', '=', cnc_production.programming_no)])
|
||||||
logging.info('制造订单号:%s' % cnc_production.name)
|
logging.info('制造订单号:%s' % cnc_production.name)
|
||||||
@@ -37,6 +47,13 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
# if ret['glb_file']:
|
# if ret['glb_file']:
|
||||||
# cnc_production.glb_file = base64.b64encode(ret['glb_file'])
|
# cnc_production.glb_file = base64.b64encode(ret['glb_file'])
|
||||||
# 拉取所有加工面的程序文件
|
# 拉取所有加工面的程序文件
|
||||||
|
if is_delete_file is True:
|
||||||
|
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', 'R')
|
||||||
|
files_r = os.listdir(program_path_tmp_r)
|
||||||
|
if files_r:
|
||||||
|
for file_name in files_r:
|
||||||
|
file_path = os.path.join(program_path_tmp_r, file_name)
|
||||||
|
os.remove(file_path)
|
||||||
for r in ret['processing_panel']:
|
for r in ret['processing_panel']:
|
||||||
download_state = request.env['sf.cnc.processing'].with_user(
|
download_state = request.env['sf.cnc.processing'].with_user(
|
||||||
request.env.ref("base.user_admin")).download_file_tmp(
|
request.env.ref("base.user_admin")).download_file_tmp(
|
||||||
@@ -64,12 +81,17 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
if cnc_processing:
|
if cnc_processing:
|
||||||
cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing))
|
cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing))
|
||||||
if (cnc_program and cnc_processing_arr) or (not cnc_program and cnc_processing_arr):
|
if (cnc_program and cnc_processing_arr) or (not cnc_program and cnc_processing_arr):
|
||||||
logging.info('cnc_processing_arr:%s' % cnc_processing_arr)
|
cnc_production.workorder_ids.filtered(lambda g: g.routing_type == '装夹预调').write(
|
||||||
|
{'processing_drawing': cnc_production.workorder_ids.filtered(
|
||||||
|
lambda g1: g1.routing_type == 'CNC加工').cnc_worksheet})
|
||||||
if cnc_program and cnc_processing_arr:
|
if cnc_program and cnc_processing_arr:
|
||||||
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
|
cnc_program.workorder_ids.filtered(lambda d: d.routing_type == '装夹预调').write(
|
||||||
|
{'processing_drawing': cnc_production.workorder_ids.filtered(
|
||||||
|
lambda d1: d1.routing_type == 'CNC加工').cnc_worksheet})
|
||||||
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
||||||
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
||||||
lambda b: b.routing_type == 'CNC加工').cnc_worksheet})
|
lambda b1: b1.routing_type == 'CNC加工').cnc_worksheet})
|
||||||
cnc_program |= cnc_production
|
cnc_program |= cnc_production
|
||||||
if not cnc_program and cnc_processing_arr:
|
if not cnc_program and cnc_processing_arr:
|
||||||
cnc_program = cnc_production
|
cnc_program = cnc_production
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
ftp_port = fields.Char(string='FTP端口')
|
ftp_port = fields.Char(string='FTP端口')
|
||||||
ftp_user = fields.Char(string='FTP用户')
|
ftp_user = fields.Char(string='FTP用户')
|
||||||
ftp_password = fields.Char(string='FTP密码')
|
ftp_password = fields.Char(string='FTP密码')
|
||||||
|
enable_tool_presetter = fields.Boolean('是否启用刀具预调仪', default=True)
|
||||||
|
|
||||||
def sf_all_sync(self):
|
def sf_all_sync(self):
|
||||||
try:
|
try:
|
||||||
@@ -108,6 +109,7 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
ftp_port = config.get_param('ftp_port', default='')
|
ftp_port = config.get_param('ftp_port', default='')
|
||||||
ftp_user = config.get_param('ftp_user', default='')
|
ftp_user = config.get_param('ftp_user', default='')
|
||||||
ftp_password = config.get_param('ftp_password', default='')
|
ftp_password = config.get_param('ftp_password', default='')
|
||||||
|
enable_tool_presetter = config.get_param('enable_tool_presetter', default='')
|
||||||
|
|
||||||
values.update(
|
values.update(
|
||||||
token=token,
|
token=token,
|
||||||
@@ -121,7 +123,8 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
ftp_host=ftp_host,
|
ftp_host=ftp_host,
|
||||||
ftp_port=ftp_port,
|
ftp_port=ftp_port,
|
||||||
ftp_user=ftp_user,
|
ftp_user=ftp_user,
|
||||||
ftp_password=ftp_password
|
ftp_password=ftp_password,
|
||||||
|
enable_tool_presetter=enable_tool_presetter
|
||||||
)
|
)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
@@ -140,3 +143,4 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
ir_config.set_param("ftp_port", self.ftp_port 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_user", self.ftp_user or "")
|
||||||
ir_config.set_param("ftp_password", self.ftp_password or "")
|
ir_config.set_param("ftp_password", self.ftp_password or "")
|
||||||
|
ir_config.set_param("enable_tool_presetter", self.enable_tool_presetter or False)
|
||||||
|
|||||||
@@ -114,6 +114,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</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">
|
||||||
|
<field name="enable_tool_presetter"/>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<div class="text-muted">
|
||||||
|
<label for="enable_tool_presetter" string="是否启用刀具预调仪"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -8,6 +8,35 @@ from odoo.http import request
|
|||||||
|
|
||||||
class Manufacturing_Connect(http.Controller):
|
class Manufacturing_Connect(http.Controller):
|
||||||
|
|
||||||
|
@http.route('/AutoDeviceApi/ToolGroup', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_functional_tool_groups_Info(self, **kw):
|
||||||
|
"""
|
||||||
|
刀具组接口
|
||||||
|
:param kw:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
logging.info('get_functional_tool_groups_Info:%s' % kw)
|
||||||
|
try:
|
||||||
|
datas = request.httprequest.data
|
||||||
|
ret = json.loads(datas)
|
||||||
|
# ret = json.loads(ret['result'])
|
||||||
|
logging.info('DeviceId:%s' % ret)
|
||||||
|
functional_tools = request.env['sf.tool.inventory'].sudo().search([])
|
||||||
|
|
||||||
|
res = {'Succeed': True, 'Datas': []}
|
||||||
|
if functional_tools:
|
||||||
|
for item in functional_tools:
|
||||||
|
res['Datas'].append({
|
||||||
|
'GroupName': item.tool_groups_id.name,
|
||||||
|
'ToolId': item.functional_cutting_tool_model_id.name,
|
||||||
|
'ToolName': item.name
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
|
logging.info('get_functional_tool_groups_Info error:%s' % e)
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/ToolInventory', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/ToolInventory', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def get_functional_tool_inventory_Info(self, **kw):
|
def get_functional_tool_inventory_Info(self, **kw):
|
||||||
@@ -67,3 +96,34 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
logging.info('get_functional_tool_entity_Info error:%s' % e)
|
logging.info('get_functional_tool_entity_Info error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
|
@http.route('/AutoDeviceApi/PutToolParameter', type='http', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def put_tool_preset_parameter_port(self, **kw):
|
||||||
|
"""
|
||||||
|
刀具预调仪接口
|
||||||
|
:param kw:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
logging.info('put_tool_preset_parameter_port:%s' % kw)
|
||||||
|
res = {'Succeed': True, 'Datas': []}
|
||||||
|
try:
|
||||||
|
datas = request.httprequest.data
|
||||||
|
ret = str(datas, 'utf-8')
|
||||||
|
data_lists = ret.split(",")
|
||||||
|
data_list = [data.replace('+', '') for data in data_lists]
|
||||||
|
logging.info(data_list)
|
||||||
|
tool_assembly = request.env['sf.functional.tool.assembly'].sudo().search(
|
||||||
|
[('assembly_order_code', '=', data_list[0]), ('start_preset_bool', '=', True)])
|
||||||
|
if not tool_assembly:
|
||||||
|
return json.JSONEncoder().encode(
|
||||||
|
{'Succeed': False, 'ErrorCode': 201, 'code': data_list[0], 'Error': '没有找到正在组装的组装单!'})
|
||||||
|
tool_assembly.write({
|
||||||
|
'after_assembly_tool_loading_length': float(data_list[1] or "0"), # 高度(总长度)
|
||||||
|
'after_assembly_functional_tool_diameter': float(data_list[2] or "0"), # 直径
|
||||||
|
'after_assembly_knife_tip_r_angle': float(data_list[3] or "0") # R角
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
|
logging.info('put_tool_preset_parameter_port error:%s' % e)
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
|
|||||||
@@ -6,4 +6,5 @@ from . import mrp_workorder
|
|||||||
from . import functional_tool_enroll
|
from . import functional_tool_enroll
|
||||||
from . import fixture_material_search
|
from . import fixture_material_search
|
||||||
from . import fixture_enroll
|
from . import fixture_enroll
|
||||||
|
from . import temporary_data_processing_methods
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ class MachineTableToolChangingApply(models.Model):
|
|||||||
|
|
||||||
class CAMWorkOrderProgramKnifePlan(models.Model):
|
class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||||
_name = 'sf.cam.work.order.program.knife.plan'
|
_name = 'sf.cam.work.order.program.knife.plan'
|
||||||
|
_inherit = ['mail.thread']
|
||||||
_description = 'CAM工单程序用刀计划'
|
_description = 'CAM工单程序用刀计划'
|
||||||
|
|
||||||
name = fields.Char('工单任务编号')
|
name = fields.Char('工单任务编号')
|
||||||
@@ -228,7 +229,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
|||||||
estimated_processing_time = fields.Char('预计加工时间')
|
estimated_processing_time = fields.Char('预计加工时间')
|
||||||
|
|
||||||
plan_execute_status = fields.Selection([('0', '待下发'), ('1', '执行中'), ('2', '已完成')],
|
plan_execute_status = fields.Selection([('0', '待下发'), ('1', '执行中'), ('2', '已完成')],
|
||||||
string='计划执行状态', default='0', readonly=False)
|
string='计划执行状态', default='0', readonly=False, tracking=True)
|
||||||
|
|
||||||
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True)
|
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True)
|
||||||
|
|
||||||
@@ -311,45 +312,58 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
|||||||
'applicant': None,
|
'applicant': None,
|
||||||
'sf_functional_tool_assembly_id': None})
|
'sf_functional_tool_assembly_id': None})
|
||||||
|
|
||||||
def create_cam_work_plan(self, cnc_processing):
|
def create_cam_work_plan(self, cnc_processing_ids):
|
||||||
"""
|
"""
|
||||||
根据传入的工单信息,查询是否有需要的功能刀具,如果没有则生成CAM工单程序用刀计划
|
根据传入的工单信息,查询是否有需要的功能刀具,如果没有则生成CAM工单程序用刀计划
|
||||||
"""
|
"""
|
||||||
status = False
|
for cnc_processing in cnc_processing_ids:
|
||||||
if cnc_processing.cutting_tool_name:
|
status = False
|
||||||
functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search(
|
if cnc_processing.cutting_tool_name:
|
||||||
[('name', '=', cnc_processing.cutting_tool_name)])
|
functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search(
|
||||||
if functional_tools:
|
[('name', '=', cnc_processing.cutting_tool_name)])
|
||||||
for functional_tool in functional_tools:
|
if functional_tools:
|
||||||
if functional_tool.on_tool_stock_num == 0:
|
for functional_tool in functional_tools:
|
||||||
if functional_tool.tool_stock_num == 0 and functional_tool.side_shelf_num == 0:
|
if functional_tool.on_tool_stock_num == 0:
|
||||||
status = True
|
if functional_tool.tool_stock_num == 0 and functional_tool.side_shelf_num == 0:
|
||||||
else:
|
status = True
|
||||||
status = True
|
else:
|
||||||
if status:
|
status = True
|
||||||
knife_plan = self.env['sf.cam.work.order.program.knife.plan'].sudo().create({
|
if status:
|
||||||
'name': cnc_processing.workorder_id.production_id.name,
|
knife_plan = self.env['sf.cam.work.order.program.knife.plan'].sudo().create({
|
||||||
'cam_procedure_code': cnc_processing.program_name,
|
'name': cnc_processing.workorder_id.production_id.name,
|
||||||
'filename': cnc_processing.cnc_id.name,
|
'cam_procedure_code': cnc_processing.program_name,
|
||||||
'functional_tool_name': cnc_processing.cutting_tool_name,
|
'filename': cnc_processing.cnc_id.name,
|
||||||
'cam_cutter_spacing_code': cnc_processing.cutting_tool_no,
|
'functional_tool_name': cnc_processing.cutting_tool_name,
|
||||||
'process_type': cnc_processing.processing_type,
|
'cam_cutter_spacing_code': cnc_processing.cutting_tool_no,
|
||||||
'margin_x_y': float(cnc_processing.margin_x_y),
|
'process_type': cnc_processing.processing_type,
|
||||||
'margin_z': float(cnc_processing.margin_z),
|
'margin_x_y': float(cnc_processing.margin_x_y),
|
||||||
'finish_depth': float(cnc_processing.depth_of_processing_z),
|
'margin_z': float(cnc_processing.margin_z),
|
||||||
'extension_length': float(cnc_processing.cutting_tool_extension_length),
|
'finish_depth': float(cnc_processing.depth_of_processing_z),
|
||||||
'shank_model': cnc_processing.cutting_tool_handle_type,
|
'extension_length': float(cnc_processing.cutting_tool_extension_length),
|
||||||
'estimated_processing_time': cnc_processing.estimated_processing_time,
|
'shank_model': cnc_processing.cutting_tool_handle_type,
|
||||||
})
|
'estimated_processing_time': cnc_processing.estimated_processing_time,
|
||||||
logging.info('CAM工单程序用刀计划创建成功!!!')
|
})
|
||||||
# 创建装刀请求
|
logging.info('CAM工单程序用刀计划创建成功!!!')
|
||||||
knife_plan.apply_for_tooling()
|
# 创建装刀请求
|
||||||
else:
|
knife_plan.apply_for_tooling()
|
||||||
logging.info('功能刀具【%s】满足CNC用刀需求!!!' % cnc_processing.cutting_tool_name)
|
else:
|
||||||
|
logging.info('功能刀具【%s】满足CNC用刀需求!!!' % cnc_processing.cutting_tool_name)
|
||||||
|
|
||||||
|
def unlink_cam_plan(self, production):
|
||||||
|
for item in production:
|
||||||
|
cam_plan_ids = self.env['sf.cam.work.order.program.knife.plan'].search([('name', '=', item.name)])
|
||||||
|
for cam_plan_id in cam_plan_ids:
|
||||||
|
assembly_id = cam_plan_id.sf_functional_tool_assembly_id
|
||||||
|
if assembly_id.assemble_status in ('0', '待组装') and not assembly_id.start_preset_bool:
|
||||||
|
logging.info('%s删除成功!!!' % assembly_id)
|
||||||
|
assembly_id.sudo().unlink()
|
||||||
|
logging.info('unlink_cam_plan成功!!!')
|
||||||
|
cam_plan_ids.sudo().unlink()
|
||||||
|
|
||||||
|
|
||||||
class FunctionalToolAssembly(models.Model):
|
class FunctionalToolAssembly(models.Model):
|
||||||
_name = 'sf.functional.tool.assembly'
|
_name = 'sf.functional.tool.assembly'
|
||||||
|
_inherit = ['mail.thread']
|
||||||
_description = '功能刀具组装'
|
_description = '功能刀具组装'
|
||||||
_order = 'assemble_status, use_tool_time asc'
|
_order = 'assemble_status, use_tool_time asc'
|
||||||
|
|
||||||
@@ -384,7 +398,7 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
applicant = fields.Char(string='申请人', readonly=True)
|
applicant = fields.Char(string='申请人', readonly=True)
|
||||||
apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True)
|
apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True)
|
||||||
assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态', default='0',
|
assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态', default='0',
|
||||||
readonly=True)
|
tracking=True, readonly=True)
|
||||||
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True)
|
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True)
|
||||||
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True)
|
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True)
|
||||||
reason_for_applying = fields.Char(string='申请原因', readonly=True)
|
reason_for_applying = fields.Char(string='申请原因', readonly=True)
|
||||||
@@ -401,8 +415,9 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
return categories.browse(functional_tool_type_ids)
|
return categories.browse(functional_tool_type_ids)
|
||||||
|
|
||||||
# 刀具物料信息
|
# 刀具物料信息
|
||||||
# ==============整体式刀具型号============
|
# ==============整体式刀具型号=============
|
||||||
integral_freight_barcode = fields.Char('整体式刀具货位')
|
integral_freight_barcode_id = fields.Many2one('sf.shelf.location', string='整体式刀具货位')
|
||||||
|
integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次')
|
||||||
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='整体式刀具型号',
|
||||||
@@ -412,19 +427,15 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
|
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
|
||||||
related='integral_product_id.brand_id')
|
related='integral_product_id.brand_id')
|
||||||
|
|
||||||
@api.depends('integral_freight_barcode')
|
@api.depends('integral_lot_id')
|
||||||
def _compute_integral_product_id(self):
|
def _compute_integral_product_id(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
if item.integral_freight_barcode:
|
if item.integral_lot_id:
|
||||||
location = self.env['sf.shelf.location'].sudo().search(
|
item.integral_product_id = item.integral_lot_id.product_id.id
|
||||||
[('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_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀片货位')
|
||||||
|
blade_lot_id = fields.Many2one('stock.lot', string='刀片批次')
|
||||||
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='刀片型号',
|
||||||
@@ -433,18 +444,15 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
related='blade_product_id.specification_id')
|
related='blade_product_id.specification_id')
|
||||||
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
|
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
|
||||||
|
|
||||||
@api.depends('blade_freight_barcode')
|
@api.depends('blade_lot_id')
|
||||||
def _compute_blade_product_id(self):
|
def _compute_blade_product_id(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
if item.blade_freight_barcode:
|
if item.blade_lot_id:
|
||||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.blade_freight_barcode)])
|
item.blade_product_id = item.blade_lot_id.product_id.id
|
||||||
if location:
|
|
||||||
item.blade_product_id = location.product_id.id
|
|
||||||
else:
|
|
||||||
item.blade_product_id = False
|
|
||||||
|
|
||||||
# ==============刀杆型号================
|
# ==============刀杆型号================
|
||||||
bar_freight_barcode = fields.Char('刀杆货位')
|
bar_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀杆货位')
|
||||||
|
bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次')
|
||||||
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='刀杆型号',
|
||||||
@@ -453,18 +461,15 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
related='bar_product_id.specification_id')
|
related='bar_product_id.specification_id')
|
||||||
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
|
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
|
||||||
|
|
||||||
@api.depends('bar_freight_barcode')
|
@api.depends('bar_lot_id')
|
||||||
def _compute_bar_product_id(self):
|
def _compute_bar_product_id(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
if item.bar_freight_barcode:
|
if item.bar_lot_id:
|
||||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.bar_freight_barcode)])
|
item.bar_product_id = item.bar_lot_id.product_id.id
|
||||||
if location:
|
|
||||||
item.bar_product_id = location.product_id.id
|
|
||||||
else:
|
|
||||||
item.bar_product_id = False
|
|
||||||
|
|
||||||
# =============刀盘型号================
|
# =============刀盘型号================
|
||||||
pad_freight_barcode = fields.Char('刀盘货位')
|
pad_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀盘货位')
|
||||||
|
pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次')
|
||||||
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='刀盘型号',
|
||||||
@@ -473,15 +478,11 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
related='pad_product_id.specification_id')
|
related='pad_product_id.specification_id')
|
||||||
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
|
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
|
||||||
|
|
||||||
@api.depends('pad_freight_barcode')
|
@api.depends('pad_lot_id')
|
||||||
def _compute_pad_product_id(self):
|
def _compute_pad_product_id(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
if item.pad_freight_barcode:
|
if item.pad_lot_id:
|
||||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.pad_freight_barcode)])
|
item.pad_product_id = item.pad_lot_id.product_id.id
|
||||||
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_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_handle_product_id', store=True)
|
||||||
@@ -505,7 +506,8 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
item.handle_freight_rfid = False
|
item.handle_freight_rfid = False
|
||||||
|
|
||||||
# ==============夹头型号==============
|
# ==============夹头型号==============
|
||||||
chuck_freight_barcode = fields.Char('夹头货位')
|
chuck_freight_barcode_id = fields.Many2one('sf.shelf.location', string='夹头货位')
|
||||||
|
chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次')
|
||||||
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='夹头型号',
|
||||||
@@ -514,17 +516,18 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
related='chuck_product_id.specification_id')
|
related='chuck_product_id.specification_id')
|
||||||
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
|
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
|
||||||
|
|
||||||
@api.depends('chuck_freight_barcode')
|
@api.depends('chuck_lot_id')
|
||||||
def _compute_chuck_product_id(self):
|
def _compute_chuck_product_id(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
if item.chuck_freight_barcode:
|
if item.chuck_lot_id:
|
||||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.chuck_freight_barcode)])
|
item.chuck_product_id = item.chuck_lot_id.product_id.id
|
||||||
if location:
|
|
||||||
item.chuck_product_id = location.product_id.id
|
|
||||||
else:
|
|
||||||
item.chuck_product_id = False
|
|
||||||
|
|
||||||
# ==================待删除字段==================
|
# ==================待删除字段==================
|
||||||
|
integral_freight_barcode = fields.Char('整体式刀具货位')
|
||||||
|
blade_freight_barcode = fields.Char('刀片货位')
|
||||||
|
bar_freight_barcode = fields.Char('刀杆货位')
|
||||||
|
pad_freight_barcode = fields.Char('刀盘货位')
|
||||||
|
chuck_freight_barcode = fields.Char('夹头货位')
|
||||||
blade_name = fields.Char('')
|
blade_name = fields.Char('')
|
||||||
integral_name = fields.Char('')
|
integral_name = fields.Char('')
|
||||||
blade_code_id = fields.Many2one('stock.lot', '刀片序列号')
|
blade_code_id = fields.Many2one('stock.lot', '刀片序列号')
|
||||||
@@ -538,12 +541,14 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
chuck_name = fields.Char('')
|
chuck_name = fields.Char('')
|
||||||
# ==============================================
|
# ==============================================
|
||||||
# 组装功能刀具参数信息
|
# 组装功能刀具参数信息
|
||||||
|
start_preset_bool = fields.Boolean('开始预调', default=False)
|
||||||
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)
|
||||||
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='组装后功能刀具类型', readonly=True)
|
string='组装后功能刀具类型', readonly=True)
|
||||||
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)', readonly=True)
|
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)', readonly=True,
|
||||||
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)', readonly=True)
|
digits=(10, 3))
|
||||||
|
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)', readonly=True, digits=(10, 3))
|
||||||
after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', readonly=True)
|
after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', readonly=True)
|
||||||
cut_time = fields.Integer(string='已切削时间(min)', readonly=True)
|
cut_time = fields.Integer(string='已切削时间(min)', readonly=True)
|
||||||
cut_length = fields.Float(string='已切削长度(mm)', readonly=True)
|
cut_length = fields.Float(string='已切削长度(mm)', readonly=True)
|
||||||
@@ -555,8 +560,9 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)', readonly=True)
|
after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)', readonly=True)
|
||||||
after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)', readonly=True)
|
after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)', readonly=True)
|
||||||
after_assembly_used_value = fields.Integer(string='组装后已使用值(min)', readonly=True)
|
after_assembly_used_value = fields.Integer(string='组装后已使用值(min)', readonly=True)
|
||||||
after_assembly_tool_loading_length = fields.Float(string='组装后总长度(mm)', readonly=True)
|
after_assembly_tool_loading_length = fields.Float(string='组装后总长度(mm)', readonly=True, digits=(10, 3))
|
||||||
after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)', readonly=True)
|
after_assembly_handle_length = fields.Float(string='组装后刀柄长度(mm)', readonly=True, digits=(10, 3))
|
||||||
|
after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)', readonly=True, digits=(10, 3))
|
||||||
after_assembly_effective_length = fields.Float(string='组装后有效长(mm)', readonly=True)
|
after_assembly_effective_length = fields.Float(string='组装后有效长(mm)', readonly=True)
|
||||||
L_D_number = fields.Float(string='L/D值(mm)', readonly=True)
|
L_D_number = fields.Float(string='L/D值(mm)', readonly=True)
|
||||||
hiding_length = fields.Float(string='避空长(mm)', readonly=True)
|
hiding_length = fields.Float(string='避空长(mm)', readonly=True)
|
||||||
@@ -574,29 +580,64 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
|
|
||||||
active = fields.Boolean(string='已归档', default=True)
|
active = fields.Boolean(string='已归档', default=True)
|
||||||
|
|
||||||
|
def put_start_preset(self):
|
||||||
|
self.search([('start_preset_bool', '=', True)]).write({'start_preset_bool': False})
|
||||||
|
self.write({
|
||||||
|
'after_assembly_tool_loading_length': 0,
|
||||||
|
'after_assembly_functional_tool_diameter': 0,
|
||||||
|
'after_assembly_knife_tip_r_angle': 0,
|
||||||
|
'start_preset_bool': True
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'res_model': 'sf.functional.tool.assembly.order',
|
||||||
|
'name': '功能刀具组装单',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'target': 'new',
|
||||||
|
'context': {'default_name': self.name,
|
||||||
|
'default_assembly_order_code': self.assembly_order_code,
|
||||||
|
'default_production_line_name_id': self.production_line_name_id.id,
|
||||||
|
'default_machine_tool_name_id': self.machine_tool_name_id.id,
|
||||||
|
'default_cutter_spacing_code_id': self.cutter_spacing_code_id.id,
|
||||||
|
'default_functional_tool_name': self.functional_tool_name,
|
||||||
|
'default_functional_tool_type_id': self.functional_tool_type_id.id,
|
||||||
|
'default_tool_groups_id': self.tool_groups_id.id,
|
||||||
|
'default_functional_tool_diameter': self.functional_tool_diameter,
|
||||||
|
'default_knife_tip_r_angle': self.knife_tip_r_angle,
|
||||||
|
'default_tool_loading_length': self.tool_loading_length,
|
||||||
|
'default_functional_tool_length': self.functional_tool_length,
|
||||||
|
'default_effective_length': self.effective_length,
|
||||||
|
'default_whether_standard_knife': self.whether_standard_knife,
|
||||||
|
'default_coarse_middle_thin': self.coarse_middle_thin,
|
||||||
|
'default_new_former': self.new_former,
|
||||||
|
'default_use_tool_time': self.use_tool_time,
|
||||||
|
'default_reason_for_applying': self.reason_for_applying
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def _get_code(self, loading_task_source):
|
def _get_code(self, loading_task_source):
|
||||||
"""
|
"""
|
||||||
自动生成组装单编码
|
自动生成组装单编码
|
||||||
"""
|
"""
|
||||||
new_time = str(fields.Date.today())
|
new_time = str(fields.Date.today())
|
||||||
datetime = new_time[2:4] + new_time[5:7] + new_time[-2:]
|
datetime = new_time[2:4] + new_time[5:7]
|
||||||
|
if loading_task_source == '0':
|
||||||
|
code = 'C' + datetime
|
||||||
|
elif loading_task_source == '1':
|
||||||
|
code = 'J' + datetime
|
||||||
|
elif loading_task_source == '2':
|
||||||
|
code = 'K' + datetime
|
||||||
|
else:
|
||||||
|
code = False
|
||||||
functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().search(
|
functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().search(
|
||||||
[('loading_task_source', '=', loading_task_source),
|
[('loading_task_source', '=', loading_task_source),
|
||||||
('assembly_order_code', 'ilike', datetime)], limit=1, order="id desc")
|
('assembly_order_code', 'ilike', code)], limit=1, order="id desc")
|
||||||
if not functional_tool_assembly:
|
if not functional_tool_assembly:
|
||||||
num = "%03d" % 1
|
num = "%03d" % 1
|
||||||
else:
|
else:
|
||||||
m = int(functional_tool_assembly.assembly_order_code[-3:]) + 1
|
m = int(functional_tool_assembly.assembly_order_code[-3:]) + 1
|
||||||
num = "%03d" % m
|
num = "%03d" % m
|
||||||
if loading_task_source == '0':
|
return code + str(num)
|
||||||
code = 'CAMZZD' + datetime + str(num)
|
|
||||||
elif loading_task_source == '1':
|
|
||||||
code = 'JTZZD' + datetime + str(num)
|
|
||||||
elif loading_task_source == '2':
|
|
||||||
code = 'MTSZZD' + datetime + str(num)
|
|
||||||
else:
|
|
||||||
code = False
|
|
||||||
return code
|
|
||||||
|
|
||||||
def get_functional_tool(self, val):
|
def get_functional_tool(self, val):
|
||||||
functional_tools = self.env['sf.functional.tool.assembly'].search(
|
functional_tools = self.env['sf.functional.tool.assembly'].search(
|
||||||
@@ -629,7 +670,7 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
|
|
||||||
class FunctionalToolDismantle(models.Model):
|
class FunctionalToolDismantle(models.Model):
|
||||||
_name = 'sf.functional.tool.dismantle'
|
_name = 'sf.functional.tool.dismantle'
|
||||||
_inherit = ["barcodes.barcode_events_mixin"]
|
_inherit = ["barcodes.barcode_events_mixin", 'mail.thread']
|
||||||
_description = '功能刀具拆解'
|
_description = '功能刀具拆解'
|
||||||
|
|
||||||
def on_barcode_scanned(self, barcode):
|
def on_barcode_scanned(self, barcode):
|
||||||
@@ -690,6 +731,22 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
raise ValidationError('该功能刀具因为%s拆解,无需录入库位' % self.dismantle_cause)
|
raise ValidationError('该功能刀具因为%s拆解,无需录入库位' % self.dismantle_cause)
|
||||||
|
|
||||||
name = fields.Char('名称', related='functional_tool_id.name')
|
name = fields.Char('名称', related='functional_tool_id.name')
|
||||||
|
code = fields.Char('拆解单号', default=lambda self: self._get_code(), readonly=True)
|
||||||
|
|
||||||
|
def _get_code(self):
|
||||||
|
"""
|
||||||
|
自动生成拆解单编码
|
||||||
|
"""
|
||||||
|
new_time = str(fields.Date.today())
|
||||||
|
datetime = new_time[2:4] + new_time[5:7] + new_time[-2:]
|
||||||
|
functional_tool_dismantle = self.env['sf.functional.tool.dismantle'].sudo().search(
|
||||||
|
[('code', 'ilike', datetime)], limit=1, order="id desc")
|
||||||
|
if not functional_tool_dismantle:
|
||||||
|
num = "%03d" % 1
|
||||||
|
else:
|
||||||
|
m = int(functional_tool_dismantle.code[-3:]) + 1
|
||||||
|
num = "%03d" % m
|
||||||
|
return 'GNDJ-CJD-%s-%s' % (datetime, num)
|
||||||
|
|
||||||
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
|
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
|
||||||
domain=[('functional_tool_status', '!=', '已拆除')])
|
domain=[('functional_tool_status', '!=', '已拆除')])
|
||||||
@@ -703,7 +760,7 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
|
|
||||||
dismantle_cause = fields.Selection(
|
dismantle_cause = fields.Selection(
|
||||||
[('寿命到期报废', '寿命到期报废'), ('崩刀报废', '崩刀报废'), ('更换为其他刀具', '更换为其他刀具'),
|
[('寿命到期报废', '寿命到期报废'), ('崩刀报废', '崩刀报废'), ('更换为其他刀具', '更换为其他刀具'),
|
||||||
('刀具需磨削', '刀具需磨削')], string='拆解原因', required=True)
|
('刀具需磨削', '刀具需磨削')], string='拆解原因', required=True, tracking=True)
|
||||||
dismantle_data = fields.Datetime('拆解日期', readonly=True)
|
dismantle_data = fields.Datetime('拆解日期', readonly=True)
|
||||||
dismantle_person = fields.Char('拆解人', readonly=True)
|
dismantle_person = fields.Char('拆解人', readonly=True)
|
||||||
image = fields.Binary('图片', readonly=True)
|
image = fields.Binary('图片', readonly=True)
|
||||||
@@ -711,7 +768,7 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
scrap_id = fields.Char('报废单号', readonly=True)
|
scrap_id = fields.Char('报废单号', readonly=True)
|
||||||
grinding_id = fields.Char('磨削单号', readonly=True)
|
grinding_id = fields.Char('磨削单号', readonly=True)
|
||||||
|
|
||||||
state = fields.Selection([('待拆解', '待拆解'), ('已拆解', '已拆解')], default='待拆解')
|
state = fields.Selection([('待拆解', '待拆解'), ('已拆解', '已拆解')], default='待拆解', tracking=True)
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
# 刀柄
|
# 刀柄
|
||||||
@@ -721,7 +778,9 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
related='handle_product_id.cutting_tool_model_id')
|
related='handle_product_id.cutting_tool_model_id')
|
||||||
handle_brand_id = fields.Many2one('sf.machine.brand', string='刀柄品牌', related='handle_product_id.brand_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)
|
handle_rfid = fields.Char(string='刀柄Rfid', compute='_compute_functional_tool_num', store=True)
|
||||||
scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False)
|
handle_lot_id = fields.Many2one('stock.lot', string='刀柄序列号', compute='_compute_functional_tool_num',
|
||||||
|
store=True)
|
||||||
|
scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False, tracking=True)
|
||||||
|
|
||||||
# 整体式
|
# 整体式
|
||||||
integral_product_id = fields.Many2one('product.product', string='整体式刀具',
|
integral_product_id = fields.Many2one('product.product', string='整体式刀具',
|
||||||
@@ -730,6 +789,8 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
related='integral_product_id.cutting_tool_model_id')
|
related='integral_product_id.cutting_tool_model_id')
|
||||||
integral_brand_id = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
|
integral_brand_id = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
|
||||||
related='integral_product_id.brand_id')
|
related='integral_product_id.brand_id')
|
||||||
|
integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次', compute='_compute_functional_tool_num',
|
||||||
|
store=True)
|
||||||
integral_freight_id = fields.Many2one('sf.shelf.location', '整体式刀具目标货位',
|
integral_freight_id = fields.Many2one('sf.shelf.location', '整体式刀具目标货位',
|
||||||
domain="[('product_id', 'in', (integral_product_id, False))]")
|
domain="[('product_id', 'in', (integral_product_id, False))]")
|
||||||
|
|
||||||
@@ -739,6 +800,7 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
blade_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
|
blade_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
|
||||||
related='blade_product_id.cutting_tool_model_id')
|
related='blade_product_id.cutting_tool_model_id')
|
||||||
blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id')
|
blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id')
|
||||||
|
blade_lot_id = fields.Many2one('stock.lot', string='刀片批次', compute='_compute_functional_tool_num', store=True)
|
||||||
blade_freight_id = fields.Many2one('sf.shelf.location', '刀片目标货位',
|
blade_freight_id = fields.Many2one('sf.shelf.location', '刀片目标货位',
|
||||||
domain="[('product_id', 'in', (blade_product_id, False))]")
|
domain="[('product_id', 'in', (blade_product_id, False))]")
|
||||||
|
|
||||||
@@ -748,6 +810,7 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
bar_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
|
bar_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
|
||||||
related='bar_product_id.cutting_tool_model_id')
|
related='bar_product_id.cutting_tool_model_id')
|
||||||
bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id')
|
bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id')
|
||||||
|
bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次', compute='_compute_functional_tool_num', store=True)
|
||||||
bar_freight_id = fields.Many2one('sf.shelf.location', '刀杆目标货位',
|
bar_freight_id = fields.Many2one('sf.shelf.location', '刀杆目标货位',
|
||||||
domain="[('product_id', 'in', (bar_product_id, False))]")
|
domain="[('product_id', 'in', (bar_product_id, False))]")
|
||||||
|
|
||||||
@@ -757,6 +820,7 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
pad_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
|
pad_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
|
||||||
related='pad_product_id.cutting_tool_model_id')
|
related='pad_product_id.cutting_tool_model_id')
|
||||||
pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id')
|
pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id')
|
||||||
|
pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次', compute='_compute_functional_tool_num', store=True)
|
||||||
pad_freight_id = fields.Many2one('sf.shelf.location', '刀盘目标货位',
|
pad_freight_id = fields.Many2one('sf.shelf.location', '刀盘目标货位',
|
||||||
domain="[('product_id', 'in', (pad_product_id, False))]")
|
domain="[('product_id', 'in', (pad_product_id, False))]")
|
||||||
|
|
||||||
@@ -766,6 +830,7 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
chuck_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
|
chuck_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
|
||||||
related='chuck_product_id.cutting_tool_model_id')
|
related='chuck_product_id.cutting_tool_model_id')
|
||||||
chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id')
|
chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id')
|
||||||
|
chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次', compute='_compute_functional_tool_num', store=True)
|
||||||
chuck_freight_id = fields.Many2one('sf.shelf.location', '夹头目标货位',
|
chuck_freight_id = fields.Many2one('sf.shelf.location', '夹头目标货位',
|
||||||
domain="[('product_id', 'in', (chuck_product_id, False))]")
|
domain="[('product_id', 'in', (chuck_product_id, False))]")
|
||||||
|
|
||||||
@@ -789,12 +854,20 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
item.rfid = item.functional_tool_id.rfid
|
item.rfid = item.functional_tool_id.rfid
|
||||||
item.handle_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.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.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.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.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.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
|
item.chuck_product_id = item.functional_tool_id.functional_tool_name_id.chuck_product_id.id
|
||||||
|
# 批次/序列号
|
||||||
|
item.handle_lot_id = item.functional_tool_id.functional_tool_name_id.handle_code_id.id
|
||||||
|
item.integral_lot_id = item.functional_tool_id.functional_tool_name_id.integral_lot_id.id
|
||||||
|
item.blade_lot_id = item.functional_tool_id.functional_tool_name_id.blade_lot_id.id
|
||||||
|
item.bar_lot_id = item.functional_tool_id.functional_tool_name_id.bar_lot_id.id
|
||||||
|
item.pad_lot_id = item.functional_tool_id.functional_tool_name_id.pad_lot_id.id
|
||||||
|
item.chuck_lot_id = item.functional_tool_id.functional_tool_name_id.chuck_lot_id.id
|
||||||
else:
|
else:
|
||||||
item.tool_groups_id = False
|
item.tool_groups_id = False
|
||||||
item.tool_type_id = False
|
item.tool_type_id = False
|
||||||
@@ -810,10 +883,45 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
item.pad_product_id = False
|
item.pad_product_id = False
|
||||||
item.chuck_product_id = False
|
item.chuck_product_id = False
|
||||||
|
|
||||||
|
item.handle_lot_id = False
|
||||||
|
item.integral_lot_id = False
|
||||||
|
item.blade_lot_id = False
|
||||||
|
item.bar_lot_id = False
|
||||||
|
item.pad_lot_id = False
|
||||||
|
item.chuck_lot_id = False
|
||||||
|
|
||||||
|
def location_duplicate_check(self):
|
||||||
|
"""
|
||||||
|
目标货位去重校验
|
||||||
|
"""
|
||||||
|
if self.blade_freight_id:
|
||||||
|
if self.bar_freight_id:
|
||||||
|
if self.blade_freight_id == self.bar_freight_id:
|
||||||
|
raise ValidationError('【刀片】和【刀杆】的目标货位重复,请重新选择!')
|
||||||
|
elif self.pad_freight_id:
|
||||||
|
if self.blade_freight_id == self.pad_freight_id:
|
||||||
|
raise ValidationError('【刀片】和【刀盘】的目标货位重复,请重新选择!')
|
||||||
|
if self.chuck_freight_id:
|
||||||
|
if self.chuck_freight_id == self.integral_freight_id:
|
||||||
|
raise ValidationError('【夹头】和【整体式刀具】的目标货位重复,请重新选择!')
|
||||||
|
if self.chuck_freight_id == self.blade_freight_id:
|
||||||
|
raise ValidationError('【夹头】和【刀片】的目标货位重复,请重新选择!')
|
||||||
|
if self.chuck_freight_id == self.bar_freight_id:
|
||||||
|
raise ValidationError('【夹头】和【刀杆】的目标货位重复,请重新选择!')
|
||||||
|
if self.chuck_freight_id == self.pad_freight_id:
|
||||||
|
raise ValidationError('【夹头】和【刀盘】的目标货位重复,请重新选择!')
|
||||||
|
|
||||||
def confirmation_disassembly(self):
|
def confirmation_disassembly(self):
|
||||||
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
||||||
|
code = self.code
|
||||||
if self.functional_tool_id.functional_tool_status == '已拆除':
|
if self.functional_tool_id.functional_tool_status == '已拆除':
|
||||||
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
|
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
|
||||||
|
# 对拆解的功能刀具进行校验,只有在刀具房的功能刀具才能拆解
|
||||||
|
if self.functional_tool_id.tool_room_num == 0:
|
||||||
|
raise ValidationError('Rfid为【%s】的功能刀具当前位置为【%s】,不能进行拆解!' % (
|
||||||
|
self.rfid, self.functional_tool_id.current_location))
|
||||||
|
# 目标重复校验
|
||||||
|
self.location_duplicate_check()
|
||||||
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
||||||
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
|
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
|
||||||
# =================刀柄是否[报废]拆解=======
|
# =================刀柄是否[报废]拆解=======
|
||||||
@@ -825,53 +933,62 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
functional_tool_assembly = self.functional_tool_id.functional_tool_name_id
|
functional_tool_assembly = self.functional_tool_id.functional_tool_name_id
|
||||||
if self.scrap_boolean:
|
if self.scrap_boolean:
|
||||||
# 刀柄报废 入库到Scrap
|
# 刀柄报废 入库到Scrap
|
||||||
lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, '功能刀具拆解',
|
lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, code,
|
||||||
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
|
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
|
||||||
else:
|
else:
|
||||||
# 刀柄不报废 入库到刀具房
|
# 刀柄不报废 入库到刀具房
|
||||||
lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, '功能刀具拆解',
|
lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, code,
|
||||||
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
|
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
|
||||||
# ==============功能刀具[报废]拆解================
|
# ==============功能刀具[报废]拆解================
|
||||||
if self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
|
if self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
|
||||||
# 除刀柄外物料报废 入库到Scrap
|
# 除刀柄外物料报废 入库到Scrap
|
||||||
if self.integral_product_id:
|
if self.integral_product_id:
|
||||||
self.integral_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location,
|
||||||
|
location_dest_scrap, code)
|
||||||
elif self.blade_product_id:
|
elif self.blade_product_id:
|
||||||
self.blade_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, location_dest_scrap,
|
||||||
|
code)
|
||||||
if self.bar_product_id:
|
if self.bar_product_id:
|
||||||
self.bar_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, location_dest_scrap,
|
||||||
|
code)
|
||||||
elif self.pad_product_id:
|
elif self.pad_product_id:
|
||||||
self.pad_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, location_dest_scrap,
|
||||||
|
code)
|
||||||
if self.chuck_product_id:
|
if self.chuck_product_id:
|
||||||
self.chuck_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, location_dest_scrap,
|
||||||
|
code)
|
||||||
# ===========功能刀具[磨削]拆解==============
|
# ===========功能刀具[磨削]拆解==============
|
||||||
elif self.dismantle_cause in ['刀具需磨削']:
|
# elif self.dismantle_cause in ['刀具需磨削']:
|
||||||
location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
|
# location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
|
||||||
# 除刀柄外物料拆解 入库到具体库位
|
# # 除刀柄外物料拆解 入库到具体库位
|
||||||
if self.integral_product_id:
|
# if self.integral_product_id:
|
||||||
self.integral_product_id.dismantle_stock_moves(False, location, location_dest)
|
# self.integral_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||||
elif self.blade_product_id:
|
# elif self.blade_product_id:
|
||||||
self.blade_product_id.dismantle_stock_moves(False, location, location_dest)
|
# self.blade_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||||
if self.bar_product_id:
|
# if self.bar_product_id:
|
||||||
self.bar_product_id.dismantle_stock_moves(False, location, location_dest)
|
# self.bar_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||||
elif self.pad_product_id:
|
# elif self.pad_product_id:
|
||||||
self.pad_product_id.dismantle_stock_moves(False, location, location_dest)
|
# self.pad_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||||
if self.chuck_product_id:
|
# if self.chuck_product_id:
|
||||||
self.chuck_product_id.dismantle_stock_moves(False, location, location_dest)
|
# self.chuck_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||||
# ==============功能刀具[更换]拆解==============
|
# ==============功能刀具[更换,磨削]拆解==============
|
||||||
elif self.dismantle_cause in ['更换为其他刀具']:
|
elif self.dismantle_cause in ['更换为其他刀具', '刀具需磨削']:
|
||||||
# 除刀柄外物料拆解 入库到具体库位
|
# 除刀柄外物料拆解 入库到具体货位
|
||||||
if self.integral_freight_id:
|
if self.integral_freight_id:
|
||||||
self.integral_product_id.dismantle_stock_moves(self.integral_freight_id.barcode, location,
|
self.integral_product_id.dismantle_stock_moves(self.integral_freight_id, self.integral_lot_id, location,
|
||||||
location_dest)
|
location_dest, code)
|
||||||
elif self.blade_freight_id:
|
elif self.blade_freight_id:
|
||||||
self.blade_product_id.dismantle_stock_moves(self.blade_freight_id.barcode, location, location_dest)
|
self.blade_product_id.dismantle_stock_moves(self.blade_freight_id, self.blade_lot_id, location,
|
||||||
|
location_dest, code)
|
||||||
if self.bar_freight_id:
|
if self.bar_freight_id:
|
||||||
self.bar_product_id.dismantle_stock_moves(self.bar_freight_id.barcode, location, location_dest)
|
self.bar_product_id.dismantle_stock_moves(self.bar_freight_id, self.bar_lot_id, location,
|
||||||
|
location_dest, code)
|
||||||
elif self.pad_freight_id:
|
elif self.pad_freight_id:
|
||||||
self.pad_product_id.dismantle_stock_moves(self.pad_freight_id.barcode, location, location_dest)
|
self.pad_product_id.dismantle_stock_moves(self.pad_freight_id, self.pad_lot_id, location,
|
||||||
|
location_dest, code)
|
||||||
if self.chuck_freight_id:
|
if self.chuck_freight_id:
|
||||||
self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id.barcode, location, location_dest)
|
self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id, self.chuck_lot_id, location,
|
||||||
|
location_dest, code)
|
||||||
# ===============删除功能刀具的Rfid字段的值, 赋值给Rfid(已拆解)字段=====
|
# ===============删除功能刀具的Rfid字段的值, 赋值给Rfid(已拆解)字段=====
|
||||||
self.functional_tool_id.write({
|
self.functional_tool_id.write({
|
||||||
'rfid_dismantle': self.functional_tool_id.rfid,
|
'rfid_dismantle': self.functional_tool_id.rfid,
|
||||||
@@ -892,26 +1009,22 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
class ProductProduct(models.Model):
|
class ProductProduct(models.Model):
|
||||||
_inherit = 'product.product'
|
_inherit = 'product.product'
|
||||||
|
|
||||||
def dismantle_stock_moves(self, shelf_location_barcode, location_id, location_dest_id):
|
def dismantle_stock_moves(self, shelf_location_id, lot_id, location_id, location_dest_id, code):
|
||||||
# 创建功能刀具拆解单产品库存移动记录
|
# 创建功能刀具拆解单产品库存移动记录
|
||||||
stock_move_id = self.env['stock.move'].sudo().create({
|
stock_move_id = self.env['stock.move'].sudo().create({
|
||||||
'name': '功能刀具拆解',
|
'name': code,
|
||||||
'product_id': self.id,
|
'product_id': self.id,
|
||||||
'location_id': location_id.id,
|
'location_id': location_id.id,
|
||||||
'location_dest_id': location_dest_id.id,
|
'location_dest_id': location_dest_id.id,
|
||||||
'product_uom_qty': 1.00,
|
'product_uom_qty': 1.00,
|
||||||
'state': 'done'
|
'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 = self.env['sf.shelf.location']
|
|
||||||
# 创建移动历史记录
|
# 创建移动历史记录
|
||||||
stock_move_line_id = self.env['stock.move.line'].sudo().create({
|
stock_move_line_id = self.env['stock.move.line'].sudo().create({
|
||||||
'product_id': self.id,
|
'product_id': self.id,
|
||||||
|
'lot_id': lot_id.id,
|
||||||
'move_id': stock_move_id.id,
|
'move_id': stock_move_id.id,
|
||||||
'current_location_id': location.id,
|
'destination_location_id': shelf_location_id.id,
|
||||||
'install_tool_time': fields.Datetime.now(),
|
'install_tool_time': fields.Datetime.now(),
|
||||||
'qty_done': 1.0,
|
'qty_done': 1.0,
|
||||||
'state': 'done',
|
'state': 'done',
|
||||||
|
|||||||
@@ -21,16 +21,17 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
name = fields.Char('名称')
|
name = fields.Char('名称')
|
||||||
tool_name_id = fields.Many2one('sf.tool.inventory', '功能刀具名称')
|
tool_name_id = fields.Many2one('sf.tool.inventory', '功能刀具名称')
|
||||||
sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号')
|
sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号')
|
||||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
|
barcode_id = fields.Many2one('stock.lot', string='序列号', readonly=True)
|
||||||
sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', 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)
|
group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True)
|
||||||
|
|
||||||
functional_tool_diameter = fields.Float(string='刀具直径(mm)', readonly=True)
|
functional_tool_diameter = fields.Float(string='刀具直径(mm)', readonly=True, digits=(10, 3))
|
||||||
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True)
|
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True, digits=(10, 3))
|
||||||
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
|
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
|
||||||
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
|
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
|
||||||
tool_loading_length = fields.Float(string='总长度(mm)', readonly=True)
|
tool_loading_length = fields.Float(string='总长度(mm)', readonly=True, digits=(10, 3))
|
||||||
functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True)
|
handle_length = fields.Float(string='刀柄长度(mm)',readonly=True, digits=(10, 3))
|
||||||
|
functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True, digits=(10, 3))
|
||||||
effective_length = fields.Float(string='有效长(mm)', readonly=True)
|
effective_length = fields.Float(string='有效长(mm)', readonly=True)
|
||||||
tool_room_num = fields.Integer(string='刀具房数量', readonly=True)
|
tool_room_num = fields.Integer(string='刀具房数量', readonly=True)
|
||||||
line_edge_knife_library_num = fields.Integer(string='线边刀库数量', readonly=True)
|
line_edge_knife_library_num = fields.Integer(string='线边刀库数量', readonly=True)
|
||||||
@@ -51,13 +52,6 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools',
|
safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools',
|
||||||
string='功能刀具安全库存', readonly=True)
|
string='功能刀具安全库存', readonly=True)
|
||||||
|
|
||||||
def button_safe_inventory_id(self):
|
|
||||||
"""更新功能刀具关联的安全库存记录"""
|
|
||||||
tool_is = self.search([])
|
|
||||||
for item in tool_is:
|
|
||||||
item.safe_inventory_id = self.env['sf.real.time.distribution.of.functional.tools'].search(
|
|
||||||
[('functional_name_id', '=', item.tool_name_id.id)])[0]
|
|
||||||
|
|
||||||
@api.depends('barcode_id.quant_ids', 'functional_tool_status')
|
@api.depends('barcode_id.quant_ids', 'functional_tool_status')
|
||||||
def _compute_current_location_id(self):
|
def _compute_current_location_id(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
@@ -324,6 +318,7 @@ class StockMoveLine(models.Model):
|
|||||||
|
|
||||||
class RealTimeDistributionOfFunctionalTools(models.Model):
|
class RealTimeDistributionOfFunctionalTools(models.Model):
|
||||||
_name = 'sf.real.time.distribution.of.functional.tools'
|
_name = 'sf.real.time.distribution.of.functional.tools'
|
||||||
|
_inherit = ['mail.thread']
|
||||||
_description = '功能刀具安全库存'
|
_description = '功能刀具安全库存'
|
||||||
|
|
||||||
name = fields.Char('名称', readonly=True, compute='_compute_name', store=True)
|
name = fields.Char('名称', readonly=True, compute='_compute_name', store=True)
|
||||||
@@ -337,11 +332,11 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
|
|||||||
side_shelf_num = fields.Integer(string='线边刀库数量')
|
side_shelf_num = fields.Integer(string='线边刀库数量')
|
||||||
on_tool_stock_num = fields.Integer(string='机内刀库数量')
|
on_tool_stock_num = fields.Integer(string='机内刀库数量')
|
||||||
tool_stock_total = fields.Integer(string='当前库存量', readonly=True)
|
tool_stock_total = fields.Integer(string='当前库存量', readonly=True)
|
||||||
min_stock_num = fields.Integer('最低库存量')
|
min_stock_num = fields.Integer('最低库存量', tracking=True)
|
||||||
max_stock_num = fields.Integer('最高库存量')
|
max_stock_num = fields.Integer('最高库存量', tracking=True)
|
||||||
batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num',
|
batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num',
|
||||||
store=True)
|
store=True)
|
||||||
unit = fields.Char('单位')
|
unit = fields.Char('单位', default="件")
|
||||||
image = fields.Binary('图片', readonly=False)
|
image = fields.Binary('图片', readonly=False)
|
||||||
|
|
||||||
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False)
|
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False)
|
||||||
|
|||||||
@@ -156,14 +156,6 @@ class ToolMaterial(models.Model):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info("捕获错误信息:%s" % e)
|
logging.info("捕获错误信息:%s" % e)
|
||||||
|
|
||||||
@api.model_create_multi
|
|
||||||
def create(self, vals_list):
|
|
||||||
records = super(ToolMaterial, self).create(vals_list)
|
|
||||||
for record in records:
|
|
||||||
if record:
|
|
||||||
record.enroll_tool_material()
|
|
||||||
return records
|
|
||||||
|
|
||||||
|
|
||||||
class FunctionalCuttingToolEntity(models.Model):
|
class FunctionalCuttingToolEntity(models.Model):
|
||||||
_inherit = 'sf.functional.cutting.tool.entity'
|
_inherit = 'sf.functional.cutting.tool.entity'
|
||||||
@@ -248,20 +240,6 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info("捕获错误信息:%s" % e)
|
logging.info("捕获错误信息:%s" % e)
|
||||||
|
|
||||||
@api.model_create_multi
|
|
||||||
def create(self, vals_list):
|
|
||||||
records = super(FunctionalCuttingToolEntity, self).create(vals_list)
|
|
||||||
for record in records:
|
|
||||||
if record:
|
|
||||||
record.enroll_functional_tool_entity()
|
|
||||||
return records
|
|
||||||
|
|
||||||
def write(self, vals):
|
|
||||||
res = super().write(vals)
|
|
||||||
if vals.get('current_location'):
|
|
||||||
self.enroll_functional_tool_entity()
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
class FunctionalToolWarning(models.Model):
|
class FunctionalToolWarning(models.Model):
|
||||||
_inherit = 'sf.functional.tool.warning'
|
_inherit = 'sf.functional.tool.warning'
|
||||||
@@ -332,14 +310,6 @@ class FunctionalToolWarning(models.Model):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info("捕获错误信息:%s" % e)
|
logging.info("捕获错误信息:%s" % e)
|
||||||
|
|
||||||
@api.model_create_multi
|
|
||||||
def create(self, vals_list):
|
|
||||||
records = super(FunctionalToolWarning, self).create(vals_list)
|
|
||||||
for record in records:
|
|
||||||
if record:
|
|
||||||
record.enroll_functional_tool_warning()
|
|
||||||
return records
|
|
||||||
|
|
||||||
|
|
||||||
class StockMoveLine(models.Model):
|
class StockMoveLine(models.Model):
|
||||||
_inherit = 'stock.move.line'
|
_inherit = 'stock.move.line'
|
||||||
@@ -401,14 +371,6 @@ class StockMoveLine(models.Model):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info("捕获错误信息:%s" % e)
|
logging.info("捕获错误信息:%s" % e)
|
||||||
|
|
||||||
@api.model_create_multi
|
|
||||||
def create(self, vals_list):
|
|
||||||
records = super(StockMoveLine, self).create(vals_list)
|
|
||||||
for record in records:
|
|
||||||
if record.functional_tool_name_id:
|
|
||||||
record.enroll_functional_tool_move()
|
|
||||||
return records
|
|
||||||
|
|
||||||
|
|
||||||
class RealTimeDistributionFunctionalTools(models.Model):
|
class RealTimeDistributionFunctionalTools(models.Model):
|
||||||
_inherit = 'sf.real.time.distribution.of.functional.tools'
|
_inherit = 'sf.real.time.distribution.of.functional.tools'
|
||||||
@@ -481,17 +443,3 @@ class RealTimeDistributionFunctionalTools(models.Model):
|
|||||||
logging.info('没有注册功能刀具出入库记录信息')
|
logging.info('没有注册功能刀具出入库记录信息')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info("捕获错误信息:%s" % e)
|
logging.info("捕获错误信息:%s" % e)
|
||||||
|
|
||||||
@api.model_create_multi
|
|
||||||
def create(self, vals_list):
|
|
||||||
records = super(RealTimeDistributionFunctionalTools, self).create(vals_list)
|
|
||||||
for record in records:
|
|
||||||
if record:
|
|
||||||
record.enroll_functional_tool_real_time_distribution()
|
|
||||||
return records
|
|
||||||
|
|
||||||
def write(self, vals):
|
|
||||||
res = super().write(vals)
|
|
||||||
if vals.get('sf_functional_tool_entity_ids') or vals.get('min_stock_num') or vals.get('max_stock_num'):
|
|
||||||
self.enroll_functional_tool_real_time_distribution()
|
|
||||||
return res
|
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
|
|
||||||
def write_maintenance_equipment_tool(self, datas):
|
def write_maintenance_equipment_tool(self, datas):
|
||||||
if datas:
|
if datas:
|
||||||
|
# 清除设备机床刀位的刀具信息
|
||||||
|
for obj in self.product_template_ids:
|
||||||
|
obj.write({
|
||||||
|
'functional_tool_name_id': False,
|
||||||
|
'tool_install_time': None
|
||||||
|
})
|
||||||
for data in datas:
|
for data in datas:
|
||||||
maintenance_equipment_id = self.search([('name', '=', data['DeviceId'])])
|
maintenance_equipment_id = self.search([('name', '=', data['DeviceId'])])
|
||||||
if maintenance_equipment_id:
|
if maintenance_equipment_id:
|
||||||
@@ -128,10 +134,7 @@ class StockLot(models.Model):
|
|||||||
record.tool_material_status = '报废'
|
record.tool_material_status = '报废'
|
||||||
else:
|
else:
|
||||||
record.tool_material_status = '未入库'
|
record.tool_material_status = '未入库'
|
||||||
if record.tool_material_search_id:
|
if record.fixture_material_search_id:
|
||||||
# 注册刀具物料状态到cloud平台
|
|
||||||
record.enroll_tool_material_stock()
|
|
||||||
elif record.fixture_material_search_id:
|
|
||||||
# 注册夹具物料状态到cloud平台
|
# 注册夹具物料状态到cloud平台
|
||||||
record.enroll_fixture_material_stock()
|
record.enroll_fixture_material_stock()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
from odoo import fields, models, api
|
||||||
|
|
||||||
|
|
||||||
|
class FunctionalCuttingToolEntity(models.Model):
|
||||||
|
_inherit = 'sf.functional.cutting.tool.entity'
|
||||||
|
|
||||||
|
def button_safe_inventory_id(self):
|
||||||
|
"""更新功能刀具关联的安全库存记录"""
|
||||||
|
tool_is = self.search([])
|
||||||
|
for item in tool_is:
|
||||||
|
item.safe_inventory_id = self.env['sf.real.time.distribution.of.functional.tools'].search(
|
||||||
|
[('functional_name_id', '=', item.tool_name_id.id)])[0]
|
||||||
|
|
||||||
|
|
||||||
|
class FunctionalToolAssembly(models.Model):
|
||||||
|
_inherit = 'sf.functional.tool.assembly'
|
||||||
|
|
||||||
|
def put_assembly_order_code(self):
|
||||||
|
assembly_list = self.search([('assemble_status', '=', '0')], order="id asc")
|
||||||
|
for item in assembly_list:
|
||||||
|
code = item.assembly_order_code[-9:-5]
|
||||||
|
if item.loading_task_source == '0':
|
||||||
|
code = 'C' + code
|
||||||
|
elif item.loading_task_source == '1':
|
||||||
|
code = 'J' + code
|
||||||
|
elif item.loading_task_source == '2':
|
||||||
|
code = 'K' + code
|
||||||
|
|
||||||
|
functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().search(
|
||||||
|
[('loading_task_source', '=', item.loading_task_source),
|
||||||
|
('assembly_order_code', 'ilike', code)], limit=1, order="id desc")
|
||||||
|
if not functional_tool_assembly:
|
||||||
|
num = "%04d" % 1
|
||||||
|
else:
|
||||||
|
m = int(functional_tool_assembly.assembly_order_code[-3:]) + 1
|
||||||
|
num = "%04d" % m
|
||||||
|
|
||||||
|
item.assembly_order_code = "%s%s" % (code, num)
|
||||||
@@ -45,8 +45,6 @@ class ToolMaterial(models.Model):
|
|||||||
record.have_been_used_num = have_been_used_num
|
record.have_been_used_num = have_been_used_num
|
||||||
record.scrap_num = scrap_num
|
record.scrap_num = scrap_num
|
||||||
record.number = usable_num + have_been_used_num + scrap_num
|
record.number = usable_num + have_been_used_num + scrap_num
|
||||||
# 更新数据到cloud的动态数据
|
|
||||||
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):
|
||||||
|
|||||||
@@ -46,8 +46,8 @@
|
|||||||
</header>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
<div class="oe_button_box" name="button_box">
|
<div class="oe_button_box" name="button_box">
|
||||||
<button name="button_safe_inventory_id" string="更新功能刀具关联的安全库存记录"
|
<!-- <button name="button_safe_inventory_id" string="更新功能刀具关联的安全库存记录"-->
|
||||||
type="object" class="btn-primary"/>
|
<!-- type="object" class="btn-primary"/>-->
|
||||||
<button class="oe_stat_button" groups="sf_base.group_sf_mrp_user"
|
<button class="oe_stat_button" groups="sf_base.group_sf_mrp_user"
|
||||||
name="open_functional_tool_warning"
|
name="open_functional_tool_warning"
|
||||||
icon="fa-list-ul"
|
icon="fa-list-ul"
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="barcode_id" invisible="1"/>
|
<field name="barcode_id" invisible="0"/>
|
||||||
<field name="rfid" readonly="1"
|
<field name="rfid" readonly="1"
|
||||||
attrs="{'invisible': [('functional_tool_status', '=', '已拆除')]}"/>
|
attrs="{'invisible': [('functional_tool_status', '=', '已拆除')]}"/>
|
||||||
<field name="rfid_dismantle" readonly="1"
|
<field name="rfid_dismantle" readonly="1"
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
options="{'no_create': True, 'no_quick_create': True}"/>
|
options="{'no_create': True, 'no_quick_create': True}"/>
|
||||||
<field name="cutting_tool_cutterhead_model_id"
|
<field name="cutting_tool_cutterhead_model_id"
|
||||||
options="{'no_create': True, 'no_quick_create': True}"/>
|
options="{'no_create': True, 'no_quick_create': True}"/>
|
||||||
<field name="safe_inventory_id" readonly="0"/>
|
<field name="safe_inventory_id" invisible="1"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="image" nolabel="1" widget="image"/>
|
<field name="image" nolabel="1" widget="image"/>
|
||||||
@@ -155,24 +155,25 @@
|
|||||||
<group>
|
<group>
|
||||||
<field name="functional_tool_diameter"/>
|
<field name="functional_tool_diameter"/>
|
||||||
<field name="knife_tip_r_angle"/>
|
<field name="knife_tip_r_angle"/>
|
||||||
<field name="whether_standard_knife"/>
|
<field name="tool_loading_length"/>
|
||||||
<field name="coarse_middle_thin"/>
|
<field name="handle_length"/>
|
||||||
|
<field name="functional_tool_length"/>
|
||||||
<field name="max_lifetime_value"/>
|
<field name="max_lifetime_value"/>
|
||||||
<field name="alarm_value"/>
|
<field name="alarm_value"/>
|
||||||
<field name="used_value"/>
|
<field name="used_value" invisible="1"/>
|
||||||
<field name="current_location_id" invisible="1"/>
|
<field name="current_location_id" invisible="1"/>
|
||||||
<field name="current_location"/>
|
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="tool_loading_length"/>
|
<field name="whether_standard_knife"/>
|
||||||
<field name="functional_tool_length"/>
|
<field name="coarse_middle_thin"/>
|
||||||
<field name="effective_length"/>
|
<field name="effective_length" invisible="1"/>
|
||||||
<field name="L_D_number"/>
|
<field name="L_D_number" invisible="1"/>
|
||||||
<field name="hiding_length"/>
|
<field name="hiding_length" invisible="1"/>
|
||||||
<field name="new_former"/>
|
<field name="new_former"/>
|
||||||
<field name="cut_time" attrs="{'invisible': [('new_former','=','0')]}"/>
|
<field name="cut_time" attrs="{'invisible': [('new_former','=','0')]}"/>
|
||||||
<field name="cut_length" attrs="{'invisible': [('new_former','=','0')]}"/>
|
<field name="cut_length" attrs="{'invisible': [('new_former','=','0')]}"/>
|
||||||
<field name="cut_number" attrs="{'invisible': [('new_former','=','0')]}"/>
|
<field name="cut_number" attrs="{'invisible': [('new_former','=','0')]}"/>
|
||||||
|
<field name="current_location" string="当前位置"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
@@ -410,6 +411,10 @@
|
|||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
<div class="oe_chatter">
|
||||||
|
<field name="message_follower_ids"/>
|
||||||
|
<field name="message_ids"/>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -376,6 +376,10 @@
|
|||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
<div class="oe_chatter">
|
||||||
|
<field name="message_follower_ids"/>
|
||||||
|
<field name="message_ids"/>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -451,36 +455,9 @@
|
|||||||
<field name="whether_standard_knife" invisible="True"/>
|
<field name="whether_standard_knife" invisible="True"/>
|
||||||
<field name="reason_for_applying" invisible="True"/>
|
<field name="reason_for_applying" invisible="True"/>
|
||||||
<field name="functional_tool_type_id" invisible="True"/>
|
<field name="functional_tool_type_id" invisible="True"/>
|
||||||
<!-- <field name="functional_tool_cutting_type" invisible="True"/>-->
|
<button string="组装" name="put_start_preset" type="object"
|
||||||
|
attrs="{'invisible': [('assemble_status', '!=', '0')]}"
|
||||||
<button string="组装"
|
|
||||||
name="%(sf_tool_management.sf_functional_tool_assembly_order_act)d"
|
|
||||||
type="action"
|
|
||||||
context="{'default_name':name,
|
|
||||||
'default_assembly_order_code':assembly_order_code,
|
|
||||||
'default_production_line_name_id':production_line_name_id,
|
|
||||||
'default_machine_tool_name_id':machine_tool_name_id,
|
|
||||||
'default_cutter_spacing_code_id':cutter_spacing_code_id,
|
|
||||||
'default_functional_tool_name':functional_tool_name,
|
|
||||||
'default_functional_tool_type_id':functional_tool_type_id,
|
|
||||||
'default_tool_groups_id': tool_groups_id,
|
|
||||||
'default_functional_tool_diameter':functional_tool_diameter,
|
|
||||||
'default_knife_tip_r_angle':knife_tip_r_angle,
|
|
||||||
'default_tool_loading_length':tool_loading_length,
|
|
||||||
'default_functional_tool_length':functional_tool_length,
|
|
||||||
'default_effective_length':effective_length,
|
|
||||||
'default_whether_standard_knife':whether_standard_knife,
|
|
||||||
'default_coarse_middle_thin':coarse_middle_thin,
|
|
||||||
'default_new_former':new_former,
|
|
||||||
'default_use_tool_time':use_tool_time,
|
|
||||||
'default_reason_for_applying':reason_for_applying,
|
|
||||||
}"
|
|
||||||
attrs="{'invisible': [('assemble_status', '!=', '0')]}" groups="sf_base.group_sf_mrp_user"
|
|
||||||
class="btn-primary"/>
|
class="btn-primary"/>
|
||||||
<!-- <button string="组装单打印" name="assemble_single_print" type="object"-->
|
|
||||||
<!-- groups="sf_base.group_sf_mrp_user"-->
|
|
||||||
<!-- attrs="{'invisible': [('assemble_status', '=', '0')]}" class="btn-primary"-->
|
|
||||||
<!-- confirm="是否确认打印组装单"/>-->
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -491,35 +468,11 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form create="0" delete="0" edit="0">
|
<form create="0" delete="0" edit="0">
|
||||||
<header>
|
<header>
|
||||||
<button string="组装"
|
<!-- <button string="修改编码" name="put_assembly_order_code" type="object"-->
|
||||||
name="%(sf_tool_management.sf_functional_tool_assembly_order_act)d"
|
<!-- class="btn-primary" confirm="是否确认修改编码"/>-->
|
||||||
type="action" groups="sf_base.group_sf_mrp_user"
|
<button string="组装" name="put_start_preset" type="object"
|
||||||
context="{'default_name':name,
|
|
||||||
'default_assembly_order_code':assembly_order_code,
|
|
||||||
'default_production_line_name_id':production_line_name_id,
|
|
||||||
'default_machine_tool_name_id':machine_tool_name_id,
|
|
||||||
'default_cutter_spacing_code_id':cutter_spacing_code_id,
|
|
||||||
'default_functional_tool_name':functional_tool_name,
|
|
||||||
'default_functional_tool_type_id':functional_tool_type_id,
|
|
||||||
'default_tool_groups_id': tool_groups_id,
|
|
||||||
'default_functional_tool_diameter':functional_tool_diameter,
|
|
||||||
'default_knife_tip_r_angle':knife_tip_r_angle,
|
|
||||||
'default_tool_loading_length':tool_loading_length,
|
|
||||||
'default_functional_tool_length':functional_tool_length,
|
|
||||||
'default_effective_length':effective_length,
|
|
||||||
'default_whether_standard_knife':whether_standard_knife,
|
|
||||||
'default_coarse_middle_thin':coarse_middle_thin,
|
|
||||||
'default_new_former':new_former,
|
|
||||||
'default_use_tool_time':use_tool_time,
|
|
||||||
'default_reason_for_applying':reason_for_applying,
|
|
||||||
}"
|
|
||||||
attrs="{'invisible': [('assemble_status', '!=', '0')]}"
|
attrs="{'invisible': [('assemble_status', '!=', '0')]}"
|
||||||
class="btn-primary"/>
|
class="btn-primary"/>
|
||||||
|
|
||||||
<!-- <button string="组装单打印" name="assemble_single_print" type="object"-->
|
|
||||||
<!-- groups="sf_base.group_sf_mrp_user"-->
|
|
||||||
<!-- attrs="{'invisible': [('assemble_status', '=', '0')]}" class="btn-primary"-->
|
|
||||||
<!-- confirm="是否确认打印组装单"/>-->
|
|
||||||
<field name="assemble_status" widget="statusbar" statusbar_visible="0,1"/>
|
<field name="assemble_status" widget="statusbar" statusbar_visible="0,1"/>
|
||||||
</header>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
@@ -544,7 +497,7 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="组装信息" attrs="{'invisible': [('assemble_status', '=' ,'0')]}">
|
<page string="组装信息" attrs="{'invisible': [('assemble_status', '=', '0')]}">
|
||||||
<group col="1">
|
<group col="1">
|
||||||
<group col="1">
|
<group col="1">
|
||||||
<group>
|
<group>
|
||||||
@@ -557,9 +510,9 @@
|
|||||||
<field name="after_assembly_functional_tool_type_id"
|
<field name="after_assembly_functional_tool_type_id"
|
||||||
string="功能刀具类型"/>
|
string="功能刀具类型"/>
|
||||||
<field name="tool_groups_id"/>
|
<field name="tool_groups_id"/>
|
||||||
<field name="after_assembly_functional_tool_diameter"
|
<field name="after_assembly_whether_standard_knife"
|
||||||
string="刀具直径(mm)"/>
|
string="是否标准刀"/>
|
||||||
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"/>
|
<field name="after_assembly_coarse_middle_thin" string="粗/中/精"/>
|
||||||
<field name="after_assembly_new_former" string="新/旧"/>
|
<field name="after_assembly_new_former" string="新/旧"/>
|
||||||
<field name="cut_time"
|
<field name="cut_time"
|
||||||
attrs="{'invisible': [('after_assembly_new_former', '=', '0')]}"/>
|
attrs="{'invisible': [('after_assembly_new_former', '=', '0')]}"/>
|
||||||
@@ -569,19 +522,22 @@
|
|||||||
attrs="{'invisible': [('after_assembly_new_former', '=', '0')]}"/>
|
attrs="{'invisible': [('after_assembly_new_former', '=', '0')]}"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="after_assembly_whether_standard_knife"
|
<field name="after_assembly_functional_tool_diameter"
|
||||||
string="是否标准刀"/>
|
string="刀具直径(mm)"/>
|
||||||
<field name="after_assembly_coarse_middle_thin" string="粗/中/精"/>
|
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"/>
|
||||||
|
<field name="after_assembly_tool_loading_length" string="总长度(mm)"/>
|
||||||
|
<field name="after_assembly_handle_length" string="刀柄长度(mm)"/>
|
||||||
|
<field name="after_assembly_functional_tool_length"
|
||||||
|
string="伸出长(mm)"/>
|
||||||
<field name="after_assembly_max_lifetime_value"
|
<field name="after_assembly_max_lifetime_value"
|
||||||
string="最大寿命值(min)"/>
|
string="最大寿命值(min)"/>
|
||||||
<field name="after_assembly_alarm_value" string="报警值(min)"/>
|
<field name="after_assembly_alarm_value" string="报警值(min)"/>
|
||||||
<field name="after_assembly_used_value" string="已使用值(min)"/>
|
<field name="after_assembly_used_value" string="已使用值(min)"
|
||||||
<field name="after_assembly_tool_loading_length" string="总长度(mm)"/>
|
invisible="1"/>
|
||||||
<field name="after_assembly_functional_tool_length"
|
<field name="after_assembly_effective_length" string="有效长(mm)"
|
||||||
string="伸出长(mm)"/>
|
invisible="1"/>
|
||||||
<field name="after_assembly_effective_length" string="有效长(mm)"/>
|
<field name="L_D_number" invisible="1"/>
|
||||||
<field name="L_D_number"/>
|
<field name="hiding_length" invisible="1"/>
|
||||||
<field name="hiding_length"/>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
@@ -601,13 +557,14 @@
|
|||||||
<field name="sf_tool_brand_id_5" string="品牌"/>
|
<field name="sf_tool_brand_id_5" string="品牌"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="1" attrs="{'invisible': [('chuck_freight_barcode', '=', False)]}">
|
<group col="1" attrs="{'invisible': [('chuck_freight_barcode_id', '=', False)]}">
|
||||||
<div>
|
<div>
|
||||||
<separator string="夹头:" style="font-size: 13px;"/>
|
<separator string="夹头:" style="font-size: 13px;"/>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="chuck_freight_barcode" string="货位"/>
|
<field name="chuck_freight_barcode_id" string="货位"/>
|
||||||
|
<field name="chuck_lot_id" string="批次"/>
|
||||||
<field name="chuck_product_id" string="名称"/>
|
<field name="chuck_product_id" string="名称"/>
|
||||||
<field name="cutting_tool_cutterhead_model_id" string="型号"/>
|
<field name="cutting_tool_cutterhead_model_id" string="型号"/>
|
||||||
<field name="chuck_specification_id" string="规格"/>
|
<field name="chuck_specification_id" string="规格"/>
|
||||||
@@ -619,24 +576,27 @@
|
|||||||
<group>
|
<group>
|
||||||
<group col="1">
|
<group col="1">
|
||||||
<group col="1"
|
<group col="1"
|
||||||
attrs="{'invisible': [('integral_freight_barcode', '=', False)]}">
|
attrs="{'invisible': [('integral_freight_barcode_id', '=', False)]}">
|
||||||
<div>
|
<div>
|
||||||
<separator string="整体式刀具:" style="font-size: 13px;"/>
|
<separator string="整体式刀具:" style="font-size: 13px;"/>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<field name="integral_freight_barcode" string="货位"/>
|
<field name="integral_freight_barcode_id" string="货位"/>
|
||||||
|
<field name="integral_lot_id" string="批次"/>
|
||||||
<field name="integral_product_id" string="名称"/>
|
<field name="integral_product_id" 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_freight_barcode', '=', False)]}">
|
<group col="1"
|
||||||
|
attrs="{'invisible': [('blade_freight_barcode_id', '=', False)]}">
|
||||||
<div>
|
<div>
|
||||||
<separator string="刀片:" style="font-size: 13px;"/>
|
<separator string="刀片:" style="font-size: 13px;"/>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<field name="blade_freight_barcode" string="货位"/>
|
<field name="blade_freight_barcode_id" string="货位"/>
|
||||||
|
<field name="blade_lot_id" string="批次"/>
|
||||||
<field name="blade_product_id" string="名称"/>
|
<field name="blade_product_id" 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="规格"/>
|
||||||
@@ -645,13 +605,14 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="1">
|
<group col="1">
|
||||||
<group col="1" attrs="{'invisible': [('bar_freight_barcode', '=', False)]}">
|
<group col="1" attrs="{'invisible': [('bar_freight_barcode_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_freight_barcode" string="货位"/>
|
<field name="bar_freight_barcode_id" string="货位"/>
|
||||||
|
<field name="bar_lot_id" string="批次"/>
|
||||||
<field name="bar_product_id" string="名称"/>
|
<field name="bar_product_id" 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="规格"/>
|
||||||
@@ -659,13 +620,14 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="1" attrs="{'invisible': [('pad_freight_barcode', '=', False)]}">
|
<group col="1" attrs="{'invisible': [('pad_freight_barcode_id', '=', False)]}">
|
||||||
<div>
|
<div>
|
||||||
<separator string="刀盘:" style="font-size: 13px;"/>
|
<separator string="刀盘:" style="font-size: 13px;"/>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="pad_freight_barcode" string="货位"/>
|
<field name="pad_freight_barcode_id" string="货位"/>
|
||||||
|
<field name="pad_lot_id" string="批次"/>
|
||||||
<field name="pad_product_id" string="名称"/>
|
<field name="pad_product_id" 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="规格"/>
|
||||||
@@ -718,6 +680,10 @@
|
|||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
<div class="oe_chatter">
|
||||||
|
<field name="message_follower_ids"/>
|
||||||
|
<field name="message_ids"/>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -772,6 +738,7 @@
|
|||||||
<field name="model">sf.functional.tool.dismantle</field>
|
<field name="model">sf.functional.tool.dismantle</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree create="1">
|
<tree create="1">
|
||||||
|
<field name="code"/>
|
||||||
<field name="rfid"/>
|
<field name="rfid"/>
|
||||||
<field name="functional_tool_id"/>
|
<field name="functional_tool_id"/>
|
||||||
<field name="tool_type_id" invisible="1"/>
|
<field name="tool_type_id" invisible="1"/>
|
||||||
@@ -799,13 +766,14 @@
|
|||||||
<sheet>
|
<sheet>
|
||||||
<div class="oe_title">
|
<div class="oe_title">
|
||||||
<h1>
|
<h1>
|
||||||
<field name="functional_tool_id" placeholder="请选择将要拆解的功能刀具"
|
<field name="code"/>
|
||||||
options="{'no_create': True}" attrs="{'readonly': [('state', '=', '已拆解')]}"/>
|
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
|
<field name="functional_tool_id" placeholder="请选择将要拆解的功能刀具"
|
||||||
|
options="{'no_create': True}" attrs="{'readonly': [('state', '=', '已拆解')]}"/>
|
||||||
<field name="rfid" attrs="{'invisible': [('state', '=', '已拆解')]}"/>
|
<field name="rfid" attrs="{'invisible': [('state', '=', '已拆解')]}"/>
|
||||||
<field name="rfid_dismantle" attrs="{'invisible': [('state', '!=', '已拆解')]}"/>
|
<field name="rfid_dismantle" attrs="{'invisible': [('state', '!=', '已拆解')]}"/>
|
||||||
<field name="tool_type_id"/>
|
<field name="tool_type_id"/>
|
||||||
@@ -836,91 +804,98 @@
|
|||||||
<group>
|
<group>
|
||||||
<group string="刀柄" attrs="{'invisible': [('handle_product_id', '=', False)]}">
|
<group string="刀柄" attrs="{'invisible': [('handle_product_id', '=', False)]}">
|
||||||
<group>
|
<group>
|
||||||
|
<field name="scrap_boolean" string="是否报废"
|
||||||
|
attrs="{'invisible': [('dismantle_cause', 'not in', ['寿命到期报废','崩刀报废'])], 'readonly': [('state', '=', '已拆解')]}"/>
|
||||||
|
<field name="handle_rfid" string="Rfid"/>
|
||||||
|
<field name="handle_lot_id" string="序列号"/>
|
||||||
<field name="handle_product_id" string="名称"/>
|
<field name="handle_product_id" string="名称"/>
|
||||||
<field name="handle_type_id" string="型号"/>
|
<field name="handle_type_id" string="型号"/>
|
||||||
<field name="handle_brand_id" string="品牌"/>
|
<field name="handle_brand_id" string="品牌"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
|
||||||
<field name="handle_rfid" string="Rfid"/>
|
|
||||||
<field name="scrap_boolean" string="是否报废"
|
|
||||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['寿命到期报废','崩刀报废'])], 'readonly': [('state', '=', '已拆解')]}"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
<group string="夹头"
|
<group string="夹头"
|
||||||
attrs="{'invisible': [('chuck_product_id', '=', False)]}">
|
attrs="{'invisible': [('chuck_product_id', '=', False)]}">
|
||||||
<group>
|
<group>
|
||||||
|
<field name="chuck_freight_id" string="目标货位" placeholder="请选择"
|
||||||
|
options="{'no_create': True,'no_create_edit':True}"
|
||||||
|
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具', '刀具需磨削'])], 'readonly': [('state', '=', '已拆解')],
|
||||||
|
'required': [('chuck_lot_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具', '刀具需磨削'])]}"/>
|
||||||
|
<field name="chuck_lot_id" string="批次"/>
|
||||||
<field name="chuck_product_id" string="名称"/>
|
<field name="chuck_product_id" string="名称"/>
|
||||||
<field name="chuck_type_id" string="型号"/>
|
<field name="chuck_type_id" string="型号"/>
|
||||||
<field name="chuck_brand_id" string="品牌"/>
|
<field name="chuck_brand_id" string="品牌"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
|
||||||
<field name="chuck_freight_id" string="目标货位"
|
|
||||||
options="{'no_create': True,'no_create_edit':True}"
|
|
||||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')],
|
|
||||||
'required': [('chuck_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group attrs="{'invisible': [('integral_product_id', '=', False)]}">
|
<group attrs="{'invisible': [('integral_product_id', '=', False)]}">
|
||||||
<group string="整体式刀具">
|
<group string="整体式刀具">
|
||||||
<group>
|
<group>
|
||||||
|
<field name="integral_freight_id" string="目标货位" placeholder="请选择"
|
||||||
|
options="{'no_create': True,'no_create_edit':True}"
|
||||||
|
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具', '刀具需磨削'])], 'readonly': [('state', '=', '已拆解')],
|
||||||
|
'required': [('integral_lot_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具', '刀具需磨削'])]}"/>
|
||||||
|
<field name="integral_lot_id" string="批次"/>
|
||||||
<field name="integral_product_id" string="名称"/>
|
<field name="integral_product_id" string="名称"/>
|
||||||
<field name="integral_type_id" string="型号"/>
|
<field name="integral_type_id" string="型号"/>
|
||||||
<field name="integral_brand_id" string="品牌"/>
|
<field name="integral_brand_id" string="品牌"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
|
||||||
<field name="integral_freight_id" string="目标货位"
|
|
||||||
options="{'no_create': True,'no_create_edit':True}"
|
|
||||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')],
|
|
||||||
'required': [('integral_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/>
|
|
||||||
|
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group string="刀片" attrs="{'invisible': [('blade_product_id', '=', False)]}">
|
<group string="刀片" attrs="{'invisible': [('blade_product_id', '=', False)]}">
|
||||||
<group>
|
<group>
|
||||||
|
<field name="blade_freight_id" string="目标货位" placeholder="请选择"
|
||||||
|
options="{'no_create': True,'no_create_edit':True}"
|
||||||
|
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具', '刀具需磨削'])], 'readonly': [('state', '=', '已拆解')],
|
||||||
|
'required': [('blade_lot_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具', '刀具需磨削'])]}"/>
|
||||||
|
<field name="blade_lot_id" string="批次"/>
|
||||||
<field name="blade_product_id" string="名称"/>
|
<field name="blade_product_id" string="名称"/>
|
||||||
<field name="blade_type_id" string="型号"/>
|
<field name="blade_type_id" string="型号"/>
|
||||||
<field name="blade_brand_id" string="品牌"/>
|
<field name="blade_brand_id" string="品牌"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
|
||||||
<field name="blade_freight_id" string="目标货位"
|
|
||||||
options="{'no_create': True,'no_create_edit':True}"
|
|
||||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')],
|
|
||||||
'required': [('blade_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
<group string="刀杆" attrs="{'invisible': [('bar_product_id', '=', False)]}">
|
<group string="刀杆" attrs="{'invisible': [('bar_product_id', '=', False)]}">
|
||||||
<group>
|
<group>
|
||||||
|
<field name="bar_freight_id" string="目标货位" placeholder="请选择"
|
||||||
|
options="{'no_create': True,'no_create_edit':True}"
|
||||||
|
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具', '刀具需磨削'])], 'readonly': [('state', '=', '已拆解')],
|
||||||
|
'required': [('bar_lot_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具', '刀具需磨削'])]}"/>
|
||||||
|
<field name="bar_lot_id" string="批次"/>
|
||||||
<field name="bar_product_id" string="名称"/>
|
<field name="bar_product_id" string="名称"/>
|
||||||
<field name="bar_type_id" string="型号"/>
|
<field name="bar_type_id" string="型号"/>
|
||||||
<field name="bar_brand_id" string="品牌"/>
|
<field name="bar_brand_id" string="品牌"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
|
||||||
<field name="bar_freight_id" string="目标货位"
|
|
||||||
options="{'no_create': True,'no_create_edit':True}"
|
|
||||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')],
|
|
||||||
'required': [('bar_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
<group string="刀盘" attrs="{'invisible': [('pad_product_id', '=', False)]}">
|
<group string="刀盘" attrs="{'invisible': [('pad_product_id', '=', False)]}">
|
||||||
<group>
|
<group>
|
||||||
|
<field name="pad_freight_id" string="目标货位" placeholder="请选择"
|
||||||
|
options="{'no_create': True,'no_create_edit':True}"
|
||||||
|
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具', '刀具需磨削'])], 'readonly': [('state', '=', '已拆解')],
|
||||||
|
'required': [('pad_lot_id', '!=', False), ('dismantle_cause', 'in', ['更换为其他刀具', '刀具需磨削'])]}"/>
|
||||||
|
<field name="pad_lot_id" string="批次"/>
|
||||||
<field name="pad_product_id" string="名称"/>
|
<field name="pad_product_id" string="名称"/>
|
||||||
<field name="pad_type_id" string="型号"/>
|
<field name="pad_type_id" string="型号"/>
|
||||||
<field name="pad_brand_id" string="品牌"/>
|
<field name="pad_brand_id" string="品牌"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
</group>
|
||||||
<field name="pad_freight_id" string="目标货位"
|
</group>
|
||||||
options="{'no_create': True,'no_create_edit':True}"
|
</page>
|
||||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')],
|
<page string="其他">
|
||||||
'required': [('pad_product_id', '!=', False), ('dismantle_cause', 'in', ['更换为其他刀具'])]}"/>
|
<group>
|
||||||
</group>
|
<group>
|
||||||
|
<field name="dismantle_person"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="dismantle_data"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
<div class="oe_chatter">
|
||||||
|
<field name="message_follower_ids"/>
|
||||||
|
<field name="message_ids"/>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -930,6 +905,7 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search>
|
<search>
|
||||||
<field name="functional_tool_id"/>
|
<field name="functional_tool_id"/>
|
||||||
|
<field name="code" string="拆解单编码"/>
|
||||||
<filter name="no_dismantle_state" string="未拆解" domain="[('state','!=','已拆解')]"/>
|
<filter name="no_dismantle_state" string="未拆解" domain="[('state','!=','已拆解')]"/>
|
||||||
<filter name="dismantle_state" string="已拆解" domain="[('state','=','已拆解')]"/>
|
<filter name="dismantle_state" string="已拆解" domain="[('state','=','已拆解')]"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
|
|||||||
@@ -223,8 +223,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
|
|
||||||
image = fields.Binary('图片')
|
image = fields.Binary('图片')
|
||||||
|
|
||||||
@api.onchange('functional_tool_name')
|
@api.depends('functional_tool_name')
|
||||||
def _onchange_functional_tool_name(self):
|
def _compute_functional_tool_name(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
if item.functional_tool_name:
|
if item.functional_tool_name:
|
||||||
inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', item.functional_tool_name)])
|
inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', item.functional_tool_name)])
|
||||||
@@ -233,7 +233,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
|
|
||||||
# 功能刀具组装信息
|
# 功能刀具组装信息
|
||||||
# ===============整体式刀具型号=================
|
# ===============整体式刀具型号=================
|
||||||
integral_freight_barcode = fields.Char('整体式刀具货位')
|
integral_freight_barcode_id = fields.Many2one('sf.shelf.location', string='整体式刀具货位',
|
||||||
|
domain="[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'),('product_num', '>', 0)]")
|
||||||
|
integral_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='整体式刀具批次',
|
||||||
|
domain="[('shelf_location_id', '=', integral_freight_barcode_id)]")
|
||||||
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='整体式刀具型号',
|
||||||
@@ -243,28 +246,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
|
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
|
||||||
related='integral_product_id.brand_id')
|
related='integral_product_id.brand_id')
|
||||||
|
|
||||||
@api.depends('integral_freight_barcode')
|
@api.onchange('integral_freight_barcode_id')
|
||||||
|
def _onchange_integral_freight_barcode_id(self):
|
||||||
|
for item in self:
|
||||||
|
item.integral_freight_lot_id = False
|
||||||
|
|
||||||
|
@api.depends('integral_freight_lot_id')
|
||||||
def _compute_integral_product_id(self):
|
def _compute_integral_product_id(self):
|
||||||
if self.integral_freight_barcode:
|
if self.integral_freight_lot_id:
|
||||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
|
self.integral_product_id = self.integral_freight_lot_id.lot_id.product_id.id
|
||||||
if location:
|
else:
|
||||||
if not location.product_id:
|
self.integral_product_id = False
|
||||||
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
|
|
||||||
else:
|
|
||||||
material_name_id = location.product_id.cutting_tool_material_id
|
|
||||||
if material_name_id and material_name_id.name == '整体式刀具':
|
|
||||||
if location.product_num == 0:
|
|
||||||
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
|
|
||||||
self.integral_product_id = location.product_id.id
|
|
||||||
else:
|
|
||||||
raise ValidationError(
|
|
||||||
'编码为【%s】的货位存放的产品为【%s】,不是整体式刀具,请重新选择!' % (
|
|
||||||
location.barcode, location.product_id.name))
|
|
||||||
else:
|
|
||||||
raise ValidationError('编码为【%s】的货位不存在!' % self.integral_freight_barcode)
|
|
||||||
|
|
||||||
# ===============刀片型号====================
|
# ===============刀片型号====================
|
||||||
blade_freight_barcode = fields.Char('刀片货位')
|
blade_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀片货位',
|
||||||
|
domain="[('product_id.cutting_tool_material_id.name', '=', '刀片'),('product_num', '>', 0)]")
|
||||||
|
blade_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀片批次',
|
||||||
|
domain="[('shelf_location_id', '=', blade_freight_barcode_id)]")
|
||||||
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='刀片型号',
|
||||||
@@ -273,28 +271,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
related='blade_product_id.specification_id')
|
related='blade_product_id.specification_id')
|
||||||
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
|
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
|
||||||
|
|
||||||
@api.depends('blade_freight_barcode')
|
@api.onchange('blade_freight_barcode_id')
|
||||||
|
def _onchange_blade_freight_barcode_id(self):
|
||||||
|
for item in self:
|
||||||
|
item.blade_freight_lot_id = False
|
||||||
|
|
||||||
|
@api.depends('blade_freight_lot_id')
|
||||||
def _compute_blade_product_id(self):
|
def _compute_blade_product_id(self):
|
||||||
if self.blade_freight_barcode:
|
if self.blade_freight_lot_id:
|
||||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
|
self.blade_product_id = self.blade_freight_lot_id.lot_id.product_id.id
|
||||||
if location:
|
else:
|
||||||
if not location.product_id:
|
self.blade_product_id = False
|
||||||
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
|
|
||||||
else:
|
|
||||||
material_name_id = location.product_id.cutting_tool_material_id
|
|
||||||
if material_name_id and material_name_id.name == '刀片':
|
|
||||||
if location.product_num == 0:
|
|
||||||
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
|
|
||||||
self.blade_product_id = location.product_id.id
|
|
||||||
else:
|
|
||||||
raise ValidationError(
|
|
||||||
'编码为【%s】的货位存放的产品为【%s】,不是刀片,请重新选择!' % (
|
|
||||||
location.barcode, location.product_id.name))
|
|
||||||
else:
|
|
||||||
raise ValidationError('编码为【%s】的货位不存在!' % self.blade_freight_barcode)
|
|
||||||
|
|
||||||
# ====================刀杆型号==================
|
# ====================刀杆型号==================
|
||||||
bar_freight_barcode = fields.Char('刀杆货位')
|
bar_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀杆货位',
|
||||||
|
domain="[('product_id.cutting_tool_material_id.name', '=', '刀杆'),('product_num', '>', 0)]")
|
||||||
|
bar_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀杆批次',
|
||||||
|
domain="[('shelf_location_id', '=', bar_freight_barcode_id)]")
|
||||||
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='刀杆型号',
|
||||||
@@ -303,28 +296,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
related='bar_product_id.specification_id')
|
related='bar_product_id.specification_id')
|
||||||
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
|
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
|
||||||
|
|
||||||
@api.depends('bar_freight_barcode')
|
@api.onchange('bar_freight_barcode_id')
|
||||||
|
def _onchange_bar_freight_barcode_id(self):
|
||||||
|
for item in self:
|
||||||
|
item.bar_freight_lot_id = False
|
||||||
|
|
||||||
|
@api.depends('bar_freight_lot_id')
|
||||||
def _compute_bar_product_id(self):
|
def _compute_bar_product_id(self):
|
||||||
if self.bar_freight_barcode:
|
if self.bar_freight_lot_id:
|
||||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
|
self.bar_product_id = self.bar_freight_lot_id.lot_id.product_id.id
|
||||||
if location:
|
else:
|
||||||
if not location.product_id:
|
self.bar_product_id = False
|
||||||
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
|
|
||||||
else:
|
|
||||||
material_name_id = location.product_id.cutting_tool_material_id
|
|
||||||
if material_name_id and material_name_id.name == '刀杆':
|
|
||||||
if location.product_num == 0:
|
|
||||||
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
|
|
||||||
self.bar_product_id = location.product_id.id
|
|
||||||
else:
|
|
||||||
raise ValidationError(
|
|
||||||
'编码为【%s】的货位存放的产品为【%s】,不是刀杆,请重新选择!' % (
|
|
||||||
location.barcode, location.product_id.name))
|
|
||||||
else:
|
|
||||||
raise ValidationError('编码为【%s】的货位不存在!' % self.bar_freight_barcode)
|
|
||||||
|
|
||||||
# ===============刀盘型号===================
|
# ===============刀盘型号===================
|
||||||
pad_freight_barcode = fields.Char('刀盘货位')
|
pad_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀盘货位',
|
||||||
|
domain="[('product_id.cutting_tool_material_id.name', '=', '刀盘'),('product_num', '>', 0)]")
|
||||||
|
pad_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀盘批次',
|
||||||
|
domain="[('shelf_location_id', '=', pad_freight_barcode_id)]")
|
||||||
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='刀盘型号',
|
||||||
@@ -333,29 +321,21 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
related='pad_product_id.specification_id')
|
related='pad_product_id.specification_id')
|
||||||
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
|
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
|
||||||
|
|
||||||
@api.depends('pad_freight_barcode')
|
@api.onchange('pad_freight_barcode_id')
|
||||||
|
def _onchange_pad_freight_barcode_id(self):
|
||||||
|
for item in self:
|
||||||
|
item.pad_freight_lot_id = False
|
||||||
|
|
||||||
|
@api.depends('pad_freight_lot_id')
|
||||||
def _compute_pad_product_id(self):
|
def _compute_pad_product_id(self):
|
||||||
if self.pad_freight_barcode:
|
if self.pad_freight_lot_id:
|
||||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
|
self.pad_product_id = self.pad_freight_lot_id.lot_id.product_id.id
|
||||||
if location:
|
else:
|
||||||
if not location.product_id:
|
self.pad_product_id = False
|
||||||
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
|
|
||||||
else:
|
|
||||||
material_name_id = location.product_id.cutting_tool_material_id
|
|
||||||
if material_name_id and material_name_id.name == '刀盘':
|
|
||||||
if location.product_num == 0:
|
|
||||||
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
|
|
||||||
self.pad_product_id = location.product_id.id
|
|
||||||
else:
|
|
||||||
raise ValidationError(
|
|
||||||
'编码为【%s】的货位存放的产品为【%s】,不是刀盘,请重新选择!' % (
|
|
||||||
location.barcode, location.product_id.name))
|
|
||||||
else:
|
|
||||||
raise ValidationError('编码为【%s】的货位不存在!' % self.pad_freight_barcode)
|
|
||||||
|
|
||||||
# ================刀柄型号===============
|
# ================刀柄型号===============
|
||||||
handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_rfid')
|
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', '刀柄序列号',
|
||||||
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='刀柄名称', compute='_compute_handle_product_id',
|
handle_product_id = fields.Many2one('product.product', string='刀柄名称', compute='_compute_handle_product_id',
|
||||||
@@ -374,7 +354,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
self.pad_product_id = False
|
self.pad_product_id = False
|
||||||
|
|
||||||
# =================夹头型号==============
|
# =================夹头型号==============
|
||||||
chuck_freight_barcode = fields.Char('夹头货位')
|
chuck_freight_barcode_id = fields.Many2one('sf.shelf.location', string='夹头货位',
|
||||||
|
domain="[('product_id.cutting_tool_material_id.name', '=', '夹头'),('product_num', '>', 0)]")
|
||||||
|
chuck_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='夹头批次',
|
||||||
|
domain="[('shelf_location_id', '=', chuck_freight_barcode_id)]")
|
||||||
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='夹头型号',
|
||||||
@@ -383,25 +366,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
related='chuck_product_id.specification_id')
|
related='chuck_product_id.specification_id')
|
||||||
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
|
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
|
||||||
|
|
||||||
@api.depends('chuck_freight_barcode')
|
@api.onchange('chuck_freight_barcode_id')
|
||||||
|
def _onchange_chuck_freight_barcode_id(self):
|
||||||
|
for item in self:
|
||||||
|
item.chuck_freight_lot_id = False
|
||||||
|
|
||||||
|
@api.depends('chuck_freight_lot_id')
|
||||||
def _compute_chuck_product_id(self):
|
def _compute_chuck_product_id(self):
|
||||||
if self.chuck_freight_barcode:
|
if self.chuck_freight_lot_id:
|
||||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
|
self.chuck_product_id = self.chuck_freight_lot_id.lot_id.product_id.id
|
||||||
if location:
|
else:
|
||||||
if not location.product_id:
|
self.chuck_product_id = False
|
||||||
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
|
|
||||||
else:
|
|
||||||
material_name_id = location.product_id.cutting_tool_material_id
|
|
||||||
if material_name_id and material_name_id.name == '夹头':
|
|
||||||
if location.product_num == 0:
|
|
||||||
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
|
|
||||||
self.chuck_product_id = location.product_id.id
|
|
||||||
else:
|
|
||||||
raise ValidationError(
|
|
||||||
'编码为【%s】的货位存放的产品为【%s】,不是夹头,请重新选择!' % (
|
|
||||||
location.barcode, location.product_id.name))
|
|
||||||
else:
|
|
||||||
raise ValidationError('编码为【%s】的货位不存在!' % self.chuck_freight_barcode)
|
|
||||||
|
|
||||||
# ========================================
|
# ========================================
|
||||||
def on_barcode_scanned(self, barcode):
|
def on_barcode_scanned(self, barcode):
|
||||||
@@ -423,23 +398,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
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
|
record.chuck_freight_barcode_id = location.id
|
||||||
elif material_name == '整体式刀具':
|
elif material_name == '整体式刀具':
|
||||||
record.integral_freight_barcode = barcode
|
record.integral_freight_barcode_id = location.id
|
||||||
record.blade_freight_barcode = ''
|
record.blade_freight_barcode_id = False
|
||||||
record.bar_freight_barcode = ''
|
record.bar_freight_barcode_id = False
|
||||||
record.pad_freight_barcode = ''
|
record.pad_freight_barcode_id = False
|
||||||
elif material_name == '刀片':
|
elif material_name == '刀片':
|
||||||
record.blade_freight_barcode = barcode
|
record.blade_freight_barcode_id = location.id
|
||||||
record.integral_freight_barcode = ''
|
record.integral_freight_barcode_id = False
|
||||||
elif material_name == '刀杆':
|
elif material_name == '刀杆':
|
||||||
record.bar_freight_barcode = barcode
|
record.bar_freight_barcode_id = location.id
|
||||||
record.integral_freight_barcode = ''
|
record.integral_freight_barcode_id = False
|
||||||
record.pad_freight_barcode = ''
|
record.pad_freight_barcode_id = False
|
||||||
elif material_name == '刀盘':
|
elif material_name == '刀盘':
|
||||||
record.pad_freight_barcode = barcode
|
record.pad_freight_barcode_id = location.id
|
||||||
record.integral_freight_barcode = ''
|
record.integral_freight_barcode_id = False
|
||||||
record.bar_freight_barcode = ''
|
record.bar_freight_barcode_id = False
|
||||||
else:
|
else:
|
||||||
raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
|
raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
|
||||||
else:
|
else:
|
||||||
@@ -456,15 +431,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
item.handle_freight_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='功能刀具名称', compute='_compute_functional_tool_name',
|
||||||
|
store=True)
|
||||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
|
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
|
||||||
rfid = fields.Char('Rfid', compute='_compute_rfid')
|
rfid = fields.Char('Rfid', compute='_compute_rfid')
|
||||||
code = fields.Char(string='功能刀具编码', compute='_compute_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_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='组装后功能刀具类型', store=True,
|
||||||
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)')
|
compute='_compute_after_assembly_max_lifetime_value')
|
||||||
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)')
|
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)', digits=(10, 3))
|
||||||
|
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)', digits=(10, 3))
|
||||||
after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', default='0')
|
after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', default='0')
|
||||||
cut_time = fields.Integer(string='已切削时间(min)')
|
cut_time = fields.Integer(string='已切削时间(min)')
|
||||||
cut_length = fields.Float(string='已切削长度(mm)')
|
cut_length = fields.Float(string='已切削长度(mm)')
|
||||||
@@ -473,15 +450,75 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
after_assembly_whether_standard_knife = fields.Boolean(string='组装后是否标准刀', default=True)
|
after_assembly_whether_standard_knife = fields.Boolean(string='组装后是否标准刀', default=True)
|
||||||
after_assembly_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')],
|
after_assembly_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')],
|
||||||
string='组装后粗/中/精', default='3')
|
string='组装后粗/中/精', default='3')
|
||||||
after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)')
|
after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)', store=True,
|
||||||
|
compute='_compute_after_assembly_max_lifetime_value')
|
||||||
after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)')
|
after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)')
|
||||||
after_assembly_used_value = fields.Integer(string='组装后已使用值(min)')
|
after_assembly_used_value = fields.Integer(string='组装后已使用值(min)')
|
||||||
after_assembly_tool_loading_length = fields.Float(string='组装后总长度(mm)')
|
after_assembly_tool_loading_length = fields.Float(string='组装后总长度(mm)', digits=(10, 3))
|
||||||
after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)', required=True)
|
after_assembly_handle_length = fields.Float(string='组装后刀柄长度(mm)', digits=(10, 3))
|
||||||
|
after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)', digits=(10, 3),
|
||||||
|
compute='_compute_after_assembly_functional_tool_length')
|
||||||
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='组装后刀具组')
|
after_tool_groups_id = fields.Many2one('sf.tool.groups', string='组装后刀具组', store=True,
|
||||||
|
compute='_compute_after_assembly_max_lifetime_value')
|
||||||
|
|
||||||
|
obtain_measurement_status = fields.Boolean('是否获取测量值', default=False)
|
||||||
|
enable_tool_presetter = fields.Boolean('是否启用刀具预调仪', default=lambda self: self.get_enable_tool_presetter())
|
||||||
|
|
||||||
|
def get_enable_tool_presetter(self):
|
||||||
|
"""
|
||||||
|
获取是否启用刀具预调仪数据
|
||||||
|
"""
|
||||||
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
|
enable_tool_presetter = sf_sync_config['enable_tool_presetter']
|
||||||
|
return enable_tool_presetter
|
||||||
|
|
||||||
|
@api.depends('after_assembly_tool_loading_length', 'after_assembly_handle_length')
|
||||||
|
def _compute_after_assembly_functional_tool_length(self):
|
||||||
|
for item in self:
|
||||||
|
item.after_assembly_functional_tool_length = item.after_assembly_tool_loading_length - item.after_assembly_handle_length
|
||||||
|
|
||||||
|
@api.onchange('after_assembly_max_lifetime_value')
|
||||||
|
def _onchange_after_assembly_alarm_value(self):
|
||||||
|
for item in self:
|
||||||
|
if item.after_assembly_max_lifetime_value:
|
||||||
|
item.after_assembly_alarm_value = item.after_assembly_max_lifetime_value * 0.95
|
||||||
|
|
||||||
|
def get_tool_preset_parameter(self):
|
||||||
|
"""
|
||||||
|
获取刀具预调仪数据
|
||||||
|
"""
|
||||||
|
tool = self.env['sf.functional.tool.assembly'].search([('assembly_order_code', '=', self.assembly_order_code)])
|
||||||
|
tool_loading_length = tool.after_assembly_tool_loading_length
|
||||||
|
diameter = tool.after_assembly_functional_tool_diameter
|
||||||
|
r_angle = tool.after_assembly_knife_tip_r_angle
|
||||||
|
if tool_loading_length == 0 and diameter == 0 and r_angle == 0:
|
||||||
|
raise ValidationError('没有获取到测量数据!')
|
||||||
|
self.write({
|
||||||
|
'after_assembly_tool_loading_length': tool_loading_length, # 总长度
|
||||||
|
'after_assembly_functional_tool_diameter': diameter, # 直径
|
||||||
|
'after_assembly_knife_tip_r_angle': r_angle, # R角
|
||||||
|
'obtain_measurement_status': True # 是否获取测量值
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'res_model': 'sf.functional.tool.assembly.order',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_id': self.id,
|
||||||
|
'target': 'new',
|
||||||
|
'flags': {'form': {'action_buttons': True, 'options': {'mode': 'modal'}}}
|
||||||
|
}
|
||||||
|
|
||||||
|
@api.depends('after_name_id')
|
||||||
|
def _compute_after_assembly_max_lifetime_value(self):
|
||||||
|
for item in self:
|
||||||
|
if item.after_name_id:
|
||||||
|
item.after_assembly_max_lifetime_value = item.after_name_id.life_span
|
||||||
|
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
|
||||||
|
|
||||||
@api.onchange('after_name_id')
|
@api.onchange('after_name_id')
|
||||||
def _onchange_number(self):
|
def _onchange_number(self):
|
||||||
@@ -489,45 +526,32 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
if item.after_name_id:
|
if item.after_name_id:
|
||||||
item.after_assembly_functional_tool_diameter = item.after_name_id.diameter
|
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_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_tool_loading_length = item.after_name_id.tool_length
|
||||||
item.after_assembly_functional_tool_length = item.after_name_id.extension
|
item.after_assembly_functional_tool_length = item.after_name_id.extension
|
||||||
item.hiding_length = item.after_name_id.blade_length
|
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:
|
else:
|
||||||
item.after_assembly_functional_tool_type_id = item.functional_tool_type_id
|
item.after_assembly_functional_tool_type_id = item.functional_tool_type_id.id
|
||||||
item.after_tool_groups_id = item.tool_groups_id.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)]")
|
||||||
|
|
||||||
@api.depends('after_assembly_functional_tool_type_id', 'integral_specification_id', 'bar_specification_id',
|
@api.depends('after_assembly_functional_tool_type_id', 'cutting_tool_cutterhandle_model_id',
|
||||||
'pad_specification_id', 'handle_specification_id', 'after_assembly_tool_loading_length')
|
'after_assembly_functional_tool_diameter', 'after_assembly_tool_loading_length',
|
||||||
|
'after_assembly_knife_tip_r_angle', 'after_assembly_functional_tool_length',
|
||||||
|
'after_assembly_handle_length')
|
||||||
def _compute_code(self):
|
def _compute_code(self):
|
||||||
for obj in self:
|
for obj in self:
|
||||||
str_1 = 'GNDJ-%s' % obj.after_assembly_functional_tool_type_id.code
|
if obj.cutting_tool_cutterhandle_model_id:
|
||||||
str_2 = ''
|
code = obj.cutting_tool_cutterhandle_model_id.code.split('-', 1)[0]
|
||||||
if obj.handle_specification_id:
|
str_1 = '%s-GNDJ-%s-D%sL%sR%sB%sH%s' % (
|
||||||
if obj.integral_specification_id:
|
code, obj.after_assembly_functional_tool_type_id.code, obj.after_assembly_functional_tool_diameter,
|
||||||
str_2 = '%s-D%sL%sB%sH%s-' % (
|
obj.after_assembly_tool_loading_length, obj.after_assembly_knife_tip_r_angle,
|
||||||
str_1, obj.integral_specification_id.blade_diameter, obj.after_assembly_tool_loading_length,
|
round(obj.after_assembly_functional_tool_length, 3), obj.after_assembly_handle_length)
|
||||||
obj.integral_specification_id.blade_length, obj.handle_specification_id.total_length)
|
obj.code = '%s-%s' % (str_1, self._get_code(str_1))
|
||||||
elif obj.bar_specification_id:
|
|
||||||
str_2 = '%s-D%sL%sB%sH%s-' % (
|
|
||||||
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)
|
|
||||||
elif obj.pad_specification_id:
|
|
||||||
str_2 = '%s-D%sL%sB%sH%s-' % (
|
|
||||||
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,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
obj.code = str_2
|
|
||||||
return True
|
|
||||||
obj.code = str_2 + str(self._get_code(str_2))
|
|
||||||
else:
|
else:
|
||||||
obj.code = str_2
|
obj.code = ''
|
||||||
|
|
||||||
def _get_code(self, str_2):
|
def _get_code(self, str_2):
|
||||||
functional_tool_assembly = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
functional_tool_assembly = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
||||||
@@ -550,7 +574,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
obj.after_assembly_functional_tool_name = ''
|
obj.after_assembly_functional_tool_name = ''
|
||||||
|
|
||||||
@api.onchange('integral_freight_barcode')
|
@api.onchange('integral_freight_barcode_id')
|
||||||
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_product_id:
|
if obj.integral_product_id:
|
||||||
@@ -558,7 +582,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
obj.after_assembly_functional_tool_diameter = 0
|
obj.after_assembly_functional_tool_diameter = 0
|
||||||
|
|
||||||
@api.onchange('blade_freight_barcode')
|
@api.onchange('blade_freight_barcode_id')
|
||||||
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_product_id:
|
if obj.blade_product_id:
|
||||||
@@ -574,24 +598,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
record.L_D_number = 0
|
record.L_D_number = 0
|
||||||
|
|
||||||
@api.constrains('after_assembly_tool_loading_length', 'after_assembly_functional_tool_length',
|
|
||||||
'after_assembly_max_lifetime_value', 'after_assembly_alarm_value',
|
|
||||||
'after_assembly_effective_length', 'hiding_length')
|
|
||||||
def _check_length_control(self):
|
|
||||||
for obj in self:
|
|
||||||
if obj.after_assembly_tool_loading_length == 0:
|
|
||||||
raise ValidationError('组装参数信息【总长度】不能为0!!!')
|
|
||||||
if obj.after_assembly_functional_tool_length == 0:
|
|
||||||
raise ValidationError('组装参数信息【伸出长】不能为0!!!')
|
|
||||||
if obj.after_assembly_max_lifetime_value == 0:
|
|
||||||
raise ValidationError('组装参数信息【最大寿命值】不能为0!!!')
|
|
||||||
if obj.after_assembly_alarm_value == 0:
|
|
||||||
raise ValidationError('组装参数信息【报警值】不能为0!!!')
|
|
||||||
if obj.after_assembly_effective_length == 0:
|
|
||||||
raise ValidationError('组装参数信息【有效长】不能为0!!!')
|
|
||||||
if obj.hiding_length == 0:
|
|
||||||
raise ValidationError('组装参数信息【避空长】不能为0!!!')
|
|
||||||
|
|
||||||
def functional_tool_assembly(self):
|
def functional_tool_assembly(self):
|
||||||
"""
|
"""
|
||||||
功能刀具组装
|
功能刀具组装
|
||||||
@@ -611,25 +617,32 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
# 创建组装入库单
|
# 创建组装入库单
|
||||||
# 创建功能刀具批次/序列号记录
|
# 创建功能刀具批次/序列号记录
|
||||||
stock_lot = product_id.create_assemble_warehouse_receipt(self.id, functional_tool_assembly, self)
|
stock_lot = product_id.create_assemble_warehouse_receipt(self.id, functional_tool_assembly, self)
|
||||||
|
# 封装功能刀具数据,用于更新组装单信息
|
||||||
|
desc_1 = self.get_desc_1(stock_lot)
|
||||||
|
# 封装功能刀具数据,用于创建功能刀具记录
|
||||||
|
desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly)
|
||||||
# 创建刀具组装入库单
|
# 创建刀具组装入库单
|
||||||
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.handle_code_id:
|
if self.handle_code_id:
|
||||||
product_id.tool_material_stock_moves(self.handle_code_id, self.assembly_order_code)
|
product_id.tool_material_stock_moves(self.handle_code_id, self.assembly_order_code)
|
||||||
if self.integral_product_id:
|
if self.integral_product_id:
|
||||||
self.integral_product_id.material_stock_moves(self.integral_freight_barcode, self.assembly_order_code)
|
self.integral_product_id.material_stock_moves(self.integral_freight_barcode_id,
|
||||||
|
self.integral_freight_lot_id, self.assembly_order_code)
|
||||||
if self.blade_product_id:
|
if self.blade_product_id:
|
||||||
self.blade_product_id.material_stock_moves(self.blade_freight_barcode, self.assembly_order_code)
|
self.blade_product_id.material_stock_moves(self.blade_freight_barcode_id,
|
||||||
|
self.blade_freight_lot_id, self.assembly_order_code)
|
||||||
if self.bar_product_id:
|
if self.bar_product_id:
|
||||||
self.bar_product_id.material_stock_moves(self.bar_freight_barcode, self.assembly_order_code)
|
self.bar_product_id.material_stock_moves(self.bar_freight_barcode_id,
|
||||||
|
self.bar_freight_lot_id, self.assembly_order_code)
|
||||||
if self.pad_product_id:
|
if self.pad_product_id:
|
||||||
self.pad_product_id.material_stock_moves(self.pad_freight_barcode, self.assembly_order_code)
|
self.pad_product_id.material_stock_moves(self.pad_freight_barcode_id,
|
||||||
|
self.pad_freight_lot_id, self.assembly_order_code)
|
||||||
if self.chuck_product_id:
|
if self.chuck_product_id:
|
||||||
self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode, self.assembly_order_code)
|
self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode_id,
|
||||||
|
self.chuck_freight_lot_id, self.assembly_order_code)
|
||||||
|
|
||||||
# ============================创建功能刀具列表、安全库存记录===============================
|
# ============================创建功能刀具列表、安全库存记录===============================
|
||||||
# 封装功能刀具数据
|
|
||||||
desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly)
|
|
||||||
# 创建功能刀具列表记录
|
# 创建功能刀具列表记录
|
||||||
record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2)
|
record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2)
|
||||||
# 创建安全库存信息
|
# 创建安全库存信息
|
||||||
@@ -638,8 +651,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
}, record_1)
|
}, record_1)
|
||||||
|
|
||||||
# =====================修改功能刀具组装单、机床换刀申请、CAM工单程序用刀计划的状态==============
|
# =====================修改功能刀具组装单、机床换刀申请、CAM工单程序用刀计划的状态==============
|
||||||
# 封装功能刀具数据
|
|
||||||
desc_1 = self.get_desc_1(stock_lot)
|
|
||||||
# 修改功能刀具组装单信息
|
# 修改功能刀具组装单信息
|
||||||
functional_tool_assembly.write(desc_1)
|
functional_tool_assembly.write(desc_1)
|
||||||
if functional_tool_assembly.sf_machine_table_tool_changing_apply_id:
|
if functional_tool_assembly.sf_machine_table_tool_changing_apply_id:
|
||||||
@@ -659,26 +670,54 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
|
|
||||||
def materials_must_be_judged(self):
|
def materials_must_be_judged(self):
|
||||||
"""
|
"""
|
||||||
功能刀具组装物料必填判断
|
功能刀具组装必填判断
|
||||||
"""
|
"""
|
||||||
|
# 物料必填校验
|
||||||
|
if not self.handle_code_id:
|
||||||
|
raise ValidationError('缺少【刀柄】物料信息!')
|
||||||
if not self.integral_product_id and not self.blade_product_id:
|
if not self.integral_product_id and not self.blade_product_id:
|
||||||
raise ValidationError('【整体式刀具】和【刀片】必须填写一个!')
|
raise ValidationError('【整体式刀具】和【刀片】必须填写一个!')
|
||||||
if self.blade_product_id:
|
if self.blade_product_id:
|
||||||
if not self.bar_product_id and not self.pad_product_id:
|
if not self.bar_product_id and not self.pad_product_id:
|
||||||
raise ValidationError('【刀盘】和【刀杆】必须填写一个!')
|
raise ValidationError('【刀盘】和【刀杆】必须填写一个!')
|
||||||
|
# 组装参数必填校验
|
||||||
|
if self.after_assembly_functional_tool_length == 0:
|
||||||
|
raise ValidationError('组装参数信息【伸出长】不能为0!')
|
||||||
|
if self.after_assembly_max_lifetime_value == 0:
|
||||||
|
raise ValidationError('组装参数信息【最大寿命值】不能为0!')
|
||||||
|
if self.after_assembly_alarm_value == 0:
|
||||||
|
raise ValidationError('组装参数信息【报警值】不能为0!')
|
||||||
|
# if self.after_assembly_effective_length == 0:
|
||||||
|
# raise ValidationError('组装参数信息【有效长】不能为0!!!')
|
||||||
|
# if self.hiding_length == 0:
|
||||||
|
# raise ValidationError('组装参数信息【避空长】不能为0!!!')
|
||||||
|
if self.after_assembly_functional_tool_diameter == 0:
|
||||||
|
raise ValidationError('组装参数信息【刀具直径】不能为0!')
|
||||||
|
if self.after_assembly_tool_loading_length == 0:
|
||||||
|
raise ValidationError('组装参数信息【总长度】不能为0!!!')
|
||||||
|
if self.after_assembly_handle_length == 0:
|
||||||
|
raise ValidationError('组装参数信息【刀柄长度】不能为0!')
|
||||||
|
if self.after_assembly_tool_loading_length < self.after_assembly_handle_length:
|
||||||
|
raise ValidationError('组装参数信息【刀柄长度】不能大于【总长度】!')
|
||||||
|
|
||||||
def get_desc_1(self, stock_lot):
|
def get_desc_1(self, stock_lot):
|
||||||
return {
|
return {
|
||||||
|
'start_preset_bool': False,
|
||||||
'barcode_id': stock_lot.id,
|
'barcode_id': stock_lot.id,
|
||||||
'code': self.code,
|
'code': self.code,
|
||||||
'rfid': self.rfid,
|
'rfid': self.rfid,
|
||||||
'tool_groups_id': self.after_tool_groups_id.id,
|
'tool_groups_id': self.after_tool_groups_id.id,
|
||||||
'integral_freight_barcode': self.integral_freight_barcode,
|
|
||||||
'blade_freight_barcode': self.blade_freight_barcode,
|
|
||||||
'bar_freight_barcode': self.bar_freight_barcode,
|
|
||||||
'pad_freight_barcode': self.pad_freight_barcode,
|
|
||||||
'handle_code_id': self.handle_code_id.id,
|
'handle_code_id': self.handle_code_id.id,
|
||||||
'chuck_freight_barcode': self.chuck_freight_barcode,
|
'integral_freight_barcode_id': self.integral_freight_barcode_id.id,
|
||||||
|
'integral_lot_id': self.integral_freight_lot_id.lot_id.id,
|
||||||
|
'blade_freight_barcode_id': self.blade_freight_barcode_id.id,
|
||||||
|
'blade_lot_id': self.blade_freight_lot_id.lot_id.id,
|
||||||
|
'bar_freight_barcode_id': self.bar_freight_barcode_id.id,
|
||||||
|
'bar_lot_id': self.bar_freight_lot_id.lot_id.id,
|
||||||
|
'pad_freight_barcode_id': self.pad_freight_barcode_id.id,
|
||||||
|
'pad_lot_id': self.pad_freight_lot_id.lot_id.id,
|
||||||
|
'chuck_freight_barcode_id': self.chuck_freight_barcode_id.id,
|
||||||
|
'chuck_lot_id': self.chuck_freight_lot_id.lot_id.id,
|
||||||
|
|
||||||
'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,
|
||||||
@@ -694,6 +733,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
'after_assembly_alarm_value': self.after_assembly_alarm_value,
|
'after_assembly_alarm_value': self.after_assembly_alarm_value,
|
||||||
'after_assembly_used_value': self.after_assembly_used_value,
|
'after_assembly_used_value': self.after_assembly_used_value,
|
||||||
'after_assembly_tool_loading_length': self.after_assembly_tool_loading_length,
|
'after_assembly_tool_loading_length': self.after_assembly_tool_loading_length,
|
||||||
|
'after_assembly_handle_length': self.after_assembly_handle_length,
|
||||||
'after_assembly_functional_tool_length': self.after_assembly_functional_tool_length,
|
'after_assembly_functional_tool_length': self.after_assembly_functional_tool_length,
|
||||||
'after_assembly_effective_length': self.after_assembly_effective_length,
|
'after_assembly_effective_length': self.after_assembly_effective_length,
|
||||||
'L_D_number': self.L_D_number,
|
'L_D_number': self.L_D_number,
|
||||||
@@ -726,6 +766,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
'coarse_middle_thin': self.after_assembly_coarse_middle_thin,
|
'coarse_middle_thin': self.after_assembly_coarse_middle_thin,
|
||||||
'new_former': self.after_assembly_new_former,
|
'new_former': self.after_assembly_new_former,
|
||||||
'tool_loading_length': self.after_assembly_tool_loading_length,
|
'tool_loading_length': self.after_assembly_tool_loading_length,
|
||||||
|
'handle_length': self.after_assembly_handle_length,
|
||||||
'functional_tool_length': self.after_assembly_functional_tool_length,
|
'functional_tool_length': self.after_assembly_functional_tool_length,
|
||||||
'effective_length': self.after_assembly_effective_length,
|
'effective_length': self.after_assembly_effective_length,
|
||||||
|
|
||||||
@@ -757,6 +798,7 @@ class StockPicking(models.Model):
|
|||||||
'picking_type_id': picking_type_id.id,
|
'picking_type_id': picking_type_id.id,
|
||||||
'location_id': picking_type_id.default_location_src_id.id,
|
'location_id': picking_type_id.default_location_src_id.id,
|
||||||
'location_dest_id': picking_type_id.default_location_dest_id.id,
|
'location_dest_id': picking_type_id.default_location_dest_id.id,
|
||||||
|
'origin': obj.assembly_order_code
|
||||||
})
|
})
|
||||||
# 创建作业详情对象记录,并绑定到刀具组装入库单
|
# 创建作业详情对象记录,并绑定到刀具组装入库单
|
||||||
self.env['stock.move.line'].create({
|
self.env['stock.move.line'].create({
|
||||||
@@ -807,7 +849,7 @@ class ProductProduct(models.Model):
|
|||||||
logging.info('没有搜索到功能刀具产品:%s' % product_id)
|
logging.info('没有搜索到功能刀具产品:%s' % product_id)
|
||||||
raise ValidationError('没有找到按唯一序列号追溯的功能刀具产品信息!')
|
raise ValidationError('没有找到按唯一序列号追溯的功能刀具产品信息!')
|
||||||
stock_lot = self.env['stock.lot'].create({
|
stock_lot = self.env['stock.lot'].create({
|
||||||
'name': self.get_stock_lot_name(tool_assembly_order_id),
|
'name': self.get_stock_lot_name(obj),
|
||||||
'product_id': product_id[0].id,
|
'product_id': product_id[0].id,
|
||||||
'company_id': self.env.company.id
|
'company_id': self.env.company.id
|
||||||
})
|
})
|
||||||
@@ -820,25 +862,21 @@ class ProductProduct(models.Model):
|
|||||||
|
|
||||||
return stock_lot
|
return stock_lot
|
||||||
|
|
||||||
def get_stock_lot_name(self, tool_assembly_order_id):
|
def get_stock_lot_name(self, obj):
|
||||||
"""
|
"""
|
||||||
生成功能刀具序列号
|
生成功能刀具序列号
|
||||||
"""
|
"""
|
||||||
tool_assembly_order = self.env['sf.functional.tool.assembly.order'].search(
|
company = obj.cutting_tool_cutterhandle_model_id.code.split('-', 1)[0]
|
||||||
[('id', '=', tool_assembly_order_id)])
|
|
||||||
code = 'JKM-T-' + str(tool_assembly_order.after_assembly_functional_tool_type_id.code) + '-' + str(
|
|
||||||
tool_assembly_order.after_assembly_functional_tool_diameter) + '-'
|
|
||||||
new_time = datetime.strptime(str(fields.Date.today()), "%Y-%m-%d").strftime("%Y%m%d")
|
new_time = datetime.strptime(str(fields.Date.today()), "%Y-%m-%d").strftime("%Y%m%d")
|
||||||
code += str(new_time) + '-'
|
code = '%s-GNDJ-%s-%s' % (company, obj.after_assembly_functional_tool_type_id.code, new_time)
|
||||||
stock_lot_id = self.env['stock.lot'].sudo().search(
|
stock_lot_id = self.env['stock.lot'].sudo().search(
|
||||||
[('name', 'like', new_time), ('product_id.categ_type', '=', '功能刀具'),
|
[('name', 'like', code)], limit=1, order="id desc")
|
||||||
('product_id.tracking', '=', 'serial')], limit=1, order="id desc")
|
|
||||||
if not stock_lot_id:
|
if not stock_lot_id:
|
||||||
num = "%03d" % 1
|
num = "%03d" % 1
|
||||||
else:
|
else:
|
||||||
m = int(stock_lot_id.name[-3:]) + 1
|
m = int(stock_lot_id.name[-3:]) + 1
|
||||||
num = "%03d" % m
|
num = "%03d" % m
|
||||||
return code + str(num)
|
return '%s-%s' % (code, num)
|
||||||
|
|
||||||
def tool_material_stock_moves(self, tool_material, assembly_order_code):
|
def tool_material_stock_moves(self, tool_material, assembly_order_code):
|
||||||
"""
|
"""
|
||||||
@@ -851,7 +889,7 @@ class ProductProduct(models.Model):
|
|||||||
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, assembly_order_code, False,
|
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, assembly_order_code, False,
|
||||||
False)
|
False)
|
||||||
|
|
||||||
def material_stock_moves(self, shelf_location_barcode, assembly_order_code):
|
def material_stock_moves(self, shelf_location_barcode_id, lot_id, assembly_order_code):
|
||||||
# 创建库存移动记录
|
# 创建库存移动记录
|
||||||
stock_move_id = self.env['stock.move'].sudo().create({
|
stock_move_id = self.env['stock.move'].sudo().create({
|
||||||
'name': assembly_order_code,
|
'name': assembly_order_code,
|
||||||
@@ -862,21 +900,16 @@ class ProductProduct(models.Model):
|
|||||||
'state': 'done'
|
'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({
|
stock_move_line_id = self.env['stock.move.line'].sudo().create({
|
||||||
'product_id': self.id,
|
'product_id': self.id,
|
||||||
'move_id': stock_move_id.id,
|
'move_id': stock_move_id.id,
|
||||||
'current_location_id': location.id,
|
'lot_id': lot_id.lot_id.id,
|
||||||
|
'current_location_id': shelf_location_barcode_id.id,
|
||||||
'install_tool_time': fields.Datetime.now(),
|
'install_tool_time': fields.Datetime.now(),
|
||||||
'qty_done': 1.0,
|
'qty_done': 1.0,
|
||||||
'state': 'done',
|
'state': 'done',
|
||||||
})
|
})
|
||||||
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
|
return stock_move_id, stock_move_line_id
|
||||||
|
|
||||||
|
|
||||||
@@ -918,14 +951,13 @@ class StockLot(models.Model):
|
|||||||
})
|
})
|
||||||
return stock_move_id, stock_move_line_id
|
return stock_move_id, stock_move_line_id
|
||||||
|
|
||||||
|
# class StockQuant(models.Model):
|
||||||
class StockQuant(models.Model):
|
# _inherit = 'stock.quant'
|
||||||
_inherit = 'stock.quant'
|
#
|
||||||
|
# @api.model_create_multi
|
||||||
@api.model_create_multi
|
# def create(self, vals_list):
|
||||||
def create(self, vals_list):
|
# records = super(StockQuant, self).create(vals_list)
|
||||||
records = super(StockQuant, self).create(vals_list)
|
# for record in records:
|
||||||
for record in records:
|
# if record.lot_id.product_id.categ_id.name == '刀具':
|
||||||
if record.lot_id.product_id.categ_id.name == '刀具':
|
# record.lot_id.enroll_tool_material_stock()
|
||||||
record.lot_id.enroll_tool_material_stock()
|
# return records
|
||||||
return records
|
|
||||||
|
|||||||
@@ -166,11 +166,12 @@
|
|||||||
<sheet>
|
<sheet>
|
||||||
<div class="oe_title">
|
<div class="oe_title">
|
||||||
<h1>
|
<h1>
|
||||||
<field name="production_line_name_id"/>
|
<field name="assembly_order_code"/>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
|
<field name="production_line_name_id"/>
|
||||||
<field name="machine_tool_name_id"/>
|
<field name="machine_tool_name_id"/>
|
||||||
<field name="cutter_spacing_code_id"/>
|
<field name="cutter_spacing_code_id"/>
|
||||||
</group>
|
</group>
|
||||||
@@ -178,24 +179,26 @@
|
|||||||
<field name="image" nolabel="1" widget="image"/>
|
<field name="image" nolabel="1" widget="image"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group string="功能刀具申请信息">
|
<group string="功能刀具申请信息" col="1">
|
||||||
<group>
|
<group>
|
||||||
<field name="functional_tool_name"/>
|
<group>
|
||||||
<field name="functional_tool_type_id"/>
|
<field name="functional_tool_name"/>
|
||||||
<field name="tool_groups_id"/>
|
<field name="functional_tool_type_id"/>
|
||||||
<field name="functional_tool_diameter" string="刀具直径(mm)"/>
|
<field name="tool_groups_id"/>
|
||||||
<field name="knife_tip_r_angle"/>
|
<field name="functional_tool_diameter" string="刀具直径(mm)"/>
|
||||||
<field name="tool_loading_length"/>
|
<field name="knife_tip_r_angle"/>
|
||||||
<field name="functional_tool_length"/>
|
<field name="tool_loading_length"/>
|
||||||
<field name="effective_length"/>
|
<field name="functional_tool_length"/>
|
||||||
</group>
|
<field name="effective_length"/>
|
||||||
<group>
|
</group>
|
||||||
<field name="whether_standard_knife"/>
|
<group>
|
||||||
<field name="coarse_middle_thin"/>
|
<field name="whether_standard_knife"/>
|
||||||
<field name="new_former"/>
|
<field name="coarse_middle_thin"/>
|
||||||
<field name="use_tool_time"/>
|
<field name="new_former"/>
|
||||||
<field name="reason_for_applying"/>
|
<field name="use_tool_time"/>
|
||||||
<!-- <field name="functional_tool_cutting_type"/>-->
|
<field name="reason_for_applying"/>
|
||||||
|
<!-- <field name="functional_tool_cutting_type"/>-->
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group string="组装物料信息" col="1">
|
<group string="组装物料信息" col="1">
|
||||||
@@ -226,13 +229,18 @@
|
|||||||
</group>
|
</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_id', '!=', False),('bar_freight_barcode_id', '!=', False),('pad_freight_barcode_id', '!=', False)]}">
|
||||||
<div>
|
<div>
|
||||||
<separator string="整体式刀具:" style="font-size: 13px;"/>
|
<separator string="整体式刀具:" style="font-size: 13px;"/>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="integral_freight_barcode" string="货位"/>
|
<field name="integral_freight_barcode_id" options="{'no_create': True}"
|
||||||
|
placeholder="请选择" string="货位"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="integral_freight_lot_id" options="{'no_create': True}"
|
||||||
|
placeholder="请选择" string="批次"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="2">
|
<group col="2">
|
||||||
@@ -246,13 +254,18 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="1" attrs="{'invisible': [('integral_freight_barcode', '!=', False)]}">
|
<group col="1" attrs="{'invisible': [('integral_freight_barcode_id', '!=', False)]}">
|
||||||
<div>
|
<div>
|
||||||
<separator string="刀片:" style="font-size: 13px;"/>
|
<separator string="刀片:" style="font-size: 13px;"/>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="blade_freight_barcode" string="货位"/>
|
<field name="blade_freight_barcode_id" options="{'no_create': True}"
|
||||||
|
placeholder="请选择" string="货位"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="blade_freight_lot_id" options="{'no_create': True}"
|
||||||
|
placeholder="请选择" string="批次"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="2">
|
<group col="2">
|
||||||
@@ -267,13 +280,18 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="1"
|
<group col="1"
|
||||||
attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}">
|
attrs="{'invisible': ['|',('integral_freight_barcode_id', '!=', False),('pad_freight_barcode_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_freight_barcode" string="货位"/>
|
<field name="bar_freight_barcode_id" options="{'no_create': True}"
|
||||||
|
placeholder="请选择" string="货位"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="bar_freight_lot_id" options="{'no_create': True}" placeholder="请选择"
|
||||||
|
string="批次"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="2">
|
<group col="2">
|
||||||
@@ -288,13 +306,18 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="1"
|
<group col="1"
|
||||||
attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False)]}">
|
attrs="{'invisible': ['|',('integral_freight_barcode_id', '!=', False),('bar_freight_barcode_id', '!=', False)]}">
|
||||||
<div>
|
<div>
|
||||||
<separator string="刀盘:" style="font-size: 13px;"/>
|
<separator string="刀盘:" style="font-size: 13px;"/>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="pad_freight_barcode" string="货位"/>
|
<field name="pad_freight_barcode_id" options="{'no_create': True}"
|
||||||
|
placeholder="请选择" string="货位"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="pad_freight_lot_id" options="{'no_create': True}" placeholder="请选择"
|
||||||
|
string="批次"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="2">
|
<group col="2">
|
||||||
@@ -314,7 +337,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="chuck_freight_barcode" string="货位"/>
|
<field name="chuck_freight_barcode_id" options="{'no_create': True}"
|
||||||
|
placeholder="请选择" string="货位"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="chuck_freight_lot_id" options="{'no_create': True}"
|
||||||
|
placeholder="请选择" string="批次"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="2">
|
<group col="2">
|
||||||
@@ -330,53 +358,72 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group string="组装参数信息">
|
<group string="组装参数信息" col="1">
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="barcode_id" invisible="True"/>
|
<field name="barcode_id" invisible="True"/>
|
||||||
<field name="code" readonly="True"/>
|
<field name="code" readonly="True"/>
|
||||||
<field name="rfid" class="custom_required"/>
|
<field name="rfid" class="custom_required"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="obtain_measurement_status" invisible="1"/>
|
||||||
|
<button name="get_tool_preset_parameter" string="获取测量值" type="object"
|
||||||
|
attrs="{'invisible': [('enable_tool_presetter', '=', False)]}"
|
||||||
|
class="btn-primary"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<group>
|
||||||
<field name="after_name_id" string="功能刀具名称" placeholder="请选择功能刀具名称"
|
<field name="after_name_id" string="功能刀具名称" placeholder="请选择功能刀具名称"
|
||||||
|
readonly="1"
|
||||||
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="after_assembly_functional_tool_name" string="功能刀具名称"
|
||||||
<field name="after_assembly_functional_tool_type_id" string="功能刀具类型"
|
invisible="1"/>
|
||||||
|
<field name="after_assembly_functional_tool_type_id" string="功能刀具类型" readonly="1"
|
||||||
options="{'no_create': True, 'no_quick_create': True}"/>
|
options="{'no_create': True, 'no_quick_create': True}"/>
|
||||||
<field name="after_tool_groups_id"
|
<field name="after_tool_groups_id" readonly="1"
|
||||||
options="{'no_create': True, 'no_quick_create': True}"/>
|
options="{'no_create': True, 'no_quick_create': True}"/>
|
||||||
<field name="after_assembly_functional_tool_diameter" string="刀具直径(mm)"
|
<field name="after_assembly_whether_standard_knife" string="是否标准刀"/>
|
||||||
class="custom_required"/>
|
<field name="after_assembly_coarse_middle_thin" string="粗/中/精"/>
|
||||||
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"
|
|
||||||
class="custom_required"/>
|
|
||||||
<field name="after_assembly_new_former" string="新/旧"/>
|
<field name="after_assembly_new_former" string="新/旧"/>
|
||||||
<field name="cut_time" attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
|
<field name="cut_time"
|
||||||
|
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
|
||||||
<field name="cut_length"
|
<field name="cut_length"
|
||||||
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
|
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
|
||||||
<field name="cut_number"
|
<field name="cut_number"
|
||||||
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
|
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<group>
|
<group>
|
||||||
<field name="after_assembly_whether_standard_knife" string="是否标准刀"/>
|
<field name="enable_tool_presetter" invisible="1"/>
|
||||||
<field name="after_assembly_coarse_middle_thin" string="粗/中/精"/>
|
<field name="after_assembly_functional_tool_diameter" string="刀具直径(mm)"
|
||||||
<field name="after_assembly_max_lifetime_value" string="最大寿命值(min)"
|
attrs="{'readonly': [('enable_tool_presetter', '=', True)]}"
|
||||||
|
class="custom_required"/>
|
||||||
|
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"
|
||||||
|
attrs="{'readonly': [('enable_tool_presetter', '=', True)]}"
|
||||||
class="custom_required"/>
|
class="custom_required"/>
|
||||||
<field name="after_assembly_alarm_value" string="报警值(min)" class="custom_required"/>
|
|
||||||
<field name="after_assembly_used_value" string="已使用值(min)"/>
|
|
||||||
<field name="after_assembly_tool_loading_length" string="总长度(mm)"
|
<field name="after_assembly_tool_loading_length" string="总长度(mm)"
|
||||||
|
attrs="{'readonly': [('enable_tool_presetter', '=', True)]}"
|
||||||
|
class="custom_required"/>
|
||||||
|
<field name="after_assembly_handle_length" string="刀柄长度(mm)"
|
||||||
class="custom_required"/>
|
class="custom_required"/>
|
||||||
<field name="after_assembly_functional_tool_length" string="伸出长(mm)"
|
<field name="after_assembly_functional_tool_length" string="伸出长(mm)"
|
||||||
class="custom_required"/>
|
class="custom_required"/>
|
||||||
<field name="after_assembly_effective_length" string="有效长(mm)"
|
<field name="after_assembly_max_lifetime_value" string="最大寿命值(min)"
|
||||||
class="custom_required"/>
|
class="custom_required"/>
|
||||||
<field name="hiding_length" class="custom_required"/>
|
<field name="after_assembly_alarm_value" string="报警值(min)"
|
||||||
<field name="L_D_number"/>
|
class="custom_required"/>
|
||||||
|
<field name="after_assembly_used_value" string="已使用值(min)" invisible="1"/>
|
||||||
|
<field name="after_assembly_effective_length" string="有效长(mm)" invisible="1"
|
||||||
|
class="custom_required"/>
|
||||||
|
<field name="hiding_length" class="custom_required" invisible="1"/>
|
||||||
|
<field name="L_D_number" invisible="1"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
<footer>
|
<footer>
|
||||||
<button string="确定" name="functional_tool_assembly" type="object" class="btn-primary"
|
<button string="确定" name="functional_tool_assembly" type="object" class="btn-primary"
|
||||||
|
attrs="{'invisible': [('obtain_measurement_status', '=', False),('enable_tool_presetter', '=', True)]}"
|
||||||
confirm="是否确认申请组装"/>
|
confirm="是否确认申请组装"/>
|
||||||
<button string="取消" class="btn-secondary" special="cancel"/>
|
<button string="取消" class="btn-secondary" special="cancel"/>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -452,8 +452,9 @@ class ShelfLocation(models.Model):
|
|||||||
# product_id = fields.Many2one('product.template', string='产品')
|
# product_id = fields.Many2one('product.template', string='产品')
|
||||||
product_id = fields.Many2one('product.product', string='产品', compute='_compute_product_id', store=True)
|
product_id = fields.Many2one('product.product', string='产品', compute='_compute_product_id', store=True)
|
||||||
product_sn_id = fields.Many2one('stock.lot', string='产品序列号')
|
product_sn_id = fields.Many2one('stock.lot', string='产品序列号')
|
||||||
|
product_sn_ids = fields.One2many('sf.shelf.location.lot', 'shelf_location_id', string='产品批次号')
|
||||||
# 产品数量
|
# 产品数量
|
||||||
product_num = fields.Integer('数量')
|
product_num = fields.Integer('总数量', compute='_compute_number', store=True)
|
||||||
|
|
||||||
@api.depends('product_num')
|
@api.depends('product_num')
|
||||||
def _compute_product_num(self):
|
def _compute_product_num(self):
|
||||||
@@ -463,6 +464,15 @@ class ShelfLocation(models.Model):
|
|||||||
elif record.product_num == 0:
|
elif record.product_num == 0:
|
||||||
record.location_status = '空闲'
|
record.location_status = '空闲'
|
||||||
|
|
||||||
|
@api.depends('product_sn_ids.qty')
|
||||||
|
def _compute_number(self):
|
||||||
|
for item in self:
|
||||||
|
if item.product_sn_ids:
|
||||||
|
qty = 0
|
||||||
|
for product_sn_id in item.product_sn_ids:
|
||||||
|
qty += product_sn_id.qty
|
||||||
|
item.product_num = qty
|
||||||
|
|
||||||
# 修改货位状态为禁用
|
# 修改货位状态为禁用
|
||||||
def action_location_status_disable(self):
|
def action_location_status_disable(self):
|
||||||
self.location_status = '禁用'
|
self.location_status = '禁用'
|
||||||
@@ -471,7 +481,7 @@ class ShelfLocation(models.Model):
|
|||||||
def action_location_status_enable(self):
|
def action_location_status_enable(self):
|
||||||
self.location_status = '空闲'
|
self.location_status = '空闲'
|
||||||
|
|
||||||
@api.depends('product_sn_id')
|
@api.depends('product_sn_id', 'product_sn_ids')
|
||||||
def _compute_product_id(self):
|
def _compute_product_id(self):
|
||||||
"""
|
"""
|
||||||
根据产品序列号,获取产品
|
根据产品序列号,获取产品
|
||||||
@@ -484,7 +494,8 @@ class ShelfLocation(models.Model):
|
|||||||
record.sudo().product_num = 1
|
record.sudo().product_num = 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('eeeeeee占用', e)
|
print('eeeeeee占用', e)
|
||||||
|
elif record.product_sn_ids:
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
record.sudo().product_id = False
|
record.sudo().product_id = False
|
||||||
@@ -525,7 +536,24 @@ class ShelfLocation(models.Model):
|
|||||||
return records
|
return records
|
||||||
|
|
||||||
|
|
||||||
class Sf_stock_move_line(models.Model):
|
class SfShelfLocationLot(models.Model):
|
||||||
|
_name = 'sf.shelf.location.lot'
|
||||||
|
_description = '批次数量'
|
||||||
|
|
||||||
|
name = fields.Char('名称', related='lot_id.name')
|
||||||
|
shelf_location_id = fields.Many2one('sf.shelf.location', string="货位")
|
||||||
|
lot_id = fields.Many2one('stock.lot', string='批次号')
|
||||||
|
qty = fields.Integer('数量')
|
||||||
|
qty_num = fields.Integer('变更数量')
|
||||||
|
|
||||||
|
@api.onchange('qty_num')
|
||||||
|
def _onchange_qty_num(self):
|
||||||
|
for item in self:
|
||||||
|
if item.qty_num > item.qty:
|
||||||
|
raise ValidationError('变更数量不能比库存数量大!!!')
|
||||||
|
|
||||||
|
|
||||||
|
class SfStockMoveLine(models.Model):
|
||||||
_name = 'stock.move.line'
|
_name = 'stock.move.line'
|
||||||
_inherit = ['stock.move.line', 'printing.utils']
|
_inherit = ['stock.move.line', 'printing.utils']
|
||||||
|
|
||||||
@@ -825,15 +853,20 @@ class Sf_stock_move_line(models.Model):
|
|||||||
obj = self.env['sf.shelf.location'].search([('name', '=',
|
obj = self.env['sf.shelf.location'].search([('name', '=',
|
||||||
self.destination_location_id.name)])
|
self.destination_location_id.name)])
|
||||||
if record.lot_id:
|
if record.lot_id:
|
||||||
shelf_location_obj = self.env['sf.shelf.location'].search(
|
if record.product_id.tracking == 'serial':
|
||||||
[('product_sn_id', '=', record.lot_id.id)])
|
shelf_location_obj = self.env['sf.shelf.location'].search(
|
||||||
if shelf_location_obj:
|
[('product_sn_id', '=', record.lot_id.id)])
|
||||||
shelf_location_obj.product_sn_id = False
|
if shelf_location_obj:
|
||||||
if obj:
|
shelf_location_obj.product_sn_id = False
|
||||||
obj.product_sn_id = record.lot_id.id
|
if obj:
|
||||||
else:
|
obj.product_sn_id = record.lot_id.id
|
||||||
if obj:
|
else:
|
||||||
obj.product_sn_id = record.lot_id.id
|
if obj:
|
||||||
|
obj.product_sn_id = record.lot_id.id
|
||||||
|
elif record.product_id.tracking == 'lot':
|
||||||
|
self.put_shelf_location(record)
|
||||||
|
if not obj.product_id:
|
||||||
|
obj.product_id = record.product_id.id
|
||||||
else:
|
else:
|
||||||
if obj:
|
if obj:
|
||||||
obj.product_id = record.product_id.id
|
obj.product_id = record.product_id.id
|
||||||
@@ -853,6 +886,47 @@ class Sf_stock_move_line(models.Model):
|
|||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
'【%s】货位已经被占用,请重新选择!!!' % item.destination_location_id.barcode)
|
'【%s】货位已经被占用,请重新选择!!!' % item.destination_location_id.barcode)
|
||||||
|
|
||||||
|
def put_shelf_location(self, vals):
|
||||||
|
"""
|
||||||
|
对货位的批量数据进行数量计算
|
||||||
|
"""
|
||||||
|
for record in vals:
|
||||||
|
if record.lot_id and record.product_id.tracking == 'lot':
|
||||||
|
if record.current_location_id:
|
||||||
|
location_lot = self.env['sf.shelf.location.lot'].sudo().search(
|
||||||
|
[('shelf_location_id', '=', record.current_location_id.id), ('lot_id', '=', record.lot_id.id)])
|
||||||
|
if location_lot:
|
||||||
|
location_lot.qty -= record.qty_done
|
||||||
|
if location_lot.qty == 0:
|
||||||
|
location_lot.unlink()
|
||||||
|
elif location_lot.qty < 0:
|
||||||
|
raise ValidationError('【%s】货位【%s】批次的【%s】产品数量不足!' % (
|
||||||
|
record.current_location_id.barcode, record.lot_id.name, record.product_id.name))
|
||||||
|
else:
|
||||||
|
raise ValidationError('【%s】货位不存在【%s】批次的【%s】产品' % (
|
||||||
|
record.current_location_id.barcode, record.lot_id.name, record.product_id.name))
|
||||||
|
if record.destination_location_id:
|
||||||
|
location_lot = self.env['sf.shelf.location.lot'].sudo().search(
|
||||||
|
[('shelf_location_id', '=', record.destination_location_id.id),
|
||||||
|
('lot_id', '=', record.lot_id.id)])
|
||||||
|
if location_lot:
|
||||||
|
location_lot.qty += record.qty_done
|
||||||
|
else:
|
||||||
|
self.env['sf.shelf.location.lot'].sudo().create({
|
||||||
|
'shelf_location_id': record.destination_location_id.id,
|
||||||
|
'lot_id': record.lot_id.id,
|
||||||
|
'qty': record.qty_done
|
||||||
|
})
|
||||||
|
if not record.destination_location_id.product_id:
|
||||||
|
record.destination_location_id.product_id = record.product_id.id
|
||||||
|
|
||||||
|
@api.model_create_multi
|
||||||
|
def create(self, vals_list):
|
||||||
|
|
||||||
|
records = super(SfStockMoveLine, self).create(vals_list)
|
||||||
|
self.put_shelf_location(records)
|
||||||
|
return records
|
||||||
|
|
||||||
|
|
||||||
class SfStockPicking(models.Model):
|
class SfStockPicking(models.Model):
|
||||||
_inherit = 'stock.picking'
|
_inherit = 'stock.picking'
|
||||||
@@ -894,6 +968,9 @@ class SfStockPicking(models.Model):
|
|||||||
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 ''):
|
||||||
for item in move.move_line_nosuggest_ids:
|
for item in move.move_line_nosuggest_ids:
|
||||||
|
if item.rfid:
|
||||||
|
if self.env['stock.lot'].search([('rfid', '=', item.rfid)]):
|
||||||
|
raise ValidationError('该Rfid【%s】在系统中已经存在,请重新录入!' % item.rfid)
|
||||||
if item.location_dest_id.name == '进货':
|
if item.location_dest_id.name == '进货':
|
||||||
if not item.rfid:
|
if not item.rfid:
|
||||||
raise ValidationError('你需要提供%s的Rfid' % move.product_id.name)
|
raise ValidationError('你需要提供%s的Rfid' % move.product_id.name)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
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_sf_shelf_location_group_sf_stock_user_group_sf_stock_user,sf.shelf.location,model_sf_shelf_location,sf_base.group_sf_stock_user,1,0,0,0
|
access_sf_shelf_location_group_sf_stock_user_group_sf_stock_user,sf.shelf.location,model_sf_shelf_location,sf_base.group_sf_stock_user,1,0,0,0
|
||||||
|
access_sf_shelf_location_lot_group_sf_stock_user_group_sf_stock_user,sf.shelf.location.lot,model_sf_shelf_location_lot,sf_base.group_sf_stock_user,1,0,0,0
|
||||||
access_sf_shelf_location_group_sf_stock_manager,sf.shelf.location,model_sf_shelf_location,sf_base.group_sf_stock_manager,1,1,1,0
|
access_sf_shelf_location_group_sf_stock_manager,sf.shelf.location,model_sf_shelf_location,sf_base.group_sf_stock_manager,1,1,1,0
|
||||||
|
access_sf_shelf_location_lot_group_sf_stock_manager,sf.shelf.location.lot,model_sf_shelf_location_lot,sf_base.group_sf_stock_manager,1,1,1,0
|
||||||
access_sf_shelf_group_sf_stock_user_group_sf_stock_user,sf.shelf.group.sf.stock.user,model_sf_shelf,sf_base.group_sf_stock_user,1,0,0,0
|
access_sf_shelf_group_sf_stock_user_group_sf_stock_user,sf.shelf.group.sf.stock.user,model_sf_shelf,sf_base.group_sf_stock_user,1,0,0,0
|
||||||
access_sf_shelf_group_sf_stock_manager,sf.shelf.group.sf.stock.manager,model_sf_shelf,sf_base.group_sf_stock_manager,1,1,1,0
|
access_sf_shelf_group_sf_stock_manager,sf.shelf.group.sf.stock.manager,model_sf_shelf,sf_base.group_sf_stock_manager,1,1,1,0
|
||||||
|
|
||||||
@@ -101,6 +103,7 @@ access_stock_replenish_option_group_sf_stock_user,stock.replenishment.option,sto
|
|||||||
access_mrp_production_group_sf_stock_user,mrp.production,mrp.model_mrp_production,sf_base.group_sf_stock_user,1,1,1,0
|
access_mrp_production_group_sf_stock_user,mrp.production,mrp.model_mrp_production,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
|
|
||||||
access_sf_shelf_location_group_plan_dispatch,sf.shelf.location,model_sf_shelf_location,sf_base.group_plan_dispatch,1,0,0,0
|
access_sf_shelf_location_group_plan_dispatch,sf.shelf.location,model_sf_shelf_location,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
|
access_sf_shelf_location_lot_group_plan_dispatch,sf.shelf.location.lot,model_sf_shelf_location_lot,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
access_stock_move,stock.move,stock.model_stock_move,sf_base.group_plan_dispatch,1,1,1,0
|
access_stock_move,stock.move,stock.model_stock_move,sf_base.group_plan_dispatch,1,1,1,0
|
||||||
access_stock_picking_group_plan_dispatch,stock.picking,stock.model_stock_picking,sf_base.group_plan_dispatch,1,0,0,0
|
access_stock_picking_group_plan_dispatch,stock.picking,stock.model_stock_picking,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
access_stock_lot_group_plan_dispatch,stock.lot,stock.model_stock_lot,sf_base.group_plan_dispatch,1,0,0,0
|
access_stock_lot_group_plan_dispatch,stock.lot,stock.model_stock_lot,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
@@ -142,6 +145,9 @@ access_sf_shelf_location_wizard_group_sf_stock_manager,sf_shelf_location_wizard_
|
|||||||
access_sf_shelf_location_group_sf_tool_user,sf.shelf.location.group_sf_tool_user,model_sf_shelf_location,sf_base.group_sf_tool_user,1,1,0,0
|
access_sf_shelf_location_group_sf_tool_user,sf.shelf.location.group_sf_tool_user,model_sf_shelf_location,sf_base.group_sf_tool_user,1,1,0,0
|
||||||
access_sf_shelf_group_user,sf.shelf.location.group_user,model_sf_shelf_location,base.group_user,1,1,0,0
|
access_sf_shelf_group_user,sf.shelf.location.group_user,model_sf_shelf_location,base.group_user,1,1,0,0
|
||||||
|
|
||||||
|
access_sf_shelf_location_lot_group_sf_tool_user,sf.shelf.location.lot.group_sf_tool_user,model_sf_shelf_location_lot,sf_base.group_sf_tool_user,1,1,0,0
|
||||||
|
access_sf_shelf_lot_group_user,sf.shelf.location.lot.group_user,model_sf_shelf_location_lot,base.group_user,1,1,0,0
|
||||||
|
|
||||||
|
|
||||||
access_ir_model_group_sf_stock_user,ir_model_group_sf_stock_user,base.model_ir_model,sf_base.group_sf_stock_user,1,1,0,0
|
access_ir_model_group_sf_stock_user,ir_model_group_sf_stock_user,base.model_ir_model,sf_base.group_sf_stock_user,1,1,0,0
|
||||||
access_mrp_workorder_group_sf_stock_user,mrp_workorder_group_sf_stock_user,mrp.model_mrp_workorder,sf_base.group_sf_stock_user,1,0,0,0
|
access_mrp_workorder_group_sf_stock_user,mrp_workorder_group_sf_stock_user,mrp.model_mrp_workorder,sf_base.group_sf_stock_user,1,0,0,0
|
||||||
|
|||||||
|
@@ -133,9 +133,11 @@
|
|||||||
type="action"
|
type="action"
|
||||||
context="{'default_name':name,
|
context="{'default_name':name,
|
||||||
'default_current_name':name,
|
'default_current_name':name,
|
||||||
|
'default_current_product_sn_ids':product_sn_ids,
|
||||||
|
'default_lot_id':product_sn_id,
|
||||||
'default_current_shelf_id':shelf_id,
|
'default_current_shelf_id':shelf_id,
|
||||||
'default_current_location_id':location_id,
|
'default_current_location_id':location_id,
|
||||||
'default_current_barcode':barcode,
|
'default_current_barcode_id':id,
|
||||||
'default_current_product_id':product_id,
|
'default_current_product_id':product_id,
|
||||||
}"
|
}"
|
||||||
class="btn-primary" attrs="{'invisible':[('location_status','!=','占用')]}"/>
|
class="btn-primary" attrs="{'invisible':[('location_status','!=','占用')]}"/>
|
||||||
@@ -169,8 +171,16 @@
|
|||||||
<field name="name" readonly="1"/>
|
<field name="name" readonly="1"/>
|
||||||
<field name="shelf_id" readonly="1"/>
|
<field name="shelf_id" readonly="1"/>
|
||||||
<field name="location_id" readonly="1"/>
|
<field name="location_id" readonly="1"/>
|
||||||
<field name="product_sn_id" options="{'no_create': True}"/>
|
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
|
<field name="product_sn_id" options="{'no_create': True}"
|
||||||
|
attrs="{'invisible': [('product_sn_ids', '!=', [])]}"/>
|
||||||
|
<field name="product_sn_ids"
|
||||||
|
attrs="{'invisible': [('product_sn_ids', '=', [])]}">
|
||||||
|
<tree edit="1" create="0" delete="0" editable="bottom">
|
||||||
|
<field name="lot_id" readonly="1"/>
|
||||||
|
<field name="qty" readonly="1"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
<field name="product_num" readonly="1"/>
|
<field name="product_num" readonly="1"/>
|
||||||
<field name="location_status"/>
|
<field name="location_status"/>
|
||||||
<field name="storage_time" widget="datetime"/>
|
<field name="storage_time" widget="datetime"/>
|
||||||
|
|||||||
@@ -8,17 +8,23 @@ class ShelfLocationWizard(models.TransientModel):
|
|||||||
|
|
||||||
name = fields.Char('')
|
name = fields.Char('')
|
||||||
|
|
||||||
current_location_id = fields.Many2one('stock.location', string='所属库区', readonly=True)
|
lot_id = fields.Many2one('stock.lot', string="序列号", readonly=True)
|
||||||
|
|
||||||
|
current_location_id = fields.Many2one('stock.location', string='所属库区', readonly=True)
|
||||||
current_shelf_id = fields.Many2one('sf.shelf', string='当前货架', readonly=True)
|
current_shelf_id = fields.Many2one('sf.shelf', string='当前货架', readonly=True)
|
||||||
current_barcode = fields.Char('当前货位编码', readonly=True)
|
current_barcode_id = fields.Many2one('sf.shelf.location', string='当前货位编码', readonly=True)
|
||||||
current_name = fields.Char('当前货位名称', readonly=True)
|
current_name = fields.Char('当前货位名称', readonly=True)
|
||||||
current_product_id = fields.Many2one('product.product', string='产品', readonly=True)
|
current_product_id = fields.Many2one('product.product', string='产品', readonly=True)
|
||||||
|
current_product_sn_ids = fields.Many2many('sf.shelf.location.lot', 'shelf_location_wizard', string='产品批次号',
|
||||||
|
readonly=True)
|
||||||
|
|
||||||
|
destination_location_id = fields.Many2one('stock.location', string='目标库区', compute='_compute_destination_name')
|
||||||
destination_shelf_id = fields.Many2one('sf.shelf', string='目标货架', compute='_compute_destination_name')
|
destination_shelf_id = fields.Many2one('sf.shelf', string='目标货架', compute='_compute_destination_name')
|
||||||
destination_barcode_id = fields.Many2one('sf.shelf.location', string='目标货位编码', required=True,
|
destination_barcode_id = fields.Many2one('sf.shelf.location', string='目标货位编码', required=True,
|
||||||
domain="")
|
domain="[('product_id', 'in', (False, current_product_id))]")
|
||||||
destination_name = fields.Char('目标货位名称', compute='_compute_destination_name')
|
destination_name = fields.Char('目标货位名称', compute='_compute_destination_name')
|
||||||
|
destination_product_sn_ids = fields.Many2many('sf.shelf.location.lot', 'shelf_location_wizard', string='批次号',
|
||||||
|
domain="[('shelf_location_id', '=', current_barcode_id)]")
|
||||||
|
|
||||||
def return_domain(self):
|
def return_domain(self):
|
||||||
val = [('location_status', '=', '空闲')]
|
val = [('location_status', '=', '空闲')]
|
||||||
@@ -32,9 +38,11 @@ class ShelfLocationWizard(models.TransientModel):
|
|||||||
def _compute_destination_name(self):
|
def _compute_destination_name(self):
|
||||||
if self.destination_barcode_id:
|
if self.destination_barcode_id:
|
||||||
self.destination_name = self.destination_barcode_id.name
|
self.destination_name = self.destination_barcode_id.name
|
||||||
|
self.destination_location_id = self.destination_barcode_id.location_id.id
|
||||||
self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
||||||
else:
|
else:
|
||||||
self.destination_name = ''
|
self.destination_name = ''
|
||||||
|
self.destination_location_id = False
|
||||||
self.destination_shelf_id = False
|
self.destination_shelf_id = False
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -43,22 +51,46 @@ class ShelfLocationWizard(models.TransientModel):
|
|||||||
# if self.destination_barcode_id:
|
# if self.destination_barcode_id:
|
||||||
# self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
# self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
||||||
|
|
||||||
def confirm_the_change(self):
|
def create_stock_moves(self, lot_id, num):
|
||||||
shelf_location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.current_barcode)])
|
# 创建产品货位变更的库存移动记录
|
||||||
# 变更货位
|
stock_move_id = self.env['stock.move'].sudo().create({
|
||||||
if self.destination_barcode_id and shelf_location:
|
'name': 'HWBG/%s' % self.id,
|
||||||
if self.destination_barcode_id.product_id and self.destination_barcode_id.product_id == shelf_location.product_id and not self.destination_barcode_id.product_sn_id:
|
'product_id': self.current_product_id.id,
|
||||||
self.destination_barcode_id.product_num += shelf_location.product_num
|
'location_id': self.current_location_id.id,
|
||||||
else:
|
'location_dest_id': self.destination_location_id.id,
|
||||||
self.destination_barcode_id.product_sn_id = shelf_location.product_sn_id.id
|
'product_uom_qty': num,
|
||||||
self.destination_barcode_id.product_id = shelf_location.product_id.id
|
'state': 'done'
|
||||||
self.destination_barcode_id.product_num = shelf_location.product_num
|
})
|
||||||
|
# 创建移动历史记录
|
||||||
|
stock_move_line_id = self.env['stock.move.line'].sudo().create({
|
||||||
|
'product_id': self.current_product_id.id,
|
||||||
|
'lot_id': lot_id.id,
|
||||||
|
'move_id': stock_move_id.id,
|
||||||
|
'current_location_id': self.current_barcode_id.id,
|
||||||
|
'destination_location_id': self.destination_barcode_id.id,
|
||||||
|
'install_tool_time': fields.Datetime.now(),
|
||||||
|
'qty_done': num,
|
||||||
|
'state': 'done'
|
||||||
|
})
|
||||||
|
|
||||||
shelf_location.product_sn_id = False
|
return stock_move_id, stock_move_line_id
|
||||||
shelf_location.product_id = False
|
|
||||||
shelf_location.product_num = 0
|
def confirm_the_change(self):
|
||||||
|
if self.destination_barcode_id:
|
||||||
|
if self.lot_id:
|
||||||
|
self.current_barcode_id.product_sn_id = False
|
||||||
|
self.destination_barcode_id.product_sn_id = self.lot_id.id
|
||||||
|
self.create_stock_moves(self.lot_id, 1)
|
||||||
|
elif self.current_product_sn_ids:
|
||||||
|
for current_product_sn_id in self.current_product_sn_ids:
|
||||||
|
self.create_stock_moves(current_product_sn_id.lot_id, current_product_sn_id.qty_num)
|
||||||
|
current_product_sn_id.write({
|
||||||
|
'qty_num': 0
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError('没有需要变更的批次/序列号!')
|
||||||
else:
|
else:
|
||||||
raise ValidationError('目标货位出错,请联系管理员!')
|
raise ValidationError('请选择目标货位编码!')
|
||||||
|
|
||||||
# 关闭弹出窗口
|
# 关闭弹出窗口
|
||||||
return {'type': 'ir.actions.act_window_close'}
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
|
|||||||
@@ -6,27 +6,45 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="货位变更">
|
<form string="货位变更">
|
||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
<group col="1">
|
||||||
<group string="初始货位">
|
<group string="初始货位">
|
||||||
<group>
|
<group>
|
||||||
<field name="current_location_id"/>
|
<field name="current_location_id"/>
|
||||||
<field name="current_shelf_id" string="货架"/>
|
<field name="current_shelf_id" string="货架"/>
|
||||||
<field name="current_barcode" string="编码"/>
|
|
||||||
<field name="current_name" string="名称"/>
|
<field name="current_name" string="名称"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="current_barcode_id" string="编码"/>
|
||||||
|
<field name="lot_id" attrs="{'invisible': [('lot_id', '=', False)]}"/>
|
||||||
|
</group>
|
||||||
|
<field name="current_product_sn_ids"
|
||||||
|
attrs="{'invisible': [('current_product_sn_ids', '=', [])]}">
|
||||||
|
<tree edit="1" create="0" delete="0" editable="bottom">
|
||||||
|
<field name="lot_id" readonly="1"/>
|
||||||
|
<field name="qty" readonly="1"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<group string="目标货位">
|
<group string="目标货位">
|
||||||
<group>
|
<group>
|
||||||
<field name="current_location_id"/>
|
<field name="destination_location_id"/>
|
||||||
<field name="destination_shelf_id" string="货架" options="{'no_create': True}"
|
<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="destination_name" string="名称"/>
|
||||||
<field name="current_product_id" invisible="1"/>
|
<field name="current_product_id" invisible="1"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="destination_barcode_id" string="编码" options="{'no_create': True}"
|
||||||
|
placeholder="请选择目标货位"/>
|
||||||
|
<field name="lot_id" attrs="{'invisible': [('lot_id', '=', False)]}"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
|
<field name="destination_product_sn_ids"
|
||||||
|
attrs="{'invisible': [('current_product_sn_ids', '=', [])]}">
|
||||||
|
<tree edit="1" create="0" delete="1" editable="bottom">
|
||||||
|
<field name="lot_id" readonly="1"/>
|
||||||
|
<field name="qty_num"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
<footer>
|
<footer>
|
||||||
|
|||||||
Reference in New Issue
Block a user