Compare commits
62 Commits
release/re
...
release_1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
609e65e36f | ||
|
|
fdfd01605d | ||
|
|
49d55822cc | ||
|
|
2db81ac2cc | ||
|
|
a673630fd3 | ||
|
|
6c5b888bba | ||
|
|
aa6b476e35 | ||
|
|
263253e79e | ||
|
|
edda681940 | ||
|
|
7043d2b8b7 | ||
|
|
6d66872dee | ||
|
|
3ab378f3bd | ||
|
|
26c979ef1d | ||
|
|
9aa4858774 | ||
|
|
d883a7ff22 | ||
|
|
17678c53c9 | ||
|
|
fb3cc095b2 | ||
|
|
c437c185a4 | ||
|
|
b3eb3ee8fa | ||
|
|
b9ec821293 | ||
|
|
f8a9fcc0ce | ||
|
|
d12714dd65 | ||
|
|
a1bea537bb | ||
|
|
5350675355 | ||
|
|
65d2593db9 | ||
|
|
a529c5513e | ||
|
|
f5f881f256 | ||
|
|
d2babec1aa | ||
|
|
f7723f1b9c | ||
|
|
ef80848e9b | ||
|
|
138dd40a9e | ||
|
|
dc210f7263 | ||
|
|
9055e7ed8b | ||
|
|
6890ddf615 | ||
|
|
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 |
@@ -504,3 +504,21 @@ div:has(.o_required_modifier) > label::before {
|
|||||||
background-color: #4A4F59;
|
background-color: #4A4F59;
|
||||||
border-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;
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
.o_data_row .w-100 {
|
.o_data_row .w-100 {
|
||||||
width: 40px !important;
|
width: 40px !important;
|
||||||
height: 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) {
|
.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) {
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ class MrpProduction(models.Model):
|
|||||||
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]))
|
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]))
|
||||||
else:
|
else:
|
||||||
production.write({'programming_no': production_programming.programming_no,
|
production.write({'programming_no': production_programming.programming_no,
|
||||||
'programming_state': '编程中'})
|
'programming_state': '已编程' if production_programming.programming_state == '已编程' else '编程中'})
|
||||||
# # 根据加工面板的面数及对应的工序模板生成工单
|
# # 根据加工面板的面数及对应的工序模板生成工单
|
||||||
i = 0
|
i = 0
|
||||||
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
||||||
@@ -379,6 +379,12 @@ class MrpProduction(models.Model):
|
|||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
||||||
production.workorder_ids = workorders_values
|
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:
|
for workorder in production.workorder_ids:
|
||||||
workorder.duration_expected = workorder._get_duration_expected()
|
workorder.duration_expected = workorder._get_duration_expected()
|
||||||
|
|
||||||
@@ -406,20 +412,15 @@ class MrpProduction(models.Model):
|
|||||||
|
|
||||||
# 工单排序
|
# 工单排序
|
||||||
def _reset_work_order_sequence1(self, k):
|
def _reset_work_order_sequence1(self, k):
|
||||||
sequen = 0
|
|
||||||
for rec in self:
|
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:
|
for work in rec.workorder_ids:
|
||||||
work.sequence = current_sequence
|
if work.name == cnc_workorder.name and work.processing_panel == k:
|
||||||
current_sequence += 10
|
cnc_back_workorder.write({'sequence': work.sequence + 1})
|
||||||
if work.name == '后置三元质量检测' and work.processing_panel == k:
|
print(cnc_back_workorder.sequence)
|
||||||
sequen = work.sequence
|
elif work.routing_type not in ['装夹预调'] and work != cnc_back_workorder:
|
||||||
|
work.sequence += 1
|
||||||
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
|
|
||||||
|
|
||||||
# 在制造订单上新增工单
|
# 在制造订单上新增工单
|
||||||
def _create_workorder1(self, k):
|
def _create_workorder1(self, k):
|
||||||
@@ -459,13 +460,7 @@ class MrpProduction(models.Model):
|
|||||||
order='sequence asc'
|
order='sequence asc'
|
||||||
)
|
)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
for route in routingworkcenter:
|
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加工':
|
if route.routing_type == 'CNC加工':
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str1(k, production, route))
|
self.env['mrp.workorder'].json_workorder_str1(k, production, route))
|
||||||
|
|||||||
@@ -677,13 +677,59 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(
|
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(
|
||||||
self.production_id.company_id).create(
|
self.production_id.company_id).create(
|
||||||
values)
|
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())
|
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||||
productions._create_workorder()
|
productions._create_workorder()
|
||||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||||
(
|
(
|
||||||
p.move_dest_ids.procure_method != 'make_to_order' and
|
p.move_dest_ids.procure_method != 'make_to_order' and
|
||||||
not p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
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:
|
for production in productions:
|
||||||
origin_production = production.move_dest_ids and production.move_dest_ids[
|
origin_production = production.move_dest_ids and production.move_dest_ids[
|
||||||
@@ -704,6 +750,28 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'mail.message_origin_link',
|
'mail.message_origin_link',
|
||||||
values={'self': production, 'origin': origin_production},
|
values={'self': production, 'origin': origin_production},
|
||||||
subtype_id=self.env.ref('mail.mt_note').id)
|
subtype_id=self.env.ref('mail.mt_note').id)
|
||||||
|
|
||||||
|
'''
|
||||||
|
创建生产计划
|
||||||
|
'''
|
||||||
|
# 工单耗时
|
||||||
|
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.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 == '返工':
|
if self.test_results == '返工':
|
||||||
productions = self.production_id
|
productions = self.production_id
|
||||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||||
@@ -720,7 +788,6 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'name': '%s(返工)' % route.route_workcenter_id.name,
|
'name': '%s(返工)' % route.route_workcenter_id.name,
|
||||||
'processing_panel': k,
|
'processing_panel': k,
|
||||||
'routing_type': route.routing_type,
|
'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,
|
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
|
||||||
route.routing_type,
|
route.routing_type,
|
||||||
production.product_id),
|
production.product_id),
|
||||||
@@ -728,10 +795,38 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'date_planned_finished': datetime.now() + timedelta(days=1),
|
'date_planned_finished': datetime.now() + timedelta(days=1),
|
||||||
'duration_expected': 60,
|
'duration_expected': 60,
|
||||||
'duration': 0,
|
'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
|
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:
|
||||||
|
scrap_workorder = self.env['mrp.workorder'].search(
|
||||||
|
[('production_id', '=', item.production_id.id), ('routing_type', '=', 'CNC加工'),
|
||||||
|
('state', '=', 'done'), ('is_remanufacture', '=', True)])
|
||||||
|
print(item.name)
|
||||||
|
print(item.state)
|
||||||
|
if item.name == 'CNC加工(返工)' and item.state not in ['ready', 'progress', 'done']:
|
||||||
|
item.state = 'ready'
|
||||||
|
if item.routing_type == '解除装夹':
|
||||||
|
last_workorder = self.env['mrp.workorder'].search(
|
||||||
|
[('production_id', '=', item.production_id.id), ('name', '=', 'CNC加工(返工)'),
|
||||||
|
('state', '!=', 'done')])
|
||||||
|
if item.state != 'pending':
|
||||||
|
if last_workorder:
|
||||||
|
item.state = 'pending'
|
||||||
|
if scrap_workorder:
|
||||||
|
item.state = 'cancel'
|
||||||
|
elif item.routing_type == '表面工艺':
|
||||||
|
if scrap_workorder:
|
||||||
|
item.state = 'cancel'
|
||||||
|
|
||||||
# 重写工单开始按钮方法
|
# 重写工单开始按钮方法
|
||||||
def button_start(self):
|
def button_start(self):
|
||||||
if self.routing_type == '装夹预调':
|
if self.routing_type == '装夹预调':
|
||||||
@@ -895,6 +990,8 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
record.write({
|
record.write({
|
||||||
'date_planned_finished': tem_date_planned_finished # 保持原值
|
'date_planned_finished': tem_date_planned_finished # 保持原值
|
||||||
})
|
})
|
||||||
|
if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']:
|
||||||
|
record.recreateManufacturingOrWorkerOrder()
|
||||||
is_production_id = True
|
is_production_id = True
|
||||||
for workorder in record.production_id.workorder_ids:
|
for workorder in record.production_id.workorder_ids:
|
||||||
if workorder.state != 'done':
|
if workorder.state != 'done':
|
||||||
@@ -1039,6 +1136,8 @@ class CNCprocessing(models.Model):
|
|||||||
for f in files:
|
for f in files:
|
||||||
if os.path.splitext(f)[1] == ".pdf":
|
if os.path.splitext(f)[1] == ".pdf":
|
||||||
full_path = os.path.join(serverdir, root, f)
|
full_path = os.path.join(serverdir, root, f)
|
||||||
|
if full_path is not False:
|
||||||
|
if not cnc_processing.workorder_id.cnc_worksheet:
|
||||||
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
||||||
open(full_path, 'rb').read())
|
open(full_path, 'rb').read())
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="name" required="1"/>
|
<field name="name" required="1"/>
|
||||||
<field name="type" readonly="1" string="任务类型"/>
|
<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="start_site_id" required="1" options="{'no_create': True}" string="起点接驳站"/>
|
||||||
<field name="end_site_id" required="1" options="{'no_create': True}" string="终点接驳站"/>
|
<field name="end_site_id" required="1" options="{'no_create': True}" string="终点接驳站"/>
|
||||||
<field name="destination_production_line_id" required="1" options="{'no_create': True}"/>
|
<field name="destination_production_line_id" required="1" options="{'no_create': True}"/>
|
||||||
|
|||||||
@@ -477,7 +477,7 @@
|
|||||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||||
<group>
|
<group>
|
||||||
<field name="test_results" attrs='{"invisible":[("results","!=",False)]}'/>
|
<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="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
|
<field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
|
||||||
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
|
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
|
||||||
widget="pdf_viewer"/>
|
widget="pdf_viewer"/>
|
||||||
@@ -618,7 +618,6 @@
|
|||||||
<field name="route_id" options="{'no_create': True}"
|
<field name="route_id" options="{'no_create': True}"
|
||||||
domain="[('route_type','in',['上产线','下产线'])]"/>
|
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_start_id" readonly="1" force_save="1"/>
|
|
||||||
<field name="feeder_station_destination_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="is_cnc_program_down" readonly="1"/>
|
||||||
<!-- <field name="rfid_code"/>-->
|
<!-- <field name="rfid_code"/>-->
|
||||||
|
|||||||
@@ -24,22 +24,12 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
ret = json.loads(ret['result'])
|
ret = json.loads(ret['result'])
|
||||||
logging.info('下发编程单:%s' % ret)
|
logging.info('下发编程单:%s' % ret)
|
||||||
is_delete_file = False
|
|
||||||
# 查询状态为进行中且类型为获取CNC加工程序的工单
|
# 查询状态为进行中且类型为获取CNC加工程序的工单
|
||||||
cnc_production = request.env['mrp.production'].with_user(
|
cnc_production = request.env['mrp.production'].with_user(
|
||||||
request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'].split(',')[0])])
|
request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'].split(',')[0])])
|
||||||
cnc_program = request.env['mrp.production'].with_user(
|
cnc_program = request.env['mrp.production'].with_user(
|
||||||
request.env.ref("base.user_admin")).search(
|
request.env.ref("base.user_admin")).search(
|
||||||
[('programming_no', '=', cnc_production.programming_no), ('id', '!=', cnc_production.id)])
|
[('programming_no', '=', cnc_production.programming_no), ('id', '!=', cnc_production.id)])
|
||||||
if cnc_production.workorder_ids.filtered(lambda a: a.routing_type == 'CNC加工').cnc_ids:
|
|
||||||
is_delete_file = True
|
|
||||||
cnc_production.workorder_ids.filtered(
|
|
||||||
lambda a1: a1.routing_type == 'CNC加工').cnc_ids.sudo().unlink()
|
|
||||||
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_production)
|
|
||||||
if cnc_program.workorder_ids.filtered(lambda c: c.routing_type == 'CNC加工').cnc_ids:
|
|
||||||
cnc_program.workorder_ids.filtered(
|
|
||||||
lambda c1: c1.routing_type == 'CNC加工').cnc_ids.sudo().unlink()
|
|
||||||
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_program)
|
|
||||||
# cnc_program = request.env['mrp.production'].with_user(
|
# cnc_program = request.env['mrp.production'].with_user(
|
||||||
# request.env.ref("base.user_admin")).search([('programming_no', '=', cnc_production.programming_no)])
|
# request.env.ref("base.user_admin")).search([('programming_no', '=', cnc_production.programming_no)])
|
||||||
logging.info('制造订单号:%s' % cnc_production.name)
|
logging.info('制造订单号:%s' % cnc_production.name)
|
||||||
@@ -47,13 +37,6 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
# if ret['glb_file']:
|
# if ret['glb_file']:
|
||||||
# cnc_production.glb_file = base64.b64encode(ret['glb_file'])
|
# cnc_production.glb_file = base64.b64encode(ret['glb_file'])
|
||||||
# 拉取所有加工面的程序文件
|
# 拉取所有加工面的程序文件
|
||||||
if is_delete_file is True:
|
|
||||||
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', 'R')
|
|
||||||
files_r = os.listdir(program_path_tmp_r)
|
|
||||||
if files_r:
|
|
||||||
for file_name in files_r:
|
|
||||||
file_path = os.path.join(program_path_tmp_r, file_name)
|
|
||||||
os.remove(file_path)
|
|
||||||
for r in ret['processing_panel']:
|
for r in ret['processing_panel']:
|
||||||
download_state = request.env['sf.cnc.processing'].with_user(
|
download_state = request.env['sf.cnc.processing'].with_user(
|
||||||
request.env.ref("base.user_admin")).download_file_tmp(
|
request.env.ref("base.user_admin")).download_file_tmp(
|
||||||
@@ -81,17 +64,15 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
if cnc_processing:
|
if cnc_processing:
|
||||||
cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing))
|
cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing))
|
||||||
if (cnc_program and cnc_processing_arr) or (not cnc_program and cnc_processing_arr):
|
if (cnc_program and cnc_processing_arr) or (not cnc_program and cnc_processing_arr):
|
||||||
cnc_production.workorder_ids.filtered(lambda g: g.routing_type == '装夹预调').write(
|
logging.info('cnc_processing_arr:%s' % cnc_processing_arr)
|
||||||
{'processing_drawing': cnc_production.workorder_ids.filtered(
|
|
||||||
lambda g1: g1.routing_type == 'CNC加工').cnc_worksheet})
|
|
||||||
if cnc_program and cnc_processing_arr:
|
if cnc_program and cnc_processing_arr:
|
||||||
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
cnc_program.workorder_ids.filtered(lambda d: d.routing_type == '装夹预调').write(
|
cnc_program.workorder_ids.filtered(lambda b1: b1.routing_type == '装夹预调').write(
|
||||||
{'processing_drawing': cnc_production.workorder_ids.filtered(
|
{'processing_drawing': cnc_production.workorder_ids.filtered(
|
||||||
lambda d1: d1.routing_type == 'CNC加工').cnc_worksheet})
|
lambda b1: b1.routing_type == 'CNC加工').cnc_worksheet})
|
||||||
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
||||||
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
||||||
lambda b1: b1.routing_type == 'CNC加工').cnc_worksheet})
|
lambda b: b.routing_type == 'CNC加工').cnc_worksheet})
|
||||||
cnc_program |= cnc_production
|
cnc_program |= cnc_production
|
||||||
if not cnc_program and cnc_processing_arr:
|
if not cnc_program and cnc_processing_arr:
|
||||||
cnc_program = cnc_production
|
cnc_program = cnc_production
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ class FtpController():
|
|||||||
logging.error(f"Error checking file: {e}")
|
logging.error(f"Error checking file: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # 检测字符串的编码
|
# # 检测字符串的编码
|
||||||
# def detect_encoding(self, s):
|
# def detect_encoding(self, s):
|
||||||
# result = chardet.detect(s)
|
# result = chardet.detect(s)
|
||||||
|
|||||||
@@ -8,35 +8,6 @@ from odoo.http import request
|
|||||||
|
|
||||||
class Manufacturing_Connect(http.Controller):
|
class Manufacturing_Connect(http.Controller):
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/ToolGroup', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
|
||||||
cors="*")
|
|
||||||
def get_functional_tool_groups_Info(self, **kw):
|
|
||||||
"""
|
|
||||||
刀具组接口
|
|
||||||
:param kw:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
logging.info('get_functional_tool_groups_Info:%s' % kw)
|
|
||||||
try:
|
|
||||||
datas = request.httprequest.data
|
|
||||||
ret = json.loads(datas)
|
|
||||||
# ret = json.loads(ret['result'])
|
|
||||||
logging.info('DeviceId:%s' % ret)
|
|
||||||
functional_tools = request.env['sf.tool.inventory'].sudo().search([])
|
|
||||||
|
|
||||||
res = {'Succeed': True, 'Datas': []}
|
|
||||||
if functional_tools:
|
|
||||||
for item in functional_tools:
|
|
||||||
res['Datas'].append({
|
|
||||||
'GroupName': item.tool_groups_id.name,
|
|
||||||
'ToolId': item.functional_cutting_tool_model_id.name,
|
|
||||||
'ToolName': item.name
|
|
||||||
})
|
|
||||||
except Exception as e:
|
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
|
||||||
logging.info('get_functional_tool_groups_Info error:%s' % e)
|
|
||||||
return json.JSONEncoder().encode(res)
|
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/ToolInventory', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/ToolInventory', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def get_functional_tool_inventory_Info(self, **kw):
|
def get_functional_tool_inventory_Info(self, **kw):
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
<field name="model_id" ref="model_sf_tool_datasync"/>
|
<field name="model_id" ref="model_sf_tool_datasync"/>
|
||||||
<field name="state">code</field>
|
<field name="state">code</field>
|
||||||
<field name="code">model._cron_tool_datasync_all()</field>
|
<field name="code">model._cron_tool_datasync_all()</field>
|
||||||
<field name="interval_number">1</field>
|
<field name="interval_number">12</field>
|
||||||
<field name="interval_type">days</field>
|
<field name="interval_type">hours</field>
|
||||||
<field name="numbercall">-1</field>
|
<field name="numbercall">-1</field>
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -311,11 +311,10 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
|||||||
'applicant': None,
|
'applicant': None,
|
||||||
'sf_functional_tool_assembly_id': None})
|
'sf_functional_tool_assembly_id': None})
|
||||||
|
|
||||||
def create_cam_work_plan(self, cnc_processing_ids):
|
def create_cam_work_plan(self, cnc_processing):
|
||||||
"""
|
"""
|
||||||
根据传入的工单信息,查询是否有需要的功能刀具,如果没有则生成CAM工单程序用刀计划
|
根据传入的工单信息,查询是否有需要的功能刀具,如果没有则生成CAM工单程序用刀计划
|
||||||
"""
|
"""
|
||||||
for cnc_processing in cnc_processing_ids:
|
|
||||||
status = False
|
status = False
|
||||||
if cnc_processing.cutting_tool_name:
|
if cnc_processing.cutting_tool_name:
|
||||||
functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search(
|
functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search(
|
||||||
@@ -348,17 +347,6 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
|||||||
else:
|
else:
|
||||||
logging.info('功能刀具【%s】满足CNC用刀需求!!!' % cnc_processing.cutting_tool_name)
|
logging.info('功能刀具【%s】满足CNC用刀需求!!!' % cnc_processing.cutting_tool_name)
|
||||||
|
|
||||||
def unlink_cam_plan(self, production):
|
|
||||||
for item in production:
|
|
||||||
cam_plan_ids = self.env['sf.cam.work.order.program.knife.plan'].search([('name', '=', item.name)])
|
|
||||||
for cam_plan_id in cam_plan_ids:
|
|
||||||
assembly_id = cam_plan_id.sf_functional_tool_assembly_id
|
|
||||||
if assembly_id.assemble_status in ('0', '待组装') and not assembly_id.start_preset_bool:
|
|
||||||
logging.info('%s删除成功!!!' % assembly_id)
|
|
||||||
assembly_id.sudo().unlink()
|
|
||||||
logging.info('unlink_cam_plan成功!!!')
|
|
||||||
cam_plan_ids.sudo().unlink()
|
|
||||||
|
|
||||||
|
|
||||||
class FunctionalToolAssembly(models.Model):
|
class FunctionalToolAssembly(models.Model):
|
||||||
_name = 'sf.functional.tool.assembly'
|
_name = 'sf.functional.tool.assembly'
|
||||||
@@ -555,8 +543,7 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', readonly=True)
|
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', readonly=True)
|
||||||
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
|
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
|
||||||
string='组装后功能刀具类型', readonly=True)
|
string='组装后功能刀具类型', readonly=True)
|
||||||
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)', readonly=True,
|
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)', readonly=True, digits=(10, 3))
|
||||||
digits=(10, 3))
|
|
||||||
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)', readonly=True, digits=(10, 3))
|
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)', readonly=True, digits=(10, 3))
|
||||||
after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', readonly=True)
|
after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', readonly=True)
|
||||||
cut_time = fields.Integer(string='已切削时间(min)', readonly=True)
|
cut_time = fields.Integer(string='已切削时间(min)', readonly=True)
|
||||||
@@ -864,10 +851,6 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
||||||
if self.functional_tool_id.functional_tool_status == '已拆除':
|
if self.functional_tool_id.functional_tool_status == '已拆除':
|
||||||
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
|
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
|
||||||
# 对拆解的功能刀具进行校验,只有在刀具房的功能刀具才能拆解
|
|
||||||
if self.functional_tool_id.tool_room_num == 0:
|
|
||||||
raise ValidationError('Rfid为【%s】的功能刀具当前位置为【%s】,不能进行拆解!' % (
|
|
||||||
self.rfid, self.functional_tool_id.current_location))
|
|
||||||
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
||||||
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
|
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
|
||||||
# =================刀柄是否[报废]拆解=======
|
# =================刀柄是否[报废]拆解=======
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
import requests
|
import requests
|
||||||
|
import logging
|
||||||
from odoo import models, api
|
from odoo import models, api
|
||||||
from odoo.addons.sf_base.commons.common import Common
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
@@ -10,14 +11,17 @@ class StockLot(models.Model):
|
|||||||
_inherit = 'stock.lot'
|
_inherit = 'stock.lot'
|
||||||
_description = '夹具物料序列号注册'
|
_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()
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
str_url = sf_sync_config['sf_url'] + "/api/fixture_material_stock/create"
|
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 = []
|
fixture_material_stock_list = []
|
||||||
|
try:
|
||||||
if objs_all:
|
if objs_all:
|
||||||
for item in objs_all:
|
for item in objs_all:
|
||||||
val = {
|
val = {
|
||||||
@@ -31,9 +35,12 @@ class StockLot(models.Model):
|
|||||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
if ret.get('code') == 200:
|
if ret.get('code') == 200:
|
||||||
|
logging.info("夹具物料序列号每日同步成功")
|
||||||
return '夹具物料序列号注册成功'
|
return '夹具物料序列号注册成功'
|
||||||
else:
|
else:
|
||||||
raise UserError("没有注册夹具物料序列号信息")
|
logging.info("没有注册夹具物料序列号信息")
|
||||||
|
except Exception as e:
|
||||||
|
logging.info("夹具物料序列号同步失败:%s" % e)
|
||||||
|
|
||||||
|
|
||||||
class FixtureMaterialSearch(models.Model):
|
class FixtureMaterialSearch(models.Model):
|
||||||
@@ -42,14 +49,16 @@ class FixtureMaterialSearch(models.Model):
|
|||||||
|
|
||||||
crea_url = "/api/fixture_material/create"
|
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()
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||||
objs_all = self.search([('id', '=', self.id)])
|
objs_all = self.search([])
|
||||||
fixture_material_list = []
|
fixture_material_list = []
|
||||||
|
try:
|
||||||
if objs_all:
|
if objs_all:
|
||||||
for obj in objs_all:
|
for obj in objs_all:
|
||||||
val = {
|
val = {
|
||||||
@@ -69,14 +78,17 @@ class FixtureMaterialSearch(models.Model):
|
|||||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
if ret.get('code') == 200:
|
if ret.get('code') == 200:
|
||||||
|
logging.info("夹具物料每日同步成功")
|
||||||
return '夹具物料注册成功'
|
return '夹具物料注册成功'
|
||||||
else:
|
else:
|
||||||
raise UserError("没有注册夹具物料信息")
|
logging.info("没有注册夹具物料信息")
|
||||||
|
except Exception as e:
|
||||||
|
logging.info("夹具物料同步失败:%s" % e)
|
||||||
|
|
||||||
@api.model_create_multi
|
# @api.model_create_multi
|
||||||
def create(self, vals_list):
|
# def create(self, vals_list):
|
||||||
records = super(FixtureMaterialSearch, self).create(vals_list)
|
# records = super(FixtureMaterialSearch, self).create(vals_list)
|
||||||
for record in records:
|
# for record in records:
|
||||||
if record:
|
# if record:
|
||||||
record.enroll_fixture_material()
|
# record.enroll_fixture_material()
|
||||||
return records
|
# return records
|
||||||
|
|||||||
@@ -33,23 +33,26 @@ def get_suitable_coolant_names(item):
|
|||||||
|
|
||||||
class ToolDatasync(models.Model):
|
class ToolDatasync(models.Model):
|
||||||
_name = 'sf.tool.datasync'
|
_name = 'sf.tool.datasync'
|
||||||
_description = '定时同步所有刀具'
|
_description = '定时同步所有刀具、夹具'
|
||||||
|
|
||||||
def _cron_tool_datasync_all(self):
|
def _cron_tool_datasync_all(self):
|
||||||
try:
|
try:
|
||||||
self.env['stock.lot'].sudo().sync_enroll_tool_material_stock_all()
|
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()
|
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()
|
self.env['sf.functional.cutting.tool.entity'].sudo().esync_enroll_functional_tool_entity_all()
|
||||||
logging.info("功能刀具列表每日同步成功")
|
logging.info("已全部同步完成!!!")
|
||||||
self.env['sf.functional.tool.warning'].sudo().sync_enroll_functional_tool_warning_all()
|
# self.env['sf.functional.tool.warning'].sudo().sync_enroll_functional_tool_warning_all()
|
||||||
logging.info("功能刀具预警每日同步成功")
|
# logging.info("功能刀具预警每日同步成功")
|
||||||
self.env['stock.move.line'].sudo().sync_enroll_functional_tool_move_all()
|
# self.env['stock.move.line'].sudo().sync_enroll_functional_tool_move_all()
|
||||||
logging.info("功能刀具出入库记录每日同步成功")
|
# logging.info("功能刀具出入库记录每日同步成功")
|
||||||
self.env[
|
# self.env['sf.real.time.distribution.of.functional.tools'].sudo().sync_enroll_functional_tool_real_time_distribution_all()
|
||||||
'sf.real.time.distribution.of.functional.tools'].sudo().sync_enroll_functional_tool_real_time_distribution_all()
|
# logging.info("功能刀具安全库存每日同步成功")
|
||||||
logging.info("功能刀具安全库存每日同步成功")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info("捕获错误信息:%s" % e)
|
logging.info("捕获错误信息:%s" % e)
|
||||||
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
||||||
@@ -59,24 +62,25 @@ class StockLot(models.Model):
|
|||||||
_inherit = 'stock.lot'
|
_inherit = 'stock.lot'
|
||||||
_description = '刀具物料序列号注册'
|
_description = '刀具物料序列号注册'
|
||||||
|
|
||||||
def enroll_tool_material_stock(self):
|
# def enroll_tool_material_stock(self):
|
||||||
logging.info('调用刀具物料序列号注册接口: enroll_tool_material_stock()')
|
# logging.info('调用刀具物料序列号注册接口: enroll_tool_material_stock()')
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
# token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
|
# 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])])
|
# 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)
|
# self._get_sync_stock_lot(objs_all, str_url, token, headers)
|
||||||
|
|
||||||
def sync_enroll_tool_material_stock_all(self):
|
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()
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
|
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)
|
self._get_sync_stock_lot(objs_all, str_url, token, headers)
|
||||||
|
|
||||||
def _get_sync_stock_lot(self, 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)
|
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
if ret.get('code') == 200:
|
if ret.get('code') == 200:
|
||||||
return '刀具物料序列号注册成功'
|
logging.info("刀具物料序列号每日同步成功")
|
||||||
|
return '刀具(夹具)物料序列号注册成功'
|
||||||
else:
|
else:
|
||||||
logging.info("没有注册刀具物料序列号信息")
|
logging.info("没有刀具物料序列号信息")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info("捕获错误信息:%s" % e)
|
logging.info("刀具物料序列号同步失败:%s" % e)
|
||||||
|
|
||||||
|
|
||||||
class ToolMaterial(models.Model):
|
class ToolMaterial(models.Model):
|
||||||
@@ -108,18 +113,18 @@ class ToolMaterial(models.Model):
|
|||||||
|
|
||||||
crea_url = '/api/tool_material/create'
|
crea_url = '/api/tool_material/create'
|
||||||
|
|
||||||
def enroll_tool_material(self):
|
# def enroll_tool_material(self):
|
||||||
logging.info('调用刀具物料注册接口: enroll_tool_material()')
|
# logging.info('调用刀具物料注册接口: enroll_tool_material()')
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
# token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||||
objs_all = self.search([('id', '=', self.id)])
|
# objs_all = self.search([('id', '=', self.id)])
|
||||||
self._get_sync_tool_material_search(objs_all, str_url, token, headers)
|
# self._get_sync_tool_material_search(objs_all, str_url, token, headers)
|
||||||
|
|
||||||
def sync_enroll_tool_material_all(self):
|
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()
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
@@ -150,11 +155,20 @@ class ToolMaterial(models.Model):
|
|||||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
if ret.get('code') == 200:
|
if ret.get('code') == 200:
|
||||||
|
logging.info("刀具物料每日同步成功")
|
||||||
return '刀具物料注册成功'
|
return '刀具物料注册成功'
|
||||||
else:
|
else:
|
||||||
logging.info('没有注册刀具物料信息')
|
logging.info('没有注册刀具物料信息')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info("捕获错误信息:%s" % e)
|
logging.info("刀具物料同步失败:%s" % e)
|
||||||
|
|
||||||
|
# @api.model_create_multi
|
||||||
|
# def create(self, vals_list):
|
||||||
|
# records = super(ToolMaterial, self).create(vals_list)
|
||||||
|
# for record in records:
|
||||||
|
# if record:
|
||||||
|
# record.enroll_tool_material()
|
||||||
|
# return records
|
||||||
|
|
||||||
|
|
||||||
class FunctionalCuttingToolEntity(models.Model):
|
class FunctionalCuttingToolEntity(models.Model):
|
||||||
@@ -164,18 +178,18 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
crea_url = "/api/functional_tool_entity/create"
|
crea_url = "/api/functional_tool_entity/create"
|
||||||
|
|
||||||
# 注册同步功能刀具列表
|
# 注册同步功能刀具列表
|
||||||
def enroll_functional_tool_entity(self):
|
# def enroll_functional_tool_entity(self):
|
||||||
logging.info('调用功能刀具列表注册接口: enroll_functional_tool_entity()')
|
# logging.info('调用功能刀具列表注册接口: enroll_functional_tool_entity()')
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
# token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||||
objs_all = self.env['sf.functional.cutting.tool.entity'].search([('id', '=', self.id)])
|
# 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)
|
# self._get_sync_functional_cutting_tool_entity(objs_all, str_url, token, headers)
|
||||||
|
|
||||||
def esync_enroll_functional_tool_entity_all(self):
|
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()
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
@@ -202,6 +216,7 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
'coarse_middle_thin': item.coarse_middle_thin,
|
'coarse_middle_thin': item.coarse_middle_thin,
|
||||||
'new_former': item.new_former,
|
'new_former': item.new_former,
|
||||||
'tool_loading_length': item.tool_loading_length,
|
'tool_loading_length': item.tool_loading_length,
|
||||||
|
'handle_length': item.handle_length,
|
||||||
'functional_tool_length': item.functional_tool_length,
|
'functional_tool_length': item.functional_tool_length,
|
||||||
'effective_length': item.effective_length,
|
'effective_length': item.effective_length,
|
||||||
'max_lifetime_value': item.max_lifetime_value,
|
'max_lifetime_value': item.max_lifetime_value,
|
||||||
@@ -234,212 +249,257 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
if ret.get('code') == 200:
|
if ret.get('code') == 200:
|
||||||
|
logging.info("功能刀具列表每日同步成功")
|
||||||
return "功能刀具注册成功"
|
return "功能刀具注册成功"
|
||||||
else:
|
else:
|
||||||
logging.info('没有注册功能刀具信息')
|
logging.info('没有注册功能刀具信息')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info("捕获错误信息:%s" % e)
|
logging.info("功能刀具同步失败:%s" % e)
|
||||||
|
|
||||||
|
# @api.model_create_multi
|
||||||
|
# def create(self, vals_list):
|
||||||
|
# records = super(FunctionalCuttingToolEntity, self).create(vals_list)
|
||||||
|
# for record in records:
|
||||||
|
# if record:
|
||||||
|
# record.enroll_functional_tool_entity()
|
||||||
|
# return records
|
||||||
|
|
||||||
class FunctionalToolWarning(models.Model):
|
# def write(self, vals):
|
||||||
_inherit = 'sf.functional.tool.warning'
|
# res = super().write(vals)
|
||||||
_description = '功能刀具预警注册'
|
# if vals.get('current_location'):
|
||||||
|
# self.enroll_functional_tool_entity()
|
||||||
|
# return res
|
||||||
|
|
||||||
crea_url = "/api/functional_tool_warning/create"
|
#
|
||||||
|
# class FunctionalToolWarning(models.Model):
|
||||||
# 注册同步功能刀具预警
|
# _inherit = 'sf.functional.tool.warning'
|
||||||
def enroll_functional_tool_warning(self):
|
# _description = '功能刀具预警注册'
|
||||||
logging.info('调用功能刀具预警注册接口: enroll_functional_tool_warning()')
|
#
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
# crea_url = "/api/functional_tool_warning/create"
|
||||||
token = sf_sync_config['token']
|
#
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
# # 注册同步功能刀具预警
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
# def enroll_functional_tool_warning(self):
|
||||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
# logging.info('调用功能刀具预警注册接口: enroll_functional_tool_warning()')
|
||||||
objs_all = self.env['sf.functional.tool.warning'].search([('id', '=', self.id)])
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
# token = sf_sync_config['token']
|
||||||
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
def sync_enroll_functional_tool_warning_all(self):
|
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
logging.info('调用功能刀具预警注册接口: sync_enroll_functional_tool_warning_all()')
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
# objs_all = self.env['sf.functional.tool.warning'].search([('id', '=', self.id)])
|
||||||
token = sf_sync_config['token']
|
# self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
#
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
# def sync_enroll_functional_tool_warning_all(self):
|
||||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
# logging.info('调用功能刀具预警注册接口: sync_enroll_functional_tool_warning_all()')
|
||||||
objs_all = self.env['sf.functional.tool.warning'].search([])
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
# token = sf_sync_config['token']
|
||||||
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
def get_sync_functional_tool_warning(self, objs_all, str_url, token, headers):
|
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
tool_warning_list = []
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||||
try:
|
# objs_all = self.env['sf.functional.tool.warning'].search([])
|
||||||
if objs_all:
|
# self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
||||||
for item in objs_all:
|
#
|
||||||
val = {
|
# def get_sync_functional_tool_warning(self, objs_all, str_url, token, headers):
|
||||||
'id': item.id,
|
# tool_warning_list = []
|
||||||
'name': item.name,
|
# try:
|
||||||
'code': item.code,
|
# if objs_all:
|
||||||
'rfid': item.rfid,
|
# for item in objs_all:
|
||||||
'tool_groups_name': item.tool_groups_id.name,
|
# val = {
|
||||||
'production_line': item.production_line_id.name,
|
# 'id': item.id,
|
||||||
'machine_tool_id': item.maintenance_equipment_id.code,
|
# 'name': item.name,
|
||||||
'machine_tool_code': item.machine_tool_code,
|
# 'code': item.code,
|
||||||
'cutter_spacing_code': item.cutter_spacing_code_id.code,
|
# 'rfid': item.rfid,
|
||||||
'functional_tool_name': item.name,
|
# 'tool_groups_name': item.tool_groups_id.name,
|
||||||
'barcode': item.barcode_id.name,
|
# 'production_line': item.production_line_id.name,
|
||||||
'mrs_cutting_tool_type_code': item.mrs_cutting_tool_type_id.code,
|
# 'machine_tool_id': item.maintenance_equipment_id.code,
|
||||||
'diameter': item.diameter,
|
# 'machine_tool_code': item.machine_tool_code,
|
||||||
'knife_tip_r_angle': item.knife_tip_r_angle,
|
# 'cutter_spacing_code': item.cutter_spacing_code_id.code,
|
||||||
'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
# 'functional_tool_name': item.name,
|
||||||
'on_board_time': item.on_board_time.strftime('%Y-%m-%d %H:%M:%S'),
|
# 'barcode': item.barcode_id.name,
|
||||||
'max_lifetime_value': item.max_lifetime_value,
|
# 'mrs_cutting_tool_type_code': item.mrs_cutting_tool_type_id.code,
|
||||||
'alarm_value': item.alarm_value,
|
# 'diameter': item.diameter,
|
||||||
'used_value': item.used_value,
|
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||||
'functional_tool_status': item.functional_tool_status,
|
# 'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
'alarm_time': item.alarm_time.strftime('%Y-%m-%d %H:%M:%S'),
|
# 'on_board_time': item.on_board_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
'dispose_user': item.dispose_user,
|
# 'max_lifetime_value': item.max_lifetime_value,
|
||||||
'dispose_time': item.dispose_time,
|
# 'alarm_value': item.alarm_value,
|
||||||
'dispose_func': item.dispose_func,
|
# 'used_value': item.used_value,
|
||||||
}
|
# 'functional_tool_status': item.functional_tool_status,
|
||||||
tool_warning_list.append(val)
|
# 'alarm_time': item.alarm_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
kw = json.dumps(tool_warning_list, ensure_ascii=False)
|
# 'dispose_user': item.dispose_user,
|
||||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
# 'dispose_time': item.dispose_time,
|
||||||
ret = r.json()
|
# 'dispose_func': item.dispose_func,
|
||||||
if ret.get('code') == 200:
|
# }
|
||||||
return "功能刀具预警注册成功"
|
# tool_warning_list.append(val)
|
||||||
else:
|
# kw = json.dumps(tool_warning_list, ensure_ascii=False)
|
||||||
logging.info('没有注册功能刀具预警信息')
|
# r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
except Exception as e:
|
# ret = r.json()
|
||||||
logging.info("捕获错误信息:%s" % e)
|
# if ret.get('code') == 200:
|
||||||
|
# return "功能刀具预警注册成功"
|
||||||
|
# else:
|
||||||
class StockMoveLine(models.Model):
|
# logging.info('没有注册功能刀具预警信息')
|
||||||
_inherit = 'stock.move.line'
|
# except Exception as e:
|
||||||
_description = '功能刀具出入库记录注册'
|
# logging.info("捕获错误信息:%s" % e)
|
||||||
|
#
|
||||||
crea_url = "/api/functional_tool_move/create"
|
# @api.model_create_multi
|
||||||
|
# def create(self, vals_list):
|
||||||
# 注册同步功能刀具出入库记录
|
# records = super(FunctionalToolWarning, self).create(vals_list)
|
||||||
def enroll_functional_tool_move(self):
|
# for record in records:
|
||||||
logging.info('调用功能刀具出入库记录注册接口: enroll_functional_tool_move()')
|
# if record:
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
# record.enroll_functional_tool_warning()
|
||||||
token = sf_sync_config['token']
|
# return records
|
||||||
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
|
# class StockMoveLine(models.Model):
|
||||||
objs_all = self.env['stock.move.line'].search([('id', '=', self.id), ('functional_tool_name_id', '!=', False)])
|
# _inherit = 'stock.move.line'
|
||||||
self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
# _description = '功能刀具出入库记录注册'
|
||||||
|
#
|
||||||
def sync_enroll_functional_tool_move_all(self):
|
# crea_url = "/api/functional_tool_move/create"
|
||||||
logging.info('调用功能刀具出入库记录注册接口: sync_enroll_functional_tool_move_all()')
|
#
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
# # 注册同步功能刀具出入库记录
|
||||||
token = sf_sync_config['token']
|
# def enroll_functional_tool_move(self):
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
# logging.info('调用功能刀具出入库记录注册接口: enroll_functional_tool_move()')
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
# token = sf_sync_config['token']
|
||||||
objs_all = self.env['stock.move.line'].search([('functional_tool_name_id', '!=', False)])
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||||
def get_sync_stock_move_line(self, objs_all, str_url, token, headers):
|
# objs_all = self.env['stock.move.line'].search([('id', '=', self.id), ('functional_tool_name_id', '!=', False)])
|
||||||
tool_stock_list = []
|
# self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
||||||
try:
|
#
|
||||||
if objs_all:
|
# def sync_enroll_functional_tool_move_all(self):
|
||||||
for item in objs_all:
|
# logging.info('调用功能刀具出入库记录注册接口: sync_enroll_functional_tool_move_all()')
|
||||||
val = {
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
'id': item.id,
|
# token = sf_sync_config['token']
|
||||||
'name': item.functional_tool_name,
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
'code': item.code,
|
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
'rfid': item.rfid,
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||||
'tool_groups_name': item.tool_groups_id.name,
|
# objs_all = self.env['stock.move.line'].search([('functional_tool_name_id', '!=', False)])
|
||||||
'reference': item.reference,
|
# self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
||||||
'barcode': item.lot_id.name,
|
#
|
||||||
'functional_tool_type_code': item.functional_tool_type_id.code,
|
# def get_sync_stock_move_line(self, objs_all, str_url, token, headers):
|
||||||
'diameter': item.diameter,
|
# tool_stock_list = []
|
||||||
'knife_tip_r_angle': item.knife_tip_r_angle,
|
# try:
|
||||||
'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
# if objs_all:
|
||||||
'location_id': item.location_id.name,
|
# for item in objs_all:
|
||||||
'location_dest_name': item.location_dest_id.name,
|
# val = {
|
||||||
'date': item.date.strftime('%Y-%m-%d %H:%M:%S'),
|
# 'id': item.id,
|
||||||
'qty_done': item.qty_done,
|
# 'name': item.functional_tool_name,
|
||||||
}
|
# 'code': item.code,
|
||||||
tool_stock_list.append(val)
|
# 'rfid': item.rfid,
|
||||||
kw = json.dumps(tool_stock_list, ensure_ascii=False)
|
# 'tool_groups_name': item.tool_groups_id.name,
|
||||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
# 'reference': item.reference,
|
||||||
ret = r.json()
|
# 'barcode': item.lot_id.name,
|
||||||
if ret.get('code') == 200:
|
# 'functional_tool_type_code': item.functional_tool_type_id.code,
|
||||||
return "功能刀具出入库记录注册成功"
|
# 'diameter': item.diameter,
|
||||||
else:
|
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||||
logging.info('没有注册功能刀具出入库记录信息')
|
# 'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
except Exception as e:
|
# 'location_id': item.location_id.name,
|
||||||
logging.info("捕获错误信息:%s" % e)
|
# 'location_dest_name': item.location_dest_id.name,
|
||||||
|
# 'date': item.date.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
|
# 'qty_done': item.qty_done,
|
||||||
class RealTimeDistributionFunctionalTools(models.Model):
|
# }
|
||||||
_inherit = 'sf.real.time.distribution.of.functional.tools'
|
# tool_stock_list.append(val)
|
||||||
_description = '功能刀具安全库存注册'
|
# kw = json.dumps(tool_stock_list, ensure_ascii=False)
|
||||||
|
# r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
crea_url = "/api/functional_tool_distribution/create"
|
# ret = r.json()
|
||||||
|
# if ret.get('code') == 200:
|
||||||
# 注册同步功能刀具预警
|
# return "功能刀具出入库记录注册成功"
|
||||||
def enroll_functional_tool_real_time_distribution(self):
|
# else:
|
||||||
logging.info('调用功能刀具安全库存注册接口: enroll_functional_tool_real_time_distribution()')
|
# logging.info('没有注册功能刀具出入库记录信息')
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
# except Exception as e:
|
||||||
token = sf_sync_config['token']
|
# logging.info("捕获错误信息:%s" % e)
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
#
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
# @api.model_create_multi
|
||||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
# def create(self, vals_list):
|
||||||
objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([('id', '=', self.id)])
|
# records = super(StockMoveLine, self).create(vals_list)
|
||||||
self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
# for record in records:
|
||||||
|
# if record.functional_tool_name_id:
|
||||||
def sync_enroll_functional_tool_real_time_distribution_all(self):
|
# record.enroll_functional_tool_move()
|
||||||
logging.info('调用功能刀具安全库存注册接口: sync_enroll_functional_tool_real_time_distribution_all()')
|
# return records
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
#
|
||||||
token = sf_sync_config['token']
|
#
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
# class RealTimeDistributionFunctionalTools(models.Model):
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
# _inherit = 'sf.real.time.distribution.of.functional.tools'
|
||||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
# _description = '功能刀具安全库存注册'
|
||||||
objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([])
|
#
|
||||||
self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
# crea_url = "/api/functional_tool_distribution/create"
|
||||||
|
#
|
||||||
def get_sync_real_time_distribution_functional_tools(self, objs_all, str_url, token, headers):
|
# # 注册同步功能刀具预警
|
||||||
tool_distribution_list = []
|
# def enroll_functional_tool_real_time_distribution(self):
|
||||||
try:
|
# logging.info('调用功能刀具安全库存注册接口: enroll_functional_tool_real_time_distribution()')
|
||||||
if objs_all:
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
for item in objs_all:
|
# token = sf_sync_config['token']
|
||||||
functional_tool_codes = []
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
for obj in item.sf_functional_tool_entity_ids:
|
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
functional_tool_codes.append(obj.code)
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||||
val = {
|
# objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([('id', '=', self.id)])
|
||||||
'id': item.id,
|
# self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
||||||
'name': item.name,
|
#
|
||||||
'tool_groups_name': item.tool_groups_id.name,
|
# def sync_enroll_functional_tool_real_time_distribution_all(self):
|
||||||
'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
|
# logging.info('调用功能刀具安全库存注册接口: sync_enroll_functional_tool_real_time_distribution_all()')
|
||||||
'diameter': item.diameter,
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
'knife_tip_r_angle': item.knife_tip_r_angle,
|
# token = sf_sync_config['token']
|
||||||
'tool_stock_num': item.tool_stock_num,
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
'side_shelf_num': item.side_shelf_num,
|
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
'on_tool_stock_num': item.on_tool_stock_num,
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||||
'tool_stock_total': item.tool_stock_total,
|
# objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([])
|
||||||
'min_stock_num': item.min_stock_num,
|
# self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
||||||
'max_stock_num': item.max_stock_num,
|
#
|
||||||
'batch_replenishment_num': item.batch_replenishment_num,
|
# def get_sync_real_time_distribution_functional_tools(self, objs_all, str_url, token, headers):
|
||||||
'unit': item.unit,
|
# tool_distribution_list = []
|
||||||
'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
|
# try:
|
||||||
'functional_tool_codes': str(functional_tool_codes),
|
# if objs_all:
|
||||||
'coarse_middle_thin': item.coarse_middle_thin,
|
# for item in objs_all:
|
||||||
'whether_standard_knife': item.whether_standard_knife,
|
# functional_tool_codes = []
|
||||||
'suitable_machining_method_names': get_suitable_machining_method_names(item),
|
# for obj in item.sf_functional_tool_entity_ids:
|
||||||
'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name,
|
# functional_tool_codes.append(obj.code)
|
||||||
'handle_type_name': item.handle_type_id.name,
|
# val = {
|
||||||
'cutting_direction_names': get_cutting_direction_names(item),
|
# 'id': item.id,
|
||||||
'suitable_coolant_names': get_suitable_coolant_names(item),
|
# 'name': item.name,
|
||||||
'active': item.active
|
# 'tool_groups_name': item.tool_groups_id.name,
|
||||||
}
|
# 'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
|
||||||
tool_distribution_list.append(val)
|
# 'diameter': item.diameter,
|
||||||
kw = json.dumps(tool_distribution_list, ensure_ascii=False)
|
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
# 'tool_stock_num': item.tool_stock_num,
|
||||||
ret = r.json()
|
# 'side_shelf_num': item.side_shelf_num,
|
||||||
if ret.get('code') == 200:
|
# 'on_tool_stock_num': item.on_tool_stock_num,
|
||||||
return "功能刀具出入库记录注册成功"
|
# 'tool_stock_total': item.tool_stock_total,
|
||||||
else:
|
# 'min_stock_num': item.min_stock_num,
|
||||||
logging.info('没有注册功能刀具出入库记录信息')
|
# 'max_stock_num': item.max_stock_num,
|
||||||
except Exception as e:
|
# 'batch_replenishment_num': item.batch_replenishment_num,
|
||||||
logging.info("捕获错误信息:%s" % e)
|
# 'unit': item.unit,
|
||||||
|
# 'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
|
||||||
|
# 'functional_tool_codes': str(functional_tool_codes),
|
||||||
|
# 'coarse_middle_thin': item.coarse_middle_thin,
|
||||||
|
# 'whether_standard_knife': item.whether_standard_knife,
|
||||||
|
# 'suitable_machining_method_names': get_suitable_machining_method_names(item),
|
||||||
|
# 'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name,
|
||||||
|
# 'handle_type_name': item.handle_type_id.name,
|
||||||
|
# 'cutting_direction_names': get_cutting_direction_names(item),
|
||||||
|
# 'suitable_coolant_names': get_suitable_coolant_names(item),
|
||||||
|
# 'active': item.active
|
||||||
|
# }
|
||||||
|
# tool_distribution_list.append(val)
|
||||||
|
# kw = json.dumps(tool_distribution_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:
|
||||||
|
# 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,12 +61,6 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
|
|
||||||
def write_maintenance_equipment_tool(self, datas):
|
def write_maintenance_equipment_tool(self, datas):
|
||||||
if datas:
|
if datas:
|
||||||
# 清除设备机床刀位的刀具信息
|
|
||||||
for obj in self.product_template_ids:
|
|
||||||
obj.write({
|
|
||||||
'functional_tool_name_id': False,
|
|
||||||
'tool_install_time': None
|
|
||||||
})
|
|
||||||
for data in datas:
|
for data in datas:
|
||||||
maintenance_equipment_id = self.search([('name', '=', data['DeviceId'])])
|
maintenance_equipment_id = self.search([('name', '=', data['DeviceId'])])
|
||||||
if maintenance_equipment_id:
|
if maintenance_equipment_id:
|
||||||
@@ -134,9 +128,12 @@ class StockLot(models.Model):
|
|||||||
record.tool_material_status = '报废'
|
record.tool_material_status = '报废'
|
||||||
else:
|
else:
|
||||||
record.tool_material_status = '未入库'
|
record.tool_material_status = '未入库'
|
||||||
if record.fixture_material_search_id:
|
# if record.tool_material_search_id:
|
||||||
# 注册夹具物料状态到cloud平台
|
# # 注册刀具物料状态到cloud平台
|
||||||
record.enroll_fixture_material_stock()
|
# record.enroll_tool_material_stock()
|
||||||
|
# elif record.fixture_material_search_id:
|
||||||
|
# # 注册夹具物料状态到cloud平台
|
||||||
|
# record.enroll_fixture_material_stock()
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ class ToolMaterial(models.Model):
|
|||||||
record.have_been_used_num = have_been_used_num
|
record.have_been_used_num = have_been_used_num
|
||||||
record.scrap_num = scrap_num
|
record.scrap_num = scrap_num
|
||||||
record.number = usable_num + have_been_used_num + scrap_num
|
record.number = usable_num + have_been_used_num + scrap_num
|
||||||
|
# 更新数据到cloud的动态数据
|
||||||
|
# record.enroll_tool_material()
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _read_group_cutting_tool_material_id(self, categories, domain, order):
|
def _read_group_cutting_tool_material_id(self, categories, domain, order):
|
||||||
|
|||||||
Reference in New Issue
Block a user