Compare commits
114 Commits
修复编程单下发接口
...
feature/优化
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85aa13ec0a | ||
|
|
8c285c0eb5 | ||
|
|
22e24c5ed3 | ||
|
|
4459ed2e81 | ||
|
|
52bf899a1f | ||
|
|
002727070d | ||
|
|
63ea5d67e8 | ||
|
|
81327f04de | ||
|
|
5e1f6a09d1 | ||
|
|
e8c86c6306 | ||
|
|
8937bfb5dd | ||
|
|
fd6b579e2a | ||
|
|
0b2b162d85 | ||
|
|
2eaec4fa58 | ||
|
|
e306d02ff2 | ||
|
|
09c56b2c07 | ||
|
|
f4926820fe | ||
|
|
5361fa7678 | ||
|
|
edf8e1004e | ||
|
|
2dc12d6a8c | ||
|
|
17e2a3ffc3 | ||
|
|
94b718533f | ||
|
|
e258e43b51 | ||
|
|
1af160542c | ||
|
|
71246af16a | ||
|
|
d2f4e5495e | ||
|
|
ba2b833aa8 | ||
|
|
cf0afd6c64 | ||
|
|
e290760895 | ||
|
|
fdfd01605d | ||
|
|
19799aefe4 | ||
|
|
f33d7b79fc | ||
|
|
8bd5841d7a | ||
|
|
e9ab57854e | ||
|
|
6fc94042ee | ||
|
|
b70ec36365 | ||
|
|
3738b8d72b | ||
|
|
5fb9326d8b | ||
|
|
2ab9f37062 | ||
|
|
711e0d1437 | ||
|
|
49d55822cc | ||
|
|
ea6de0c248 | ||
|
|
2db81ac2cc | ||
|
|
a673630fd3 | ||
|
|
d213a2cf54 | ||
|
|
6c5b888bba | ||
|
|
d527bc6899 | ||
|
|
aa6b476e35 | ||
|
|
263253e79e | ||
|
|
edda681940 | ||
|
|
7043d2b8b7 | ||
|
|
6d66872dee | ||
|
|
3ab378f3bd | ||
|
|
26c979ef1d | ||
|
|
6405944cf1 | ||
|
|
9aa4858774 | ||
|
|
d883a7ff22 | ||
|
|
17678c53c9 | ||
|
|
fb3cc095b2 | ||
|
|
c437c185a4 | ||
|
|
b3eb3ee8fa | ||
|
|
b9ec821293 | ||
|
|
f8a9fcc0ce | ||
|
|
d12714dd65 | ||
|
|
a1bea537bb | ||
|
|
5350675355 | ||
|
|
65d2593db9 | ||
|
|
a529c5513e | ||
|
|
f5f881f256 | ||
|
|
caf7aaa560 | ||
|
|
d2babec1aa | ||
|
|
0b9c856d56 | ||
|
|
66dc7b540c | ||
|
|
f71d62dad1 | ||
|
|
a1d8b88db2 | ||
|
|
b7a11f0abe | ||
|
|
7ab954ebbc | ||
|
|
f7723f1b9c | ||
|
|
fe88a416a7 | ||
|
|
ef80848e9b | ||
|
|
138dd40a9e | ||
|
|
dc210f7263 | ||
|
|
9055e7ed8b | ||
|
|
6890ddf615 | ||
|
|
6dc29fb50a | ||
|
|
412bf4b9be | ||
|
|
c7df18ace6 | ||
|
|
053eba5887 | ||
|
|
e935b2fa11 | ||
|
|
d5bc610214 | ||
|
|
2ca67eb8ad | ||
|
|
b6a69debd8 | ||
|
|
147ac35239 | ||
|
|
3c3f375120 | ||
|
|
c87f310bb3 | ||
|
|
f53eecbb57 | ||
|
|
1743fa45b5 | ||
|
|
75f30922e6 | ||
|
|
3a0db05c33 | ||
|
|
5f42b5d056 | ||
|
|
c698b50853 | ||
|
|
251786f6be | ||
|
|
66b4df5193 | ||
|
|
57b264b84d | ||
|
|
ff12a86406 | ||
|
|
b0b3ce7d99 | ||
|
|
8d02a94f78 | ||
|
|
4f6e4a8ed3 | ||
|
|
b524e385a1 | ||
|
|
d22f08d187 | ||
|
|
2ba53bbb02 | ||
|
|
38e0a62130 | ||
|
|
bf1b14290e | ||
|
|
1b6ca90bd4 |
@@ -503,4 +503,27 @@ div:has(.o_required_modifier) > label::before {
|
||||
color: #fff;
|
||||
background-color: #4A4F59;
|
||||
border-color: #4A4F59;
|
||||
}
|
||||
|
||||
// 功能刀具组装单 弹窗样式
|
||||
.o_horizontal_separator.mt-4.mb-3.text-uppercase.fw-bolder.small ~ div.col-lg-6 .o_inner_group.col-lg-6 {
|
||||
width: 100%;
|
||||
}
|
||||
.o_horizontal_separator.mt-4.mb-3.text-uppercase.fw-bolder.small ~ div .o_inner_group .o_wrap_field.d-flex.d-sm-contents.flex-column{
|
||||
display: flex!important;
|
||||
flex-direction: row!important;
|
||||
input {
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置表格横向滚动
|
||||
.o_list_renderer.o_renderer {
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
// 设置表单页面label文本不换行
|
||||
.o_form_view .o_group .o_wrap_label .o_form_label {
|
||||
white-space: nowrap;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
.o_data_row .w-100 {
|
||||
width: 40px !important;
|
||||
height: 40px !important;
|
||||
display: block !important;
|
||||
//display: block !important;
|
||||
}
|
||||
|
||||
.o_list_renderer .o_list_table tbody > tr > td:not(.o_list_record_selector):not(.o_handle_cell):not(.o_list_button):not(.o_list_record_remove) {
|
||||
|
||||
@@ -67,9 +67,10 @@ class JdEclp(models.Model):
|
||||
"""
|
||||
判断是否为出库单
|
||||
"""
|
||||
if self.name:
|
||||
is_check_out = self.name.split('/')
|
||||
self.check_out = is_check_out[1]
|
||||
for record in self:
|
||||
if record.name:
|
||||
is_check_out = record.name.split('/')
|
||||
record.check_out = is_check_out[1]
|
||||
|
||||
@api.depends('carrier_tracking_ref')
|
||||
def query_bill_pdf(self):
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<field name='categ_id' class="custom_required" attrs="{'readonly': [('id', '!=', False)]}"/>
|
||||
<field name='is_bfm' invisible="1"/>
|
||||
<field name='categ_type' invisible="1"/>
|
||||
<field name='part_number' attrs="{'invisible': [('categ_type', '!=', '成品')]}"/>
|
||||
<field name='manual_quotation' attrs="{'invisible':[('upload_model_file', '=', [])]}"/>
|
||||
<field name="upload_model_file"
|
||||
widget="many2many_binary"
|
||||
|
||||
@@ -166,11 +166,13 @@ class Manufacturing_Connect(http.Controller):
|
||||
if not workorder:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
logging.info('workorder_state:%s' % workorder.state)
|
||||
if workorder.state != 'ready':
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '工单未就绪'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
work_equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', equipment_id)],
|
||||
limit=1)
|
||||
logging.info('work_equipment_id:%s' % work_equipment_id.name)
|
||||
if not work_equipment_id:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有找到该加工设备'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
@@ -213,7 +215,7 @@ class Manufacturing_Connect(http.Controller):
|
||||
if workorder.state != 'progress':
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单未开始'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
workorder.button_finish()
|
||||
workorder.write({'date_finished': datetime.now()})
|
||||
# workorder.process_state = '待解除装夹'
|
||||
# workorder.sudo().production_id.process_state = '待解除装夹'
|
||||
|
||||
@@ -457,20 +459,21 @@ class Manufacturing_Connect(http.Controller):
|
||||
rfid_code = ret[f'RfidCode{i}']
|
||||
logging.info('RfidCode:%s' % rfid_code)
|
||||
domain = [
|
||||
('feeder_station_destination_id.name', '=', ret['DeviceId']),
|
||||
('workorder_id.rfid_code', '=', rfid_code),
|
||||
('status', '=', '已配送'),
|
||||
('type', '=', '上产线')
|
||||
('rfid_code', '=', rfid_code),
|
||||
('routing_type', '=', 'CNC加工')
|
||||
]
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain,
|
||||
order='id asc')
|
||||
if workpiece_delivery:
|
||||
for wd in workpiece_delivery:
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '待上产线':
|
||||
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
|
||||
if workorder:
|
||||
for order in workorder:
|
||||
if order.production_id.production_line_state == '待上产线':
|
||||
logging.info(
|
||||
'wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||
wd.production_id.write({'production_line_state': '已上产线'})
|
||||
'制造订单产线状态:%s' % order.production_id.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:
|
||||
res = {'Succeed': False, 'ErrorCode': 204,
|
||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||
@@ -511,20 +514,20 @@ class Manufacturing_Connect(http.Controller):
|
||||
rfid_code = ret[f'RfidCode{i}']
|
||||
logging.info('RfidCode:%s' % rfid_code)
|
||||
domain = [
|
||||
('workorder_id.rfid_code', '=', rfid_code),
|
||||
('status', '=', '待下发'),
|
||||
('type', '=', '下产线')
|
||||
('rfid_code', '=', rfid_code),
|
||||
('routing_type', '=', 'CNC加工')
|
||||
]
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain,
|
||||
order='id asc')
|
||||
if workpiece_delivery:
|
||||
for wd in workpiece_delivery:
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
|
||||
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
|
||||
if workorder:
|
||||
for order in workorder:
|
||||
if order.production_id.production_line_state == '已上产线':
|
||||
logging.info(
|
||||
'wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||
wd.production_id.write({'production_line_state': '已下产线'})
|
||||
delivery_Arr.append(wd.id)
|
||||
'制造订单产线状态:%s' % order.production_id.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)])
|
||||
delivery_Arr.append(workpiece_delivery.id)
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 204,
|
||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||
@@ -534,10 +537,14 @@ class Manufacturing_Connect(http.Controller):
|
||||
[('id', 'in', delivery_Arr)])
|
||||
if delivery_workpiece:
|
||||
logging.info('开始向agv下发下产线任务')
|
||||
is_free = delivery_workpiece._check_avgsite_state()
|
||||
if is_free is True:
|
||||
delivery_workpiece._delivery_avg()
|
||||
logging.info('agv下发下产线任务下发完成')
|
||||
agv_site = request.env['sf.agv.site'].sudo().search([])
|
||||
if agv_site:
|
||||
has_site = agv_site.update_site_state()
|
||||
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:
|
||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
||||
except Exception as e:
|
||||
|
||||
@@ -26,20 +26,28 @@ class AgvSetting(models.Model):
|
||||
timestamp = int(time.time())
|
||||
center_control_url += str(timestamp)
|
||||
logging.info('工件配送-请求中控地址:%s' % center_control_url)
|
||||
center_control_r = requests.get(center_control_url, params={}, headers=headers)
|
||||
ret = center_control_r.json()
|
||||
logging.info('工件配送-请求中控站点信息:%s' % ret)
|
||||
self.env['center_control.interface.log'].sudo().create(
|
||||
{'content': ret, 'name': 'AutoDeviceApi/GetAgvStationState?date=%s' % str(timestamp)})
|
||||
if ret['Succeed'] is True:
|
||||
datas = ret['Datas']
|
||||
for item in self:
|
||||
for da in datas:
|
||||
if da['DeviceId'] == item.name:
|
||||
if da['AtHome'] is True:
|
||||
item.state = '占用'
|
||||
else:
|
||||
item.state = '空闲'
|
||||
try:
|
||||
center_control_r = requests.get(center_control_url, headers=headers, timeout=10) # 设置超时为60秒
|
||||
ret = center_control_r.json()
|
||||
logging.info('工件配送-请求中控站点信息:%s' % ret)
|
||||
self.env['center_control.interface.log'].sudo().create(
|
||||
{'content': ret, 'name': 'AutoDeviceApi/GetAgvStationState?date=%s' % str(timestamp)})
|
||||
if ret['Succeed'] is True:
|
||||
datas = ret['Datas']
|
||||
for item in self:
|
||||
for da in datas:
|
||||
if da['DeviceId'] == item.name:
|
||||
if da['AtHome'] is True:
|
||||
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):
|
||||
|
||||
@@ -5,7 +5,7 @@ import re
|
||||
import requests
|
||||
from itertools import groupby
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo.tools import float_compare, float_round, float_is_zero, format_datetime
|
||||
|
||||
@@ -77,6 +77,7 @@ class MrpProduction(models.Model):
|
||||
part_drawing = fields.Binary('零件图纸')
|
||||
|
||||
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
|
||||
rework_production = fields.Many2one('mrp.production', string='返工的制造订单')
|
||||
|
||||
@api.depends(
|
||||
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
|
||||
@@ -154,8 +155,30 @@ class MrpProduction(models.Model):
|
||||
for production in self:
|
||||
production.maintenance_count = len(production.request_ids)
|
||||
|
||||
# 制造订单报废:编程单更新
|
||||
def updateCNC(self):
|
||||
try:
|
||||
res = {'production_no': self.name, 'programming_no': self.programming_no,
|
||||
'order_no': self.origin}
|
||||
logging.info('res=%s:' % res)
|
||||
configsettings = self.env['res.config.settings'].get_values()
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
url = '/api/intelligent_programming/update_intelligent_programmings'
|
||||
config_url = configsettings['sf_url'] + url
|
||||
res['token'] = configsettings['token']
|
||||
ret = requests.post(config_url, json={}, data=res, headers=config_header)
|
||||
ret = ret.json()
|
||||
logging.info('updateCNC-ret:%s' % ret)
|
||||
if ret['status'] == 1:
|
||||
self.write({'work_state': '已编程'})
|
||||
else:
|
||||
raise UserError(ret['message'])
|
||||
except Exception as e:
|
||||
logging.info('updateCNC error:%s' % e)
|
||||
raise UserError("更新程单失败,请联系管理员")
|
||||
|
||||
# cnc程序获取
|
||||
def fetchCNC(self, production_names):
|
||||
def fetchCNC(self, production_names, scrap_production):
|
||||
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
|
||||
quick_order = self.env['quick.easy.order'].search(
|
||||
[('name', '=', cnc.product_id.default_code.rsplit('-', 1)[0])])
|
||||
@@ -171,6 +194,8 @@ class MrpProduction(models.Model):
|
||||
'production_no': production_names,
|
||||
'machine_tool_code': '',
|
||||
'product_name': cnc.product_id.name,
|
||||
'remanufacture_type': '' if not scrap_production else scrap_production.workorder_ids.filtered(
|
||||
lambda b: b.routing_type == "CNC加工").test_results,
|
||||
'model_code': cnc.product_id.model_code,
|
||||
'material_code': self.env['sf.production.materials'].search(
|
||||
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
|
||||
@@ -268,7 +293,7 @@ class MrpProduction(models.Model):
|
||||
# 则根据设备找到工作中心;否则采用前面描述的工作中心分配机制;
|
||||
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
|
||||
|
||||
def _create_workorder3(self):
|
||||
def _create_workorder3(self, is_fetchcnc=False, scrap_production=False):
|
||||
# 根据product_id对self进行分组
|
||||
grouped_product_ids = {k: list(g) for k, g in groupby(self, key=lambda x: x.product_id.id)}
|
||||
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
|
||||
@@ -311,11 +336,16 @@ class MrpProduction(models.Model):
|
||||
production_programming = self.search(
|
||||
[('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)],
|
||||
limit=1, order='id asc')
|
||||
if not production_programming.programming_no:
|
||||
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]))
|
||||
if not production_programming.programming_no or (is_fetchcnc is True and scrap_production):
|
||||
# 制造订单报废/返工也需重新编程
|
||||
if (is_fetchcnc is True and scrap_production) or (
|
||||
is_fetchcnc is False and scrap_production):
|
||||
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]),
|
||||
scrap_production)
|
||||
else:
|
||||
production.write({'programming_no': production_programming.programming_no,
|
||||
'programming_state': '编程中'})
|
||||
|
||||
# # 根据加工面板的面数及对应的工序模板生成工单
|
||||
i = 0
|
||||
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
||||
@@ -379,6 +409,12 @@ class MrpProduction(models.Model):
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
||||
production.workorder_ids = workorders_values
|
||||
if production_programming.programming_state == '已编程':
|
||||
logging.info("production_programming: %s" % production_programming.name)
|
||||
production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').write({
|
||||
'cnc_ids': production_programming.workorder_ids.filtered(
|
||||
lambda
|
||||
t1: t1.routing_type == 'CNC加工').cnc_ids})
|
||||
for workorder in production.workorder_ids:
|
||||
workorder.duration_expected = workorder._get_duration_expected()
|
||||
|
||||
@@ -406,20 +442,15 @@ class MrpProduction(models.Model):
|
||||
|
||||
# 工单排序
|
||||
def _reset_work_order_sequence1(self, k):
|
||||
sequen = 0
|
||||
for rec in self:
|
||||
current_sequence = 10
|
||||
cnc_workorder = rec.workorder_ids.filtered(lambda wo: wo.name == "CNC加工")
|
||||
cnc_back_workorder = rec.workorder_ids.filtered(lambda wo: wo.name == "CNC加工(返工)")
|
||||
for work in rec.workorder_ids:
|
||||
work.sequence = current_sequence
|
||||
current_sequence += 10
|
||||
if work.name == '后置三元质量检测' and work.processing_panel == k:
|
||||
sequen = work.sequence
|
||||
|
||||
for work in rec.workorder_ids:
|
||||
if work.name == '后置三元质量检测(返工)' and work.processing_panel == k:
|
||||
work.sequence = sequen + 2
|
||||
if work.name == 'CNC加工(返工)' and work.processing_panel == k:
|
||||
work.sequence = sequen + 1
|
||||
if work.name == cnc_workorder.name and work.processing_panel == k:
|
||||
cnc_back_workorder.write({'sequence': work.sequence + 1})
|
||||
print(cnc_back_workorder.sequence)
|
||||
elif work.routing_type not in ['装夹预调'] and work != cnc_back_workorder:
|
||||
work.sequence += 1
|
||||
|
||||
# 在制造订单上新增工单
|
||||
def _create_workorder1(self, k):
|
||||
@@ -459,13 +490,7 @@ class MrpProduction(models.Model):
|
||||
order='sequence asc'
|
||||
)
|
||||
i += 1
|
||||
|
||||
for route in routingworkcenter:
|
||||
|
||||
# if route.routing_type == '后置三元质量检测':
|
||||
# workorders_values.append(
|
||||
# self.env['mrp.workorder'].json_workorder_str1(k, production, route)
|
||||
# )
|
||||
if route.routing_type == 'CNC加工':
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str1(k, production, route))
|
||||
@@ -483,18 +508,57 @@ class MrpProduction(models.Model):
|
||||
|
||||
def _reset_work_order_sequence(self):
|
||||
for rec in self:
|
||||
current_sequence = 1
|
||||
sequence_list = {}
|
||||
model_type_id = rec.product_id.product_model_type_id
|
||||
if model_type_id:
|
||||
tmpl_num = 1
|
||||
# 成品工序
|
||||
product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids
|
||||
if product_routing_tmpl_ids:
|
||||
for tmpl_id in product_routing_tmpl_ids:
|
||||
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
|
||||
tmpl_num += 1
|
||||
# 表面工艺工序
|
||||
# 模型类型的表面工艺工序模版
|
||||
surface_tmpl_ids = model_type_id.surface_technics_routing_tmpl_ids
|
||||
# 产品选择的表面工艺
|
||||
model_process_parameters_ids = rec.product_id.model_process_parameters_ids
|
||||
process_dict = {}
|
||||
if model_process_parameters_ids:
|
||||
for process_parameters_id in model_process_parameters_ids:
|
||||
process_id = process_parameters_id.process_id
|
||||
for surface_tmpl_id in surface_tmpl_ids:
|
||||
if process_id == surface_tmpl_id.route_workcenter_id.surface_technics_id:
|
||||
surface_tmpl_name = surface_tmpl_id.route_workcenter_id.name
|
||||
process_dict.update({int(process_id.category_id.code): '%s-%s' % (
|
||||
surface_tmpl_name, process_parameters_id.name)})
|
||||
process_list = sorted(process_dict.keys())
|
||||
for process_num in process_list:
|
||||
sequence_list.update({process_dict.get(process_num): tmpl_num})
|
||||
tmpl_num += 1
|
||||
# 坯料工序
|
||||
tmpl_num = 1
|
||||
embryo_routing_tmpl_ids = model_type_id.embryo_routing_tmpl_ids
|
||||
if embryo_routing_tmpl_ids:
|
||||
for tmpl_id in embryo_routing_tmpl_ids:
|
||||
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
|
||||
tmpl_num += 1
|
||||
else:
|
||||
raise ValidationError('该产品没有选择【模版类型】!')
|
||||
|
||||
for work in rec.workorder_ids:
|
||||
work.sequence = current_sequence
|
||||
current_sequence += 1
|
||||
if sequence_list.get(work.name):
|
||||
work.sequence = sequence_list[work.name]
|
||||
else:
|
||||
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
|
||||
# if work.name == '获取CNC加工程序':
|
||||
# work.button_start()
|
||||
# #work.fetchCNC()
|
||||
# work.button_finish()
|
||||
|
||||
# 创建工单并进行排序
|
||||
def _create_workorder(self):
|
||||
self._create_workorder3()
|
||||
def _create_workorder(self, is_fetchcnc=False, scrap_production=False):
|
||||
self._create_workorder3(is_fetchcnc=is_fetchcnc, scrap_production=scrap_production)
|
||||
self._reset_work_order_sequence()
|
||||
return True
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
('已完工', '已完工'),
|
||||
], string='工序状态', default='待装夹', readonly='True')
|
||||
# 加工图纸
|
||||
processing_drawing = fields.Binary(string='加工图纸', related='production_id.part_drawing')
|
||||
processing_drawing = fields.Binary(string='加工图纸')
|
||||
|
||||
@api.depends('production_id')
|
||||
def _compute_save_name(self):
|
||||
@@ -199,7 +199,12 @@ class ResMrpWorkOrder(models.Model):
|
||||
production_line_state = fields.Selection(related='production_id.production_line_state',
|
||||
string='上/下产线', store=True)
|
||||
detection_report = fields.Binary('检测报告', readonly=True)
|
||||
is_remanufacture = fields.Boolean(string='是否重新生成制造订单', default=True)
|
||||
is_remanufacture = fields.Boolean(string='重新生成制造订单', default=False)
|
||||
is_fetchcnc = fields.Boolean(string='重新获取NC程序', default=False)
|
||||
reason = fields.Selection(
|
||||
[("programming", "编程"), ("clamping", "返工"), ("cutter", "刀具"), ("operate computer", "操机"),
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因")
|
||||
detailed_reason = fields.Text('详细原因')
|
||||
|
||||
@api.onchange('rfid_code')
|
||||
def _onchange(self):
|
||||
@@ -672,18 +677,64 @@ class ResMrpWorkOrder(models.Model):
|
||||
"""
|
||||
重新生成制造订单或者重新生成工单
|
||||
"""
|
||||
if self.test_results == '报废':
|
||||
if self.test_results in ['返工', '报废']:
|
||||
values = self.env['mrp.production'].create_production1_values(self.production_id)
|
||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(
|
||||
self.production_id.company_id).create(
|
||||
values)
|
||||
self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
productions._create_workorder()
|
||||
productions._create_workorder(is_fetchcnc=self.is_fetchcnc, scrap_production=self.production_id)
|
||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||
(
|
||||
p.move_dest_ids.procure_method != 'make_to_order' and
|
||||
not p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
||||
for production_item in productions:
|
||||
process_parameter_workorder = self.env['mrp.workorder'].search(
|
||||
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production_item.id),
|
||||
('is_subcontract', '=', True)])
|
||||
if process_parameter_workorder:
|
||||
is_pick = False
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
|
||||
for i in range(len(sorted_workorders) - 1):
|
||||
if m == 0:
|
||||
is_pick = False
|
||||
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
|
||||
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
|
||||
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
|
||||
if sorted_workorders[i] not in consecutive_workorders:
|
||||
consecutive_workorders.append(sorted_workorders[i])
|
||||
consecutive_workorders.append(sorted_workorders[i + 1])
|
||||
m += 1
|
||||
continue
|
||||
else:
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
||||
production_item)
|
||||
if sorted_workorders[i] in consecutive_workorders:
|
||||
is_pick = True
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
|
||||
if is_pick is False:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
||||
production_item)
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
||||
production_item)
|
||||
if sorted_workorders[i] in consecutive_workorders:
|
||||
is_pick = True
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production_item)
|
||||
if is_pick is False and m == 0:
|
||||
if len(sorted_workorders) == 1:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production_item)
|
||||
else:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production_item)
|
||||
|
||||
for production in productions:
|
||||
origin_production = production.move_dest_ids and production.move_dest_ids[
|
||||
@@ -704,13 +755,36 @@ class ResMrpWorkOrder(models.Model):
|
||||
'mail.message_origin_link',
|
||||
values={'self': production, 'origin': origin_production},
|
||||
subtype_id=self.env.ref('mail.mt_note').id)
|
||||
if self.test_results == '返工':
|
||||
productions = self.production_id
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
productions._create_workorder2(self.processing_panel)
|
||||
else:
|
||||
self.results = '合格'
|
||||
|
||||
'''
|
||||
创建生产计划
|
||||
'''
|
||||
# 工单耗时
|
||||
workorder_duration = 0
|
||||
for workorder in productions.workorder_ids:
|
||||
workorder_duration += workorder.duration_expected
|
||||
|
||||
sale_order = self.env['sale.order'].sudo().search([('name', '=', productions.origin)])
|
||||
if sale_order:
|
||||
sale_order.mrp_production_ids |= productions
|
||||
# sale_order.write({'schedule_status': 'to schedule'})
|
||||
self.env['sf.production.plan'].sudo().with_company(self.production_id.company_id).create({
|
||||
'name': productions.name,
|
||||
'order_deadline': sale_order.deadline_of_delivery,
|
||||
'production_id': productions.id,
|
||||
'date_planned_start': productions.date_planned_start,
|
||||
'origin': productions.origin,
|
||||
'product_qty': productions.product_qty,
|
||||
'product_id': productions.product_id.id,
|
||||
'state': 'draft',
|
||||
})
|
||||
# if self.test_results == '返工':
|
||||
# productions = self.production_id
|
||||
# # self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
# # self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
# productions._create_workorder2(self.processing_panel)
|
||||
# else:
|
||||
# self.results = '合格'
|
||||
|
||||
def json_workorder_str1(self, k, production, route):
|
||||
workorders_values_str = [0, '', {
|
||||
@@ -720,7 +794,6 @@ class ResMrpWorkOrder(models.Model):
|
||||
'name': '%s(返工)' % route.route_workcenter_id.name,
|
||||
'processing_panel': k,
|
||||
'routing_type': route.routing_type,
|
||||
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
|
||||
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
|
||||
route.routing_type,
|
||||
production.product_id),
|
||||
@@ -728,10 +801,37 @@ class ResMrpWorkOrder(models.Model):
|
||||
'date_planned_finished': datetime.now() + timedelta(days=1),
|
||||
'duration_expected': 60,
|
||||
'duration': 0,
|
||||
|
||||
'manual_quotation': production.workorder_ids.filtered(
|
||||
lambda t: t.routing_type == 'CNC加工').manual_quotation,
|
||||
'rfid_code': production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').rfid_code,
|
||||
'cnc_ids': production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').cnc_ids,
|
||||
'cmm_ids': production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').cmm_ids,
|
||||
}]
|
||||
return workorders_values_str
|
||||
|
||||
# @api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state')
|
||||
# def _compute_state(self):
|
||||
# super(ResMrpWorkOrder, self)._compute_state()
|
||||
# for item in self:
|
||||
# print(item.name)
|
||||
# print(item.state)
|
||||
# print(item.is_remanufacture)
|
||||
# scrap_workorder = self.env['mrp.workorder'].search(
|
||||
# [('production_id', '=', item.production_id.id), ('routing_type', '=', 'CNC加工'),
|
||||
# ('state', '=', 'done'), ('test_results', 'in', ['返工', '报废'])])
|
||||
# print(scrap_workorder)
|
||||
# # if item.routing_type == 'CNC加工' and item.state in ['done'] and item.test_results in ['返工', '报废']:
|
||||
# if item.routing_type == '解除装夹':
|
||||
# if scrap_workorder and item.state not in ['cancel']:
|
||||
# item.state = 'cancel'
|
||||
# elif item.routing_type == '表面工艺':
|
||||
# if scrap_workorder:
|
||||
# stock_move = self.env['stock.move'].search(
|
||||
# [('origin', '=', item.production_id.name)])
|
||||
# stock_move.write({'state': 'cancel'})
|
||||
# item.picking_ids.write({'state': 'cancel'})
|
||||
# item.state = 'cancel'
|
||||
|
||||
# 重写工单开始按钮方法
|
||||
def button_start(self):
|
||||
if self.routing_type == '装夹预调':
|
||||
@@ -887,6 +987,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
raise UserError(
|
||||
'请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
||||
tem_date_planned_finished = record.date_planned_finished
|
||||
tem_date_finished = record.date_finished
|
||||
logging.info('routing_type:%s' % record.routing_type)
|
||||
super().button_finish()
|
||||
logging.info('date_planned_finished:%s' % record.date_planned_finished)
|
||||
@@ -895,6 +996,15 @@ class ResMrpWorkOrder(models.Model):
|
||||
record.write({
|
||||
'date_planned_finished': tem_date_planned_finished # 保持原值
|
||||
})
|
||||
if record.routing_type == 'CNC加工':
|
||||
record.write({
|
||||
'date_finished': tem_date_finished # 保持原值
|
||||
})
|
||||
if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']:
|
||||
record.production_id.action_cancel()
|
||||
record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code})
|
||||
if record.is_remanufacture is True:
|
||||
record.recreateManufacturingOrWorkerOrder()
|
||||
is_production_id = True
|
||||
for workorder in record.production_id.workorder_ids:
|
||||
if workorder.state != 'done':
|
||||
@@ -1035,14 +1145,14 @@ class CNCprocessing(models.Model):
|
||||
# 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配
|
||||
def get_cnc_processing_file(self, serverdir, cnc_processing, program_path):
|
||||
logging.info('serverdir:%s' % serverdir)
|
||||
logging.info('cnc_processing:%s' % cnc_processing)
|
||||
for root, dirs, files in os.walk(serverdir):
|
||||
for f in files:
|
||||
logging.info('splitext(f):%s' % os.path.splitext(f)[1])
|
||||
if os.path.splitext(f)[1] == ".pdf":
|
||||
full_path = os.path.join(serverdir, root, f)
|
||||
if full_path is not False:
|
||||
if not cnc_processing.workorder_id.cnc_worksheet:
|
||||
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
||||
open(full_path, 'rb').read())
|
||||
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
||||
open(full_path, 'rb').read())
|
||||
else:
|
||||
if f in program_path:
|
||||
# if cnc_processing.program_name == f.split('.')[0]:
|
||||
@@ -1229,15 +1339,25 @@ class WorkPieceDelivery(models.Model):
|
||||
status = fields.Selection(
|
||||
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发')
|
||||
is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
|
||||
is_manual_work = fields.Boolean('人工操作', default=False)
|
||||
active = fields.Boolean(string="有效", default=True)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('name', '/') == '/' or vals.get('name', '/') is False:
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code('sf.workpiece.delivery') or '/'
|
||||
else:
|
||||
vals['type'] = '运送空料架'
|
||||
obj = super(WorkPieceDelivery, self).create(vals)
|
||||
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):
|
||||
return {
|
||||
'name': _('配送历史'),
|
||||
@@ -1287,6 +1407,8 @@ class WorkPieceDelivery(models.Model):
|
||||
is_not_route += 1
|
||||
# else:
|
||||
# raise UserError('请选择【任务路线】再进行配送')
|
||||
# if item.production_id.production_line_state == '已下产线' and item.state == '待下发' and item.type == '下产线':
|
||||
# raise UserError('该制造订单已下产线,无需配送')
|
||||
if production_type != item.type:
|
||||
raise UserError('请选择类型为%s的制造订单进行配送' % production_type)
|
||||
if down_status != item.status:
|
||||
@@ -1340,22 +1462,25 @@ class WorkPieceDelivery(models.Model):
|
||||
is_free = False
|
||||
agv_site = self.env['sf.agv.site'].search([])
|
||||
if agv_site:
|
||||
agv_site.update_site_state()
|
||||
for item in self:
|
||||
logging.info('工件配送-起点状态:%s-%s' % (
|
||||
item.feeder_station_start_id.name, item.feeder_station_start_id.state))
|
||||
logging.info('工件配送-终点状态:%s-%s' % (
|
||||
item.feeder_station_destination_id.name, item.feeder_station_destination_id.state))
|
||||
if item.type in ['上产线', '下产线']:
|
||||
if (
|
||||
item.feeder_station_start_id.state == '占用' and item.feeder_station_destination_id.state == '空闲') or (
|
||||
item.feeder_station_start_id.state == '空闲' and item.feeder_station_destination_id.state == '空闲'):
|
||||
is_free = True
|
||||
has_site = agv_site.update_site_state()
|
||||
if has_site is True:
|
||||
for item in self:
|
||||
if item.type in ['上产线', '下产线']:
|
||||
logging.info('工件配送-起点状态:%s-%s' % (
|
||||
item.feeder_station_start_id.name, item.feeder_station_start_id.state))
|
||||
logging.info('工件配送-终点状态:%s-%s' % (
|
||||
item.feeder_station_destination_id.name, item.feeder_station_destination_id.state))
|
||||
if (
|
||||
item.feeder_station_start_id.state == '占用' and item.feeder_station_destination_id.state == '空闲') or (
|
||||
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:
|
||||
if item.feeder_station_destination_id.state == '空闲':
|
||||
is_free = True
|
||||
logging.info('is_free:%s' % is_free)
|
||||
return is_free
|
||||
raise UserError("接驳站暂未反馈站点实时状态,请稍后再试")
|
||||
|
||||
# 配送至avg小车
|
||||
def _delivery_avg(self):
|
||||
|
||||
@@ -7,8 +7,8 @@ import os
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.modules import get_resource_path
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
|
||||
|
||||
class ResProductMo(models.Model):
|
||||
@@ -530,6 +530,7 @@ class ResProductMo(models.Model):
|
||||
|
||||
# bfm下单
|
||||
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
|
||||
part_number = fields.Char(string='零件图号', readonly=True)
|
||||
|
||||
@api.constrains('tool_length')
|
||||
def _check_tool_length_size(self):
|
||||
@@ -626,6 +627,7 @@ class ResProductMo(models.Model):
|
||||
'model_remark': item['remark'],
|
||||
'default_code': '%s-%s' % (order_number, i),
|
||||
'manual_quotation': item['manual_quotation'] or False,
|
||||
'part_number': item['part_number'] or '',
|
||||
'active': True,
|
||||
}
|
||||
copy_product_id.sudo().write(vals)
|
||||
|
||||
@@ -207,7 +207,7 @@ class StockRule(models.Model):
|
||||
'''
|
||||
创建工单
|
||||
'''
|
||||
productions._create_workorder()
|
||||
productions._create_workorder(is_fetchcnc=False, scrap_production=False)
|
||||
|
||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||
(
|
||||
@@ -492,7 +492,7 @@ class StockPicking(models.Model):
|
||||
|
||||
# 设置外协出入单的名称
|
||||
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:
|
||||
num = "%04d" % 1
|
||||
else:
|
||||
@@ -631,8 +631,8 @@ class ReStockMove(models.Model):
|
||||
'reserved_uom_qty': 1.0,
|
||||
'lot_id': purchase.picking_ids.move_line_ids.lot_id.id,
|
||||
'company_id': self.company_id.id,
|
||||
'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
|
||||
'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
|
||||
# 'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
|
||||
# 'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
|
||||
'state': 'assigned',
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<tree editable="bottom">
|
||||
<field name="name" required="1"/>
|
||||
<field name="type" readonly="1" string="任务类型"/>
|
||||
<field name="route_type" string="类型"/>
|
||||
<field name="route_type" string="类型" required="1"/>
|
||||
<field name="start_site_id" required="1" options="{'no_create': True}" string="起点接驳站"/>
|
||||
<field name="end_site_id" required="1" options="{'no_create': True}" string="终点接驳站"/>
|
||||
<field name="destination_production_line_id" required="1" options="{'no_create': True}"/>
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
<xpath expr="//field[@name='user_id']" position="after">
|
||||
<field name="production_line_id" readonly="1"/>
|
||||
<field name="production_line_state" readonly="1"/>
|
||||
<field name="part_number"/>
|
||||
<field name="part_number" string="成品的零件图号"/>
|
||||
<field name="part_drawing"/>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_ids" eval="[(5, 0, 0),
|
||||
(0, 0, {'view_mode': 'tree', 'view_id': ref('mrp.mrp_production_workorder_tree_editable_view')}) ]"/>
|
||||
<!-- (0, 0, {'view_mode': 'kanban', 'view_id': ref('mrp.workcenter_line_kanban')})-->
|
||||
<!-- (0, 0, {'view_mode': 'kanban', 'view_id': ref('mrp.workcenter_line_kanban')})-->
|
||||
<!-- <field name="target">fullscreen</field>-->
|
||||
<field name="target">current</field>
|
||||
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
|
||||
@@ -214,7 +214,7 @@
|
||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
||||
<field name="functional_fixture_type_id"
|
||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
||||
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
||||
<field name="rfid_code" cache="True"
|
||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
|
||||
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||
</group>
|
||||
@@ -477,7 +477,12 @@
|
||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<group>
|
||||
<field name="test_results" attrs='{"invisible":[("results","!=",False)]}'/>
|
||||
<field name="is_remanufacture" attrs='{"invisible":[("test_results","=","合格")]}'/>
|
||||
<field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>
|
||||
<field name="is_fetchcnc"
|
||||
attrs='{"invisible":["|",("test_results","=","合格"),("is_remanufacture","=",False)]}'/>
|
||||
<field name="reason"
|
||||
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")]}'/>
|
||||
<field name="detailed_reason" attrs='{"invisible":[("test_results","=","合格")]}'/>
|
||||
<field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
|
||||
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
|
||||
widget="pdf_viewer"/>
|
||||
@@ -573,7 +578,7 @@
|
||||
<label for="material_height" string="高"/>
|
||||
<field name="material_height" class="o_address_zip"/>
|
||||
</div>
|
||||
<field name="part_number"/>
|
||||
<field name="part_number" string="成品的零件图号"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -618,7 +623,6 @@
|
||||
<field name="route_id" options="{'no_create': True}"
|
||||
domain="[('route_type','in',['上产线','下产线'])]"/>
|
||||
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
||||
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
||||
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
|
||||
<field name="is_cnc_program_down" readonly="1"/>
|
||||
<!-- <field name="rfid_code"/>-->
|
||||
@@ -659,7 +663,9 @@
|
||||
<field name="search_view_id" ref="sf_workpiece_delivery_search"/>
|
||||
<field name="context">{'search_default_on_up':1}</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>
|
||||
|
||||
|
||||
@@ -668,14 +674,18 @@
|
||||
<field name="name">空料架配送</field>
|
||||
<field name="model">sf.workpiece.delivery</field>
|
||||
<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>
|
||||
<button name="button_delivery" type="object" string="配送" class="oe_highlight"/>
|
||||
</header>
|
||||
<field name="name" string="路线名称" readonly="1"/>
|
||||
<field name="route_id" options="{'no_create': True}"/>
|
||||
<field name="feeder_station_start_id" readonly="1"/>
|
||||
<field name="feeder_station_destination_id" readonly="1"/>
|
||||
<field name="name" string="路线名称" attrs="{'readonly': [('id', '!=', False)]}"
|
||||
placeholder="例如:运送空料架路线:G01-A01" required="1" force_save="1"/>
|
||||
<field name="route_id" options="{'no_create': True}" required="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"
|
||||
string="历史"/>
|
||||
</tree>
|
||||
|
||||
@@ -24,12 +24,22 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
ret = json.loads(datas)
|
||||
ret = json.loads(ret['result'])
|
||||
logging.info('下发编程单:%s' % ret)
|
||||
is_delete_file = False
|
||||
# 查询状态为进行中且类型为获取CNC加工程序的工单
|
||||
cnc_production = request.env['mrp.production'].with_user(
|
||||
request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'].split(',')[0])])
|
||||
cnc_program = request.env['mrp.production'].with_user(
|
||||
request.env.ref("base.user_admin")).search(
|
||||
[('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(
|
||||
# request.env.ref("base.user_admin")).search([('programming_no', '=', cnc_production.programming_no)])
|
||||
logging.info('制造订单号:%s' % cnc_production.name)
|
||||
@@ -37,6 +47,13 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
# if 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']:
|
||||
download_state = request.env['sf.cnc.processing'].with_user(
|
||||
request.env.ref("base.user_admin")).download_file_tmp(
|
||||
@@ -64,12 +81,17 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
if 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):
|
||||
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:
|
||||
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_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
|
||||
if not cnc_program and cnc_processing_arr:
|
||||
cnc_program = cnc_production
|
||||
|
||||
@@ -32,6 +32,9 @@ class FtpController():
|
||||
logging.error(f"Error checking file: {e}")
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
# # 检测字符串的编码
|
||||
# def detect_encoding(self, s):
|
||||
# result = chardet.detect(s)
|
||||
@@ -43,6 +46,8 @@ class FtpController():
|
||||
os.makedirs(serverdir)
|
||||
try:
|
||||
logging.info("进入FTP目录 ")
|
||||
self.ftp.pwd()
|
||||
logging.info('当前目录:%s' % self.ftp.pwd())
|
||||
logging.info('目录:%s' % target_dir)
|
||||
target_dir1 = target_dir.split('/')
|
||||
logging.info('目录1:%s' % target_dir1[1])
|
||||
|
||||
@@ -8,8 +8,8 @@ from datetime import datetime
|
||||
import requests
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
from odoo import models, fields, api
|
||||
from odoo.modules import get_resource_path
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
|
||||
@@ -6,8 +6,8 @@ import os
|
||||
from datetime import datetime
|
||||
from stl import mesh
|
||||
# from OCC.Core.GProp import GProp_GProps
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo import models, fields, api
|
||||
from odoo.modules import get_resource_path
|
||||
|
||||
@@ -36,3 +36,94 @@ class Manufacturing_Connect(http.Controller):
|
||||
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,
|
||||
cors="*")
|
||||
def get_functional_tool_inventory_Info(self, **kw):
|
||||
"""
|
||||
功能刀具清单接口
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
logging.info('get_functional_tool_inventory_Info:%s' % kw)
|
||||
try:
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
# ret = json.loads(ret['result'])
|
||||
logging.info('DeviceId:%s' % ret)
|
||||
tool_inventory = request.env['sf.tool.inventory'].sudo().search([])
|
||||
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
if tool_inventory:
|
||||
for item in tool_inventory:
|
||||
res['Datas'].append({
|
||||
'ToolName': item.name,
|
||||
'GroupName': item.tool_groups_id.name,
|
||||
'Lifetime': item.life_span
|
||||
})
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('get_functional_tool_inventory_Info error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@http.route('/AutoDeviceApi/ToolEntity', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def get_functional_tool_entity_Info(self, **kw):
|
||||
"""
|
||||
功能刀具列表接口
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
logging.info('get_functional_tool_entity_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.functional.cutting.tool.entity'].sudo().search([])
|
||||
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
if functional_tools:
|
||||
for item in functional_tools:
|
||||
res['Datas'].append({
|
||||
'Rfid': item.rfid,
|
||||
'ToolName': item.tool_name_id.name,
|
||||
'GroupName': item.tool_groups_id.name,
|
||||
'MaxLifetime': item.max_lifetime_value,
|
||||
'KnifeHandle': item.cutting_tool_cutterhandle_model_id.name
|
||||
})
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('get_functional_tool_entity_Info error:%s' % e)
|
||||
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)
|
||||
@@ -5,8 +5,8 @@
|
||||
<field name="model_id" ref="model_sf_tool_datasync"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model._cron_tool_datasync_all()</field>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="interval_number">12</field>
|
||||
<field name="interval_type">hours</field>
|
||||
<field name="numbercall">-1</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -6,4 +6,5 @@ from . import mrp_workorder
|
||||
from . import functional_tool_enroll
|
||||
from . import fixture_material_search
|
||||
from . import fixture_enroll
|
||||
from . import temporary_data_processing_methods
|
||||
|
||||
|
||||
@@ -311,41 +311,54 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
'applicant': 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工单程序用刀计划
|
||||
"""
|
||||
status = False
|
||||
if cnc_processing.cutting_tool_name:
|
||||
functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search(
|
||||
[('name', '=', cnc_processing.cutting_tool_name)])
|
||||
if functional_tools:
|
||||
for functional_tool in functional_tools:
|
||||
if functional_tool.on_tool_stock_num == 0:
|
||||
if functional_tool.tool_stock_num == 0 and functional_tool.side_shelf_num == 0:
|
||||
status = True
|
||||
else:
|
||||
status = True
|
||||
if status:
|
||||
knife_plan = self.env['sf.cam.work.order.program.knife.plan'].sudo().create({
|
||||
'name': cnc_processing.workorder_id.production_id.name,
|
||||
'cam_procedure_code': cnc_processing.program_name,
|
||||
'filename': cnc_processing.cnc_id.name,
|
||||
'functional_tool_name': cnc_processing.cutting_tool_name,
|
||||
'cam_cutter_spacing_code': cnc_processing.cutting_tool_no,
|
||||
'process_type': cnc_processing.processing_type,
|
||||
'margin_x_y': float(cnc_processing.margin_x_y),
|
||||
'margin_z': float(cnc_processing.margin_z),
|
||||
'finish_depth': float(cnc_processing.depth_of_processing_z),
|
||||
'extension_length': float(cnc_processing.cutting_tool_extension_length),
|
||||
'shank_model': cnc_processing.cutting_tool_handle_type,
|
||||
'estimated_processing_time': cnc_processing.estimated_processing_time,
|
||||
})
|
||||
logging.info('CAM工单程序用刀计划创建成功!!!')
|
||||
# 创建装刀请求
|
||||
knife_plan.apply_for_tooling()
|
||||
else:
|
||||
logging.info('功能刀具【%s】满足CNC用刀需求!!!' % cnc_processing.cutting_tool_name)
|
||||
for cnc_processing in cnc_processing_ids:
|
||||
status = False
|
||||
if cnc_processing.cutting_tool_name:
|
||||
functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search(
|
||||
[('name', '=', cnc_processing.cutting_tool_name)])
|
||||
if functional_tools:
|
||||
for functional_tool in functional_tools:
|
||||
if functional_tool.on_tool_stock_num == 0:
|
||||
if functional_tool.tool_stock_num == 0 and functional_tool.side_shelf_num == 0:
|
||||
status = True
|
||||
else:
|
||||
status = True
|
||||
if status:
|
||||
knife_plan = self.env['sf.cam.work.order.program.knife.plan'].sudo().create({
|
||||
'name': cnc_processing.workorder_id.production_id.name,
|
||||
'cam_procedure_code': cnc_processing.program_name,
|
||||
'filename': cnc_processing.cnc_id.name,
|
||||
'functional_tool_name': cnc_processing.cutting_tool_name,
|
||||
'cam_cutter_spacing_code': cnc_processing.cutting_tool_no,
|
||||
'process_type': cnc_processing.processing_type,
|
||||
'margin_x_y': float(cnc_processing.margin_x_y),
|
||||
'margin_z': float(cnc_processing.margin_z),
|
||||
'finish_depth': float(cnc_processing.depth_of_processing_z),
|
||||
'extension_length': float(cnc_processing.cutting_tool_extension_length),
|
||||
'shank_model': cnc_processing.cutting_tool_handle_type,
|
||||
'estimated_processing_time': cnc_processing.estimated_processing_time,
|
||||
})
|
||||
logging.info('CAM工单程序用刀计划创建成功!!!')
|
||||
# 创建装刀请求
|
||||
knife_plan.apply_for_tooling()
|
||||
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):
|
||||
@@ -538,12 +551,14 @@ class FunctionalToolAssembly(models.Model):
|
||||
chuck_name = fields.Char('')
|
||||
# ==============================================
|
||||
# 组装功能刀具参数信息
|
||||
start_preset_bool = fields.Boolean('开始预调', default=False)
|
||||
barcode_id = fields.Many2one('stock.lot', 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',
|
||||
string='组装后功能刀具类型', 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)
|
||||
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(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)
|
||||
cut_time = fields.Integer(string='已切削时间(min)', readonly=True)
|
||||
cut_length = fields.Float(string='已切削长度(mm)', readonly=True)
|
||||
@@ -555,8 +570,9 @@ class FunctionalToolAssembly(models.Model):
|
||||
after_assembly_max_lifetime_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_tool_loading_length = fields.Float(string='组装后总长度(mm)', readonly=True)
|
||||
after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)', readonly=True)
|
||||
after_assembly_tool_loading_length = fields.Float(string='组装后总长度(mm)', readonly=True, digits=(10, 3))
|
||||
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)
|
||||
L_D_number = fields.Float(string='L/D值(mm)', readonly=True)
|
||||
hiding_length = fields.Float(string='避空长(mm)', readonly=True)
|
||||
@@ -574,29 +590,64 @@ class FunctionalToolAssembly(models.Model):
|
||||
|
||||
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):
|
||||
"""
|
||||
自动生成组装单编码
|
||||
"""
|
||||
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(
|
||||
[('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:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
m = int(functional_tool_assembly.assembly_order_code[-3:]) + 1
|
||||
num = "%03d" % m
|
||||
if loading_task_source == '0':
|
||||
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
|
||||
return code + str(num)
|
||||
|
||||
def get_functional_tool(self, val):
|
||||
functional_tools = self.env['sf.functional.tool.assembly'].search(
|
||||
@@ -814,6 +865,10 @@ class FunctionalToolDismantle(models.Model):
|
||||
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
||||
if self.functional_tool_id.functional_tool_status == '已拆除':
|
||||
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))
|
||||
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
||||
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
|
||||
# =================刀柄是否[报废]拆解=======
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
import base64
|
||||
import requests
|
||||
import logging
|
||||
from odoo import models, api
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo.exceptions import UserError
|
||||
@@ -10,30 +11,36 @@ class StockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
_description = '夹具物料序列号注册'
|
||||
|
||||
def enroll_fixture_material_stock(self):
|
||||
def sync_enroll_fixture_material_stock_all(self):
|
||||
logging.info("调用 sync_enroll_fixture_material_stock_all 同步接口")
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + "/api/fixture_material_stock/create"
|
||||
objs_all = self.env['stock.lot'].search([('id', '=', self.id)])
|
||||
product_ids = self.env['product.product'].sudo().search([('categ_type', '=', '夹具')]).ids
|
||||
objs_all = self.env['stock.lot'].search([('rfid', '!=', False), ('product_id', 'in', product_ids)])
|
||||
fixture_material_stock_list = []
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
val = {
|
||||
'name': item.name,
|
||||
'tool_material_status': item.tool_material_status,
|
||||
'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
|
||||
'fixture_material_search_id': item.fixture_material_search_id.id,
|
||||
}
|
||||
fixture_material_stock_list.append(val)
|
||||
kw = json.dumps(fixture_material_stock_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return '夹具物料序列号注册成功'
|
||||
else:
|
||||
raise UserError("没有注册夹具物料序列号信息")
|
||||
try:
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
val = {
|
||||
'name': item.name,
|
||||
'tool_material_status': item.tool_material_status,
|
||||
'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
|
||||
'fixture_material_search_id': item.fixture_material_search_id.id,
|
||||
}
|
||||
fixture_material_stock_list.append(val)
|
||||
kw = json.dumps(fixture_material_stock_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
logging.info("夹具物料序列号每日同步成功")
|
||||
return '夹具物料序列号注册成功'
|
||||
else:
|
||||
logging.info("没有注册夹具物料序列号信息")
|
||||
except Exception as e:
|
||||
logging.info("夹具物料序列号同步失败:%s" % e)
|
||||
|
||||
|
||||
class FixtureMaterialSearch(models.Model):
|
||||
@@ -42,41 +49,46 @@ class FixtureMaterialSearch(models.Model):
|
||||
|
||||
crea_url = "/api/fixture_material/create"
|
||||
|
||||
def enroll_fixture_material(self):
|
||||
def sync_enroll_fixture_material_all(self):
|
||||
logging.info("调用 sync_enroll_fixture_material_all 同步接口")
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.search([('id', '=', self.id)])
|
||||
objs_all = self.search([])
|
||||
fixture_material_list = []
|
||||
if objs_all:
|
||||
for obj in objs_all:
|
||||
val = {
|
||||
'name': obj.name,
|
||||
'id': obj.id,
|
||||
'fixture_material_code': obj.fixture_material_id.code,
|
||||
'fixture_model_code': obj.fixture_model_id.code,
|
||||
'specification_name': obj.specification_fixture_id.name,
|
||||
'image': '' if not obj.image else base64.b64encode(obj.image).decode('utf-8'),
|
||||
'number': obj.number,
|
||||
'usable_num': obj.usable_num,
|
||||
'have_been_used_num': obj.have_been_used_num,
|
||||
'scrap_num': obj.scrap_num
|
||||
}
|
||||
fixture_material_list.append(val)
|
||||
kw = json.dumps(fixture_material_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return '夹具物料注册成功'
|
||||
else:
|
||||
raise UserError("没有注册夹具物料信息")
|
||||
try:
|
||||
if objs_all:
|
||||
for obj in objs_all:
|
||||
val = {
|
||||
'name': obj.name,
|
||||
'id': obj.id,
|
||||
'fixture_material_code': obj.fixture_material_id.code,
|
||||
'fixture_model_code': obj.fixture_model_id.code,
|
||||
'specification_name': obj.specification_fixture_id.name,
|
||||
'image': '' if not obj.image else base64.b64encode(obj.image).decode('utf-8'),
|
||||
'number': obj.number,
|
||||
'usable_num': obj.usable_num,
|
||||
'have_been_used_num': obj.have_been_used_num,
|
||||
'scrap_num': obj.scrap_num
|
||||
}
|
||||
fixture_material_list.append(val)
|
||||
kw = json.dumps(fixture_material_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
logging.info("夹具物料每日同步成功")
|
||||
return '夹具物料注册成功'
|
||||
else:
|
||||
logging.info("没有注册夹具物料信息")
|
||||
except Exception as e:
|
||||
logging.info("夹具物料同步失败:%s" % e)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super(FixtureMaterialSearch, self).create(vals_list)
|
||||
for record in records:
|
||||
if record:
|
||||
record.enroll_fixture_material()
|
||||
return records
|
||||
# @api.model_create_multi
|
||||
# def create(self, vals_list):
|
||||
# records = super(FixtureMaterialSearch, self).create(vals_list)
|
||||
# for record in records:
|
||||
# if record:
|
||||
# record.enroll_fixture_material()
|
||||
# return records
|
||||
|
||||
@@ -25,12 +25,13 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型',
|
||||
group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True)
|
||||
|
||||
functional_tool_diameter = fields.Float(string='刀具直径(mm)', readonly=True)
|
||||
knife_tip_r_angle = fields.Float(string='刀尖R角(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, digits=(10, 3))
|
||||
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
|
||||
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
|
||||
tool_loading_length = fields.Float(string='总长度(mm)', readonly=True)
|
||||
functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True)
|
||||
tool_loading_length = fields.Float(string='总长度(mm)', readonly=True, digits=(10, 3))
|
||||
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)
|
||||
tool_room_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',
|
||||
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')
|
||||
def _compute_current_location_id(self):
|
||||
for record in self:
|
||||
|
||||
@@ -33,23 +33,26 @@ def get_suitable_coolant_names(item):
|
||||
|
||||
class ToolDatasync(models.Model):
|
||||
_name = 'sf.tool.datasync'
|
||||
_description = '定时同步所有刀具'
|
||||
_description = '定时同步所有刀具、夹具'
|
||||
|
||||
def _cron_tool_datasync_all(self):
|
||||
try:
|
||||
self.env['stock.lot'].sudo().sync_enroll_tool_material_stock_all()
|
||||
logging.info("刀具物料序列号每日同步成功")
|
||||
|
||||
self.env['stock.lot'].sudo().sync_enroll_fixture_material_stock_all()
|
||||
|
||||
self.env['sf.tool.material.search'].sudo().sync_enroll_tool_material_all()
|
||||
logging.info("刀具物料每日同步成功")
|
||||
|
||||
self.env['sf.fixture.material.search'].sudo().sync_enroll_fixture_material_all()
|
||||
|
||||
self.env['sf.functional.cutting.tool.entity'].sudo().esync_enroll_functional_tool_entity_all()
|
||||
logging.info("功能刀具列表每日同步成功")
|
||||
self.env['sf.functional.tool.warning'].sudo().sync_enroll_functional_tool_warning_all()
|
||||
logging.info("功能刀具预警每日同步成功")
|
||||
self.env['stock.move.line'].sudo().sync_enroll_functional_tool_move_all()
|
||||
logging.info("功能刀具出入库记录每日同步成功")
|
||||
self.env[
|
||||
'sf.real.time.distribution.of.functional.tools'].sudo().sync_enroll_functional_tool_real_time_distribution_all()
|
||||
logging.info("功能刀具安全库存每日同步成功")
|
||||
logging.info("已全部同步完成!!!")
|
||||
# self.env['sf.functional.tool.warning'].sudo().sync_enroll_functional_tool_warning_all()
|
||||
# logging.info("功能刀具预警每日同步成功")
|
||||
# self.env['stock.move.line'].sudo().sync_enroll_functional_tool_move_all()
|
||||
# logging.info("功能刀具出入库记录每日同步成功")
|
||||
# self.env['sf.real.time.distribution.of.functional.tools'].sudo().sync_enroll_functional_tool_real_time_distribution_all()
|
||||
# logging.info("功能刀具安全库存每日同步成功")
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
||||
@@ -59,24 +62,25 @@ class StockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
_description = '刀具物料序列号注册'
|
||||
|
||||
def enroll_tool_material_stock(self):
|
||||
logging.info('调用刀具物料序列号注册接口: enroll_tool_material_stock()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
|
||||
objs_all = self.env['stock.lot'].search([('id', '=', self.id), ('active', 'in', [True, False])])
|
||||
self._get_sync_stock_lot(objs_all, str_url, token, headers)
|
||||
# def enroll_tool_material_stock(self):
|
||||
# logging.info('调用刀具物料序列号注册接口: enroll_tool_material_stock()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
|
||||
# objs_all = self.env['stock.lot'].search([('id', '=', self.id), ('active', 'in', [True, False])])
|
||||
# self._get_sync_stock_lot(objs_all, str_url, token, headers)
|
||||
|
||||
def sync_enroll_tool_material_stock_all(self):
|
||||
logging.info('调用刀具物料序列号注册接口: sync_enroll_tool_material_stock_all()')
|
||||
logging.info('调用 sync_enroll_tool_material_stock_all 同步接口')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
|
||||
objs_all = self.env['stock.lot'].search([('rfid', '!=', False)])
|
||||
product_ids = self.env['product.product'].sudo().search([('categ_type', '=', '刀具')]).ids
|
||||
objs_all = self.env['stock.lot'].search([('rfid', '!=', False), ('product_id', 'in', product_ids)])
|
||||
self._get_sync_stock_lot(objs_all, str_url, token, headers)
|
||||
|
||||
def _get_sync_stock_lot(self, objs_all, str_url, token, headers):
|
||||
@@ -95,11 +99,12 @@ class StockLot(models.Model):
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return '刀具物料序列号注册成功'
|
||||
logging.info("刀具物料序列号每日同步成功")
|
||||
return '刀具(夹具)物料序列号注册成功'
|
||||
else:
|
||||
logging.info("没有注册刀具物料序列号信息")
|
||||
logging.info("没有刀具物料序列号信息")
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
logging.info("刀具物料序列号同步失败:%s" % e)
|
||||
|
||||
|
||||
class ToolMaterial(models.Model):
|
||||
@@ -108,18 +113,18 @@ class ToolMaterial(models.Model):
|
||||
|
||||
crea_url = '/api/tool_material/create'
|
||||
|
||||
def enroll_tool_material(self):
|
||||
logging.info('调用刀具物料注册接口: enroll_tool_material()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.search([('id', '=', self.id)])
|
||||
self._get_sync_tool_material_search(objs_all, str_url, token, headers)
|
||||
# def enroll_tool_material(self):
|
||||
# logging.info('调用刀具物料注册接口: enroll_tool_material()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
# objs_all = self.search([('id', '=', self.id)])
|
||||
# self._get_sync_tool_material_search(objs_all, str_url, token, headers)
|
||||
|
||||
def sync_enroll_tool_material_all(self):
|
||||
logging.info('调用刀具物料注册接口: sync_enroll_tool_material_all()')
|
||||
logging.info('调用 sync_enroll_tool_material_all 同步接口')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
@@ -150,19 +155,14 @@ class ToolMaterial(models.Model):
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
logging.info("刀具物料每日同步成功")
|
||||
return '刀具物料注册成功'
|
||||
else:
|
||||
logging.info('没有注册刀具物料信息')
|
||||
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):
|
||||
@@ -172,18 +172,18 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
crea_url = "/api/functional_tool_entity/create"
|
||||
|
||||
# 注册同步功能刀具列表
|
||||
def enroll_functional_tool_entity(self):
|
||||
logging.info('调用功能刀具列表注册接口: enroll_functional_tool_entity()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.env['sf.functional.cutting.tool.entity'].search([('id', '=', self.id)])
|
||||
self._get_sync_functional_cutting_tool_entity(objs_all, str_url, token, headers)
|
||||
# def enroll_functional_tool_entity(self):
|
||||
# logging.info('调用功能刀具列表注册接口: enroll_functional_tool_entity()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
# objs_all = self.env['sf.functional.cutting.tool.entity'].search([('id', '=', self.id)])
|
||||
# self._get_sync_functional_cutting_tool_entity(objs_all, str_url, token, headers)
|
||||
|
||||
def esync_enroll_functional_tool_entity_all(self):
|
||||
logging.info('调用功能刀具列表注册接口: esync_enroll_functional_tool_entity_all()')
|
||||
logging.info('调用 esync_enroll_functional_tool_entity_all 同步接口')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
@@ -210,6 +210,7 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
'coarse_middle_thin': item.coarse_middle_thin,
|
||||
'new_former': item.new_former,
|
||||
'tool_loading_length': item.tool_loading_length,
|
||||
'handle_length': item.handle_length,
|
||||
'functional_tool_length': item.functional_tool_length,
|
||||
'effective_length': item.effective_length,
|
||||
'max_lifetime_value': item.max_lifetime_value,
|
||||
@@ -242,25 +243,14 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
logging.info("功能刀具列表每日同步成功")
|
||||
return "功能刀具注册成功"
|
||||
else:
|
||||
logging.info('没有注册功能刀具信息')
|
||||
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):
|
||||
@@ -332,14 +322,6 @@ class FunctionalToolWarning(models.Model):
|
||||
except Exception as 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):
|
||||
_inherit = 'stock.move.line'
|
||||
@@ -401,14 +383,6 @@ class StockMoveLine(models.Model):
|
||||
except Exception as 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):
|
||||
_inherit = 'sf.real.time.distribution.of.functional.tools'
|
||||
@@ -481,17 +455,3 @@ class RealTimeDistributionFunctionalTools(models.Model):
|
||||
logging.info('没有注册功能刀具出入库记录信息')
|
||||
except Exception as 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):
|
||||
if datas:
|
||||
# 清除设备机床刀位的刀具信息
|
||||
for obj in self.product_template_ids:
|
||||
obj.write({
|
||||
'functional_tool_name_id': False,
|
||||
'tool_install_time': None
|
||||
})
|
||||
for data in datas:
|
||||
maintenance_equipment_id = self.search([('name', '=', data['DeviceId'])])
|
||||
if maintenance_equipment_id:
|
||||
@@ -128,10 +134,7 @@ class StockLot(models.Model):
|
||||
record.tool_material_status = '报废'
|
||||
else:
|
||||
record.tool_material_status = '未入库'
|
||||
if record.tool_material_search_id:
|
||||
# 注册刀具物料状态到cloud平台
|
||||
record.enroll_tool_material_stock()
|
||||
elif record.fixture_material_search_id:
|
||||
if record.fixture_material_search_id:
|
||||
# 注册夹具物料状态到cloud平台
|
||||
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,8 @@ class ToolMaterial(models.Model):
|
||||
record.have_been_used_num = have_been_used_num
|
||||
record.scrap_num = scrap_num
|
||||
record.number = usable_num + have_been_used_num + scrap_num
|
||||
# 更新数据到cloud的动态数据
|
||||
record.enroll_tool_material()
|
||||
|
||||
|
||||
|
||||
@api.model
|
||||
def _read_group_cutting_tool_material_id(self, categories, domain, order):
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="button_safe_inventory_id" string="更新功能刀具关联的安全库存记录"
|
||||
type="object" class="btn-primary"/>
|
||||
<!-- <button name="button_safe_inventory_id" string="更新功能刀具关联的安全库存记录"-->
|
||||
<!-- type="object" class="btn-primary"/>-->
|
||||
<button class="oe_stat_button" groups="sf_base.group_sf_mrp_user"
|
||||
name="open_functional_tool_warning"
|
||||
icon="fa-list-ul"
|
||||
@@ -155,24 +155,25 @@
|
||||
<group>
|
||||
<field name="functional_tool_diameter"/>
|
||||
<field name="knife_tip_r_angle"/>
|
||||
<field name="whether_standard_knife"/>
|
||||
<field name="coarse_middle_thin"/>
|
||||
<field name="tool_loading_length"/>
|
||||
<field name="handle_length"/>
|
||||
<field name="functional_tool_length"/>
|
||||
<field name="max_lifetime_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"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="tool_loading_length"/>
|
||||
<field name="functional_tool_length"/>
|
||||
<field name="effective_length"/>
|
||||
<field name="L_D_number"/>
|
||||
<field name="hiding_length"/>
|
||||
<field name="whether_standard_knife"/>
|
||||
<field name="coarse_middle_thin"/>
|
||||
<field name="effective_length" invisible="1"/>
|
||||
<field name="L_D_number" invisible="1"/>
|
||||
<field name="hiding_length" invisible="1"/>
|
||||
<field name="new_former"/>
|
||||
<field name="cut_time" attrs="{'invisible': [('new_former','=','0')]}"/>
|
||||
<field name="cut_length" attrs="{'invisible': [('new_former','=','0')]}"/>
|
||||
<field name="cut_number" attrs="{'invisible': [('new_former','=','0')]}"/>
|
||||
<field name="current_location" string="当前位置"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
@@ -451,36 +451,9 @@
|
||||
<field name="whether_standard_knife" invisible="True"/>
|
||||
<field name="reason_for_applying" invisible="True"/>
|
||||
<field name="functional_tool_type_id" invisible="True"/>
|
||||
<!-- <field name="functional_tool_cutting_type" invisible="True"/>-->
|
||||
|
||||
<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"
|
||||
<button string="组装" name="put_start_preset" type="object"
|
||||
attrs="{'invisible': [('assemble_status', '!=', '0')]}"
|
||||
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>
|
||||
</field>
|
||||
</record>
|
||||
@@ -491,35 +464,11 @@
|
||||
<field name="arch" type="xml">
|
||||
<form create="0" delete="0" edit="0">
|
||||
<header>
|
||||
<button string="组装"
|
||||
name="%(sf_tool_management.sf_functional_tool_assembly_order_act)d"
|
||||
type="action" groups="sf_base.group_sf_mrp_user"
|
||||
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,
|
||||
}"
|
||||
<!-- <button string="修改编码" name="put_assembly_order_code" type="object"-->
|
||||
<!-- class="btn-primary" confirm="是否确认修改编码"/>-->
|
||||
<button string="组装" name="put_start_preset" type="object"
|
||||
attrs="{'invisible': [('assemble_status', '!=', '0')]}"
|
||||
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"/>
|
||||
</header>
|
||||
<sheet>
|
||||
@@ -544,7 +493,7 @@
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="组装信息" attrs="{'invisible': [('assemble_status', '=' ,'0')]}">
|
||||
<page string="组装信息" attrs="{'invisible': [('assemble_status', '=', '0')]}">
|
||||
<group col="1">
|
||||
<group col="1">
|
||||
<group>
|
||||
@@ -557,9 +506,9 @@
|
||||
<field name="after_assembly_functional_tool_type_id"
|
||||
string="功能刀具类型"/>
|
||||
<field name="tool_groups_id"/>
|
||||
<field name="after_assembly_functional_tool_diameter"
|
||||
string="刀具直径(mm)"/>
|
||||
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"/>
|
||||
<field name="after_assembly_whether_standard_knife"
|
||||
string="是否标准刀"/>
|
||||
<field name="after_assembly_coarse_middle_thin" string="粗/中/精"/>
|
||||
<field name="after_assembly_new_former" string="新/旧"/>
|
||||
<field name="cut_time"
|
||||
attrs="{'invisible': [('after_assembly_new_former', '=', '0')]}"/>
|
||||
@@ -569,19 +518,20 @@
|
||||
attrs="{'invisible': [('after_assembly_new_former', '=', '0')]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="after_assembly_whether_standard_knife"
|
||||
string="是否标准刀"/>
|
||||
<field name="after_assembly_coarse_middle_thin" string="粗/中/精"/>
|
||||
<field name="after_assembly_functional_tool_diameter"
|
||||
string="刀具直径(mm)"/>
|
||||
<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"
|
||||
string="最大寿命值(min)"/>
|
||||
<field name="after_assembly_alarm_value" string="报警值(min)"/>
|
||||
<field name="after_assembly_used_value" string="已使用值(min)"/>
|
||||
<field name="after_assembly_tool_loading_length" string="总长度(mm)"/>
|
||||
<field name="after_assembly_functional_tool_length"
|
||||
string="伸出长(mm)"/>
|
||||
<field name="after_assembly_effective_length" string="有效长(mm)"/>
|
||||
<field name="L_D_number"/>
|
||||
<field name="hiding_length"/>
|
||||
<field name="after_assembly_used_value" string="已使用值(min)" invisible="1"/>
|
||||
<field name="after_assembly_effective_length" string="有效长(mm)" invisible="1"/>
|
||||
<field name="L_D_number" invisible="1"/>
|
||||
<field name="hiding_length" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
@@ -223,8 +223,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
image = fields.Binary('图片')
|
||||
|
||||
@api.onchange('functional_tool_name')
|
||||
def _onchange_functional_tool_name(self):
|
||||
@api.depends('functional_tool_name')
|
||||
def _compute_functional_tool_name(self):
|
||||
for item in self:
|
||||
if item.functional_tool_name:
|
||||
inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', item.functional_tool_name)])
|
||||
@@ -355,7 +355,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
# ================刀柄型号===============
|
||||
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', '=', '刀柄'),
|
||||
('tool_material_status', '=', '可用')])
|
||||
handle_product_id = fields.Many2one('product.product', string='刀柄名称', compute='_compute_handle_product_id',
|
||||
@@ -456,15 +456,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
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='功能刀具序列号')
|
||||
rfid = fields.Char('Rfid', compute='_compute_rfid')
|
||||
code = fields.Char(string='功能刀具编码', compute='_compute_code')
|
||||
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name', store=True)
|
||||
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
|
||||
string='组装后功能刀具类型')
|
||||
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)')
|
||||
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)')
|
||||
string='组装后功能刀具类型', store=True,
|
||||
compute='_compute_after_assembly_max_lifetime_value')
|
||||
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')
|
||||
cut_time = fields.Integer(string='已切削时间(min)')
|
||||
cut_length = fields.Float(string='已切削长度(mm)')
|
||||
@@ -473,15 +475,66 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
after_assembly_whether_standard_knife = fields.Boolean(string='组装后是否标准刀', default=True)
|
||||
after_assembly_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('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_used_value = fields.Integer(string='组装后已使用值(min)')
|
||||
after_assembly_tool_loading_length = fields.Float(string='组装后总长度(mm)')
|
||||
after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)', required=True)
|
||||
after_assembly_tool_loading_length = fields.Float(string='组装后总长度(mm)', digits=(10, 3))
|
||||
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)')
|
||||
L_D_number = fields.Float(string='L/D值(mm)', compute='_compute_l_d_number')
|
||||
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)
|
||||
|
||||
@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')
|
||||
def _onchange_number(self):
|
||||
@@ -489,14 +542,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
if item.after_name_id:
|
||||
item.after_assembly_functional_tool_diameter = item.after_name_id.diameter
|
||||
item.after_assembly_knife_tip_r_angle = item.after_name_id.angle
|
||||
item.after_assembly_max_lifetime_value = item.after_name_id.life_span
|
||||
item.after_assembly_tool_loading_length = item.after_name_id.tool_length
|
||||
item.after_assembly_functional_tool_length = item.after_name_id.extension
|
||||
item.hiding_length = item.after_name_id.blade_length
|
||||
item.after_assembly_functional_tool_type_id = item.after_name_id.functional_cutting_tool_model_id.id
|
||||
item.after_tool_groups_id = item.after_name_id.tool_groups_id.id
|
||||
|
||||
else:
|
||||
item.after_assembly_functional_tool_type_id = item.functional_tool_type_id
|
||||
item.after_assembly_functional_tool_type_id = item.functional_tool_type_id.id
|
||||
item.after_tool_groups_id = item.tool_groups_id.id
|
||||
|
||||
# functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False)
|
||||
@@ -574,24 +625,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
else:
|
||||
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):
|
||||
"""
|
||||
功能刀具组装
|
||||
@@ -659,16 +692,39 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
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:
|
||||
raise ValidationError('【整体式刀具】和【刀片】必须填写一个!')
|
||||
if self.blade_product_id:
|
||||
if not self.bar_product_id and not self.pad_product_id:
|
||||
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):
|
||||
return {
|
||||
'start_preset_bool': False,
|
||||
'barcode_id': stock_lot.id,
|
||||
'code': self.code,
|
||||
'rfid': self.rfid,
|
||||
@@ -694,6 +750,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
'after_assembly_alarm_value': self.after_assembly_alarm_value,
|
||||
'after_assembly_used_value': self.after_assembly_used_value,
|
||||
'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_effective_length': self.after_assembly_effective_length,
|
||||
'L_D_number': self.L_D_number,
|
||||
@@ -726,6 +783,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
'coarse_middle_thin': self.after_assembly_coarse_middle_thin,
|
||||
'new_former': self.after_assembly_new_former,
|
||||
'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,
|
||||
'effective_length': self.after_assembly_effective_length,
|
||||
|
||||
@@ -918,14 +976,13 @@ class StockLot(models.Model):
|
||||
})
|
||||
return stock_move_id, stock_move_line_id
|
||||
|
||||
|
||||
class StockQuant(models.Model):
|
||||
_inherit = 'stock.quant'
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super(StockQuant, self).create(vals_list)
|
||||
for record in records:
|
||||
if record.lot_id.product_id.categ_id.name == '刀具':
|
||||
record.lot_id.enroll_tool_material_stock()
|
||||
return records
|
||||
# class StockQuant(models.Model):
|
||||
# _inherit = 'stock.quant'
|
||||
#
|
||||
# @api.model_create_multi
|
||||
# def create(self, vals_list):
|
||||
# records = super(StockQuant, self).create(vals_list)
|
||||
# for record in records:
|
||||
# if record.lot_id.product_id.categ_id.name == '刀具':
|
||||
# record.lot_id.enroll_tool_material_stock()
|
||||
# return records
|
||||
|
||||
@@ -166,11 +166,12 @@
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<field name="production_line_name_id"/>
|
||||
<field name="assembly_order_code"/>
|
||||
</h1>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="production_line_name_id"/>
|
||||
<field name="machine_tool_name_id"/>
|
||||
<field name="cutter_spacing_code_id"/>
|
||||
</group>
|
||||
@@ -178,24 +179,26 @@
|
||||
<field name="image" nolabel="1" widget="image"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="功能刀具申请信息">
|
||||
<group string="功能刀具申请信息" col="1">
|
||||
<group>
|
||||
<field name="functional_tool_name"/>
|
||||
<field name="functional_tool_type_id"/>
|
||||
<field name="tool_groups_id"/>
|
||||
<field name="functional_tool_diameter" string="刀具直径(mm)"/>
|
||||
<field name="knife_tip_r_angle"/>
|
||||
<field name="tool_loading_length"/>
|
||||
<field name="functional_tool_length"/>
|
||||
<field name="effective_length"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="whether_standard_knife"/>
|
||||
<field name="coarse_middle_thin"/>
|
||||
<field name="new_former"/>
|
||||
<field name="use_tool_time"/>
|
||||
<field name="reason_for_applying"/>
|
||||
<!-- <field name="functional_tool_cutting_type"/>-->
|
||||
<group>
|
||||
<field name="functional_tool_name"/>
|
||||
<field name="functional_tool_type_id"/>
|
||||
<field name="tool_groups_id"/>
|
||||
<field name="functional_tool_diameter" string="刀具直径(mm)"/>
|
||||
<field name="knife_tip_r_angle"/>
|
||||
<field name="tool_loading_length"/>
|
||||
<field name="functional_tool_length"/>
|
||||
<field name="effective_length"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="whether_standard_knife"/>
|
||||
<field name="coarse_middle_thin"/>
|
||||
<field name="new_former"/>
|
||||
<field name="use_tool_time"/>
|
||||
<field name="reason_for_applying"/>
|
||||
<!-- <field name="functional_tool_cutting_type"/>-->
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group string="组装物料信息" col="1">
|
||||
@@ -330,53 +333,66 @@
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<group string="组装参数信息">
|
||||
<group string="组装参数信息" col="1">
|
||||
<group>
|
||||
<group>
|
||||
<field name="barcode_id" invisible="True"/>
|
||||
<field name="code" readonly="True"/>
|
||||
<field name="rfid" class="custom_required"/>
|
||||
<field name="after_name_id" string="功能刀具名称" placeholder="请选择功能刀具名称"
|
||||
</group>
|
||||
<group>
|
||||
<field name="obtain_measurement_status" invisible="1"/>
|
||||
<button name="get_tool_preset_parameter" string="获取测量值" type="object"
|
||||
class="btn-primary"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group>
|
||||
<field name="after_name_id" string="功能刀具名称" placeholder="请选择功能刀具名称" readonly="1"
|
||||
options="{'no_create': True, 'no_quick_create': True}"/>
|
||||
<field name="after_assembly_functional_tool_name" string="功能刀具名称" invisible="1"/>
|
||||
<field name="after_assembly_functional_tool_type_id" string="功能刀具类型"
|
||||
<field name="after_assembly_functional_tool_name" string="功能刀具名称"
|
||||
invisible="1"/>
|
||||
<field name="after_assembly_functional_tool_type_id" string="功能刀具类型" readonly="1"
|
||||
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}"/>
|
||||
<field name="after_assembly_functional_tool_diameter" string="刀具直径(mm)"
|
||||
class="custom_required"/>
|
||||
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"
|
||||
class="custom_required"/>
|
||||
<field name="after_assembly_whether_standard_knife" string="是否标准刀"/>
|
||||
<field name="after_assembly_coarse_middle_thin" 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"
|
||||
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
|
||||
<field name="cut_number"
|
||||
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group>
|
||||
<field name="after_assembly_whether_standard_knife" string="是否标准刀"/>
|
||||
<field name="after_assembly_coarse_middle_thin" string="粗/中/精"/>
|
||||
<field name="after_assembly_max_lifetime_value" string="最大寿命值(min)"
|
||||
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_functional_tool_diameter" string="刀具直径(mm)"
|
||||
class="custom_required" readonly="1"/>
|
||||
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"
|
||||
class="custom_required" readonly="1"/>
|
||||
<field name="after_assembly_tool_loading_length" string="总长度(mm)"
|
||||
class="custom_required" readonly="1"/>
|
||||
<field name="after_assembly_handle_length" string="刀柄长度(mm)"
|
||||
class="custom_required"/>
|
||||
<field name="after_assembly_functional_tool_length" string="伸出长(mm)"
|
||||
class="custom_required"/>
|
||||
<field name="after_assembly_effective_length" string="有效长(mm)"
|
||||
<field name="after_assembly_max_lifetime_value" string="最大寿命值(min)"
|
||||
class="custom_required"/>
|
||||
<field name="hiding_length" class="custom_required"/>
|
||||
<field name="L_D_number"/>
|
||||
<field name="after_assembly_alarm_value" string="报警值(min)"
|
||||
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>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button string="确定" name="functional_tool_assembly" type="object" class="btn-primary"
|
||||
attrs="{'invisible': [('obtain_measurement_status', '=', False)]}"
|
||||
confirm="是否确认申请组装"/>
|
||||
<button string="取消" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
|
||||
@@ -859,14 +859,36 @@ class SfStockPicking(models.Model):
|
||||
|
||||
check_in = fields.Char(string='查询是否为入库单', compute='_check_is_in')
|
||||
|
||||
def batch_stock_move(self):
|
||||
"""
|
||||
批量调拨,非就绪状态的会被忽略,完成后有通知提示
|
||||
"""
|
||||
for record in self:
|
||||
if record.state != 'assigned':
|
||||
continue
|
||||
record.action_set_quantities_to_reservation()
|
||||
record.button_validate()
|
||||
|
||||
notification_message = '批量调拨完成!请注意,状态非就绪的单据会被忽略'
|
||||
return {
|
||||
'effect': {
|
||||
'fadeout': 'fast',
|
||||
'message': notification_message,
|
||||
'img_url': '/web/image/%s/%s/image_1024' % (
|
||||
self.create_uid._name, self.create_uid.id) if 0 else '/web/static/img/smile.svg',
|
||||
'type': 'rainbow_man',
|
||||
}
|
||||
}
|
||||
|
||||
@api.depends('name')
|
||||
def _check_is_in(self):
|
||||
"""
|
||||
判断是否为出库单
|
||||
"""
|
||||
if self.name:
|
||||
is_check_in = self.name.split('/')
|
||||
self.check_in = is_check_in[1]
|
||||
for record in self:
|
||||
if record.name:
|
||||
is_check_in = record.name.split('/')
|
||||
record.check_in = is_check_in[1]
|
||||
|
||||
def button_validate(self):
|
||||
"""
|
||||
|
||||
@@ -149,6 +149,9 @@
|
||||
<button name="action_assign" type="object" string="检查可用量"
|
||||
groups="sf_base.group_sf_stock_user"/>
|
||||
</xpath>
|
||||
<xpath expr="//header" position="inside">
|
||||
<button name="batch_stock_move" type='object' string="批量调拨"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user