Compare commits
1 Commits
feature/优化
...
release_1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
609e65e36f |
@@ -521,9 +521,4 @@ div:has(.o_required_modifier) > label::before {
|
||||
.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;
|
||||
}
|
||||
@@ -67,10 +67,9 @@ class JdEclp(models.Model):
|
||||
"""
|
||||
判断是否为出库单
|
||||
"""
|
||||
for record in self:
|
||||
if record.name:
|
||||
is_check_out = record.name.split('/')
|
||||
record.check_out = is_check_out[1]
|
||||
if self.name:
|
||||
is_check_out = self.name.split('/')
|
||||
self.check_out = is_check_out[1]
|
||||
|
||||
@api.depends('carrier_tracking_ref')
|
||||
def query_bill_pdf(self):
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<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"
|
||||
|
||||
@@ -215,7 +215,7 @@ class Manufacturing_Connect(http.Controller):
|
||||
if workorder.state != 'progress':
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单未开始'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
workorder.write({'date_finished': datetime.now()})
|
||||
workorder.button_finish()
|
||||
# workorder.process_state = '待解除装夹'
|
||||
# workorder.sudo().production_id.process_state = '待解除装夹'
|
||||
|
||||
|
||||
@@ -77,7 +77,6 @@ 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',
|
||||
@@ -155,30 +154,8 @@ 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, scrap_production):
|
||||
def fetchCNC(self, production_names):
|
||||
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])])
|
||||
@@ -194,8 +171,6 @@ 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,
|
||||
@@ -293,7 +268,7 @@ class MrpProduction(models.Model):
|
||||
# 则根据设备找到工作中心;否则采用前面描述的工作中心分配机制;
|
||||
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
|
||||
|
||||
def _create_workorder3(self, is_fetchcnc=False, scrap_production=False):
|
||||
def _create_workorder3(self):
|
||||
# 根据product_id对self进行分组
|
||||
grouped_product_ids = {k: list(g) for k, g in groupby(self, key=lambda x: x.product_id.id)}
|
||||
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
|
||||
@@ -336,16 +311,11 @@ 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 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)
|
||||
if not production_programming.programming_no:
|
||||
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]))
|
||||
else:
|
||||
production.write({'programming_no': production_programming.programming_no,
|
||||
'programming_state': '编程中'})
|
||||
|
||||
'programming_state': '已编程' if production_programming.programming_state == '已编程' else '编程中'})
|
||||
# # 根据加工面板的面数及对应的工序模板生成工单
|
||||
i = 0
|
||||
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
||||
@@ -557,8 +527,8 @@ class MrpProduction(models.Model):
|
||||
# work.button_finish()
|
||||
|
||||
# 创建工单并进行排序
|
||||
def _create_workorder(self, is_fetchcnc=False, scrap_production=False):
|
||||
self._create_workorder3(is_fetchcnc=is_fetchcnc, scrap_production=scrap_production)
|
||||
def _create_workorder(self):
|
||||
self._create_workorder3()
|
||||
self._reset_work_order_sequence()
|
||||
return True
|
||||
|
||||
|
||||
@@ -199,12 +199,7 @@ 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=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('详细原因')
|
||||
is_remanufacture = fields.Boolean(string='是否重新生成制造订单', default=True)
|
||||
|
||||
@api.onchange('rfid_code')
|
||||
def _onchange(self):
|
||||
@@ -677,14 +672,14 @@ class ResMrpWorkOrder(models.Model):
|
||||
"""
|
||||
重新生成制造订单或者重新生成工单
|
||||
"""
|
||||
if self.test_results in ['返工', '报废']:
|
||||
if self.test_results == '报废':
|
||||
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_finished_values())
|
||||
productions._create_workorder(is_fetchcnc=self.is_fetchcnc, scrap_production=self.production_id)
|
||||
productions._create_workorder()
|
||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||
(
|
||||
p.move_dest_ids.procure_method != 'make_to_order' and
|
||||
@@ -766,7 +761,6 @@ class ResMrpWorkOrder(models.Model):
|
||||
|
||||
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,
|
||||
@@ -778,13 +772,13 @@ class ResMrpWorkOrder(models.Model):
|
||||
'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 = '合格'
|
||||
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, '', {
|
||||
@@ -809,28 +803,29 @@ class ResMrpWorkOrder(models.Model):
|
||||
}]
|
||||
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'
|
||||
@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):
|
||||
@@ -987,7 +982,6 @@ 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)
|
||||
@@ -996,15 +990,8 @@ 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()
|
||||
record.recreateManufacturingOrWorkerOrder()
|
||||
is_production_id = True
|
||||
for workorder in record.production_id.workorder_ids:
|
||||
if workorder.state != 'done':
|
||||
@@ -1145,14 +1132,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)
|
||||
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
||||
open(full_path, 'rb').read())
|
||||
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())
|
||||
else:
|
||||
if f in program_path:
|
||||
# if cnc_processing.program_name == f.split('.')[0]:
|
||||
|
||||
@@ -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,7 +530,6 @@ 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):
|
||||
@@ -627,7 +626,6 @@ 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(is_fetchcnc=False, scrap_production=False)
|
||||
productions._create_workorder()
|
||||
|
||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||
(
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
|
||||
@@ -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" string="成品的零件图号"/>
|
||||
<field name="part_number"/>
|
||||
<field name="part_drawing"/>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
||||
<field name="functional_fixture_type_id"
|
||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
||||
<field name="rfid_code" cache="True"
|
||||
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
|
||||
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||
</group>
|
||||
@@ -478,11 +478,6 @@
|
||||
<group>
|
||||
<field name="test_results" attrs='{"invisible":[("results","!=",False)]}'/>
|
||||
<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"/>
|
||||
@@ -578,7 +573,7 @@
|
||||
<label for="material_height" string="高"/>
|
||||
<field name="material_height" class="o_address_zip"/>
|
||||
</div>
|
||||
<field name="part_number" string="成品的零件图号"/>
|
||||
<field name="part_number"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -24,22 +24,12 @@ 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)
|
||||
@@ -47,13 +37,6 @@ 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(
|
||||
@@ -81,17 +64,15 @@ 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):
|
||||
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})
|
||||
logging.info('cnc_processing_arr:%s' % cnc_processing_arr)
|
||||
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(
|
||||
cnc_program.workorder_ids.filtered(lambda b1: b1.routing_type == '装夹预调').write(
|
||||
{'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_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
|
||||
if not cnc_program and cnc_processing_arr:
|
||||
cnc_program = cnc_production
|
||||
|
||||
@@ -46,8 +46,6 @@ 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
|
||||
|
||||
@@ -8,35 +8,6 @@ from odoo.http import request
|
||||
|
||||
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,
|
||||
cors="*")
|
||||
def get_functional_tool_inventory_Info(self, **kw):
|
||||
@@ -126,4 +97,4 @@ class Manufacturing_Connect(http.Controller):
|
||||
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)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@@ -311,54 +311,41 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
'applicant': 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工单程序用刀计划
|
||||
"""
|
||||
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()
|
||||
|
||||
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)
|
||||
|
||||
|
||||
class FunctionalToolAssembly(models.Model):
|
||||
@@ -556,8 +543,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
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,
|
||||
digits=(10, 3))
|
||||
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)
|
||||
@@ -571,7 +557,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
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, digits=(10, 3))
|
||||
after_assembly_handle_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)
|
||||
@@ -865,10 +851,6 @@ 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', '=', '刀具房')])
|
||||
# =================刀柄是否[报废]拆解=======
|
||||
|
||||
@@ -162,7 +162,13 @@ class ToolMaterial(models.Model):
|
||||
except Exception as 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):
|
||||
@@ -250,208 +256,250 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
except Exception as 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):
|
||||
_inherit = 'sf.functional.tool.warning'
|
||||
_description = '功能刀具预警注册'
|
||||
|
||||
crea_url = "/api/functional_tool_warning/create"
|
||||
|
||||
# 注册同步功能刀具预警
|
||||
def enroll_functional_tool_warning(self):
|
||||
logging.info('调用功能刀具预警注册接口: enroll_functional_tool_warning()')
|
||||
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.tool.warning'].search([('id', '=', self.id)])
|
||||
self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
||||
|
||||
def sync_enroll_functional_tool_warning_all(self):
|
||||
logging.info('调用功能刀具预警注册接口: sync_enroll_functional_tool_warning_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.env['sf.functional.tool.warning'].search([])
|
||||
self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
||||
|
||||
def get_sync_functional_tool_warning(self, objs_all, str_url, token, headers):
|
||||
tool_warning_list = []
|
||||
try:
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
val = {
|
||||
'id': item.id,
|
||||
'name': item.name,
|
||||
'code': item.code,
|
||||
'rfid': item.rfid,
|
||||
'tool_groups_name': item.tool_groups_id.name,
|
||||
'production_line': item.production_line_id.name,
|
||||
'machine_tool_id': item.maintenance_equipment_id.code,
|
||||
'machine_tool_code': item.machine_tool_code,
|
||||
'cutter_spacing_code': item.cutter_spacing_code_id.code,
|
||||
'functional_tool_name': item.name,
|
||||
'barcode': item.barcode_id.name,
|
||||
'mrs_cutting_tool_type_code': item.mrs_cutting_tool_type_id.code,
|
||||
'diameter': item.diameter,
|
||||
'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'on_board_time': item.on_board_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'max_lifetime_value': item.max_lifetime_value,
|
||||
'alarm_value': item.alarm_value,
|
||||
'used_value': item.used_value,
|
||||
'functional_tool_status': item.functional_tool_status,
|
||||
'alarm_time': item.alarm_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'dispose_user': item.dispose_user,
|
||||
'dispose_time': item.dispose_time,
|
||||
'dispose_func': item.dispose_func,
|
||||
}
|
||||
tool_warning_list.append(val)
|
||||
kw = json.dumps(tool_warning_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)
|
||||
|
||||
|
||||
class StockMoveLine(models.Model):
|
||||
_inherit = 'stock.move.line'
|
||||
_description = '功能刀具出入库记录注册'
|
||||
|
||||
crea_url = "/api/functional_tool_move/create"
|
||||
|
||||
# 注册同步功能刀具出入库记录
|
||||
def enroll_functional_tool_move(self):
|
||||
logging.info('调用功能刀具出入库记录注册接口: enroll_functional_tool_move()')
|
||||
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['stock.move.line'].search([('id', '=', self.id), ('functional_tool_name_id', '!=', False)])
|
||||
self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
||||
|
||||
def sync_enroll_functional_tool_move_all(self):
|
||||
logging.info('调用功能刀具出入库记录注册接口: sync_enroll_functional_tool_move_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.env['stock.move.line'].search([('functional_tool_name_id', '!=', False)])
|
||||
self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
||||
|
||||
def get_sync_stock_move_line(self, objs_all, str_url, token, headers):
|
||||
tool_stock_list = []
|
||||
try:
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
val = {
|
||||
'id': item.id,
|
||||
'name': item.functional_tool_name,
|
||||
'code': item.code,
|
||||
'rfid': item.rfid,
|
||||
'tool_groups_name': item.tool_groups_id.name,
|
||||
'reference': item.reference,
|
||||
'barcode': item.lot_id.name,
|
||||
'functional_tool_type_code': item.functional_tool_type_id.code,
|
||||
'diameter': item.diameter,
|
||||
'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'location_id': item.location_id.name,
|
||||
'location_dest_name': item.location_dest_id.name,
|
||||
'date': item.date.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'qty_done': item.qty_done,
|
||||
}
|
||||
tool_stock_list.append(val)
|
||||
kw = json.dumps(tool_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:
|
||||
logging.info('没有注册功能刀具出入库记录信息')
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
|
||||
|
||||
class RealTimeDistributionFunctionalTools(models.Model):
|
||||
_inherit = 'sf.real.time.distribution.of.functional.tools'
|
||||
_description = '功能刀具安全库存注册'
|
||||
|
||||
crea_url = "/api/functional_tool_distribution/create"
|
||||
|
||||
# 注册同步功能刀具预警
|
||||
def enroll_functional_tool_real_time_distribution(self):
|
||||
logging.info('调用功能刀具安全库存注册接口: enroll_functional_tool_real_time_distribution()')
|
||||
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.real.time.distribution.of.functional.tools'].search([('id', '=', self.id)])
|
||||
self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
||||
|
||||
def sync_enroll_functional_tool_real_time_distribution_all(self):
|
||||
logging.info('调用功能刀具安全库存注册接口: sync_enroll_functional_tool_real_time_distribution_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.env['sf.real.time.distribution.of.functional.tools'].search([])
|
||||
self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
||||
|
||||
def get_sync_real_time_distribution_functional_tools(self, objs_all, str_url, token, headers):
|
||||
tool_distribution_list = []
|
||||
try:
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
functional_tool_codes = []
|
||||
for obj in item.sf_functional_tool_entity_ids:
|
||||
functional_tool_codes.append(obj.code)
|
||||
val = {
|
||||
'id': item.id,
|
||||
'name': item.name,
|
||||
'tool_groups_name': item.tool_groups_id.name,
|
||||
'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
|
||||
'diameter': item.diameter,
|
||||
'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
'tool_stock_num': item.tool_stock_num,
|
||||
'side_shelf_num': item.side_shelf_num,
|
||||
'on_tool_stock_num': item.on_tool_stock_num,
|
||||
'tool_stock_total': item.tool_stock_total,
|
||||
'min_stock_num': item.min_stock_num,
|
||||
'max_stock_num': item.max_stock_num,
|
||||
'batch_replenishment_num': item.batch_replenishment_num,
|
||||
'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)
|
||||
#
|
||||
# class FunctionalToolWarning(models.Model):
|
||||
# _inherit = 'sf.functional.tool.warning'
|
||||
# _description = '功能刀具预警注册'
|
||||
#
|
||||
# crea_url = "/api/functional_tool_warning/create"
|
||||
#
|
||||
# # 注册同步功能刀具预警
|
||||
# def enroll_functional_tool_warning(self):
|
||||
# logging.info('调用功能刀具预警注册接口: enroll_functional_tool_warning()')
|
||||
# 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.tool.warning'].search([('id', '=', self.id)])
|
||||
# self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def sync_enroll_functional_tool_warning_all(self):
|
||||
# logging.info('调用功能刀具预警注册接口: sync_enroll_functional_tool_warning_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.env['sf.functional.tool.warning'].search([])
|
||||
# self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def get_sync_functional_tool_warning(self, objs_all, str_url, token, headers):
|
||||
# tool_warning_list = []
|
||||
# try:
|
||||
# if objs_all:
|
||||
# for item in objs_all:
|
||||
# val = {
|
||||
# 'id': item.id,
|
||||
# 'name': item.name,
|
||||
# 'code': item.code,
|
||||
# 'rfid': item.rfid,
|
||||
# 'tool_groups_name': item.tool_groups_id.name,
|
||||
# 'production_line': item.production_line_id.name,
|
||||
# 'machine_tool_id': item.maintenance_equipment_id.code,
|
||||
# 'machine_tool_code': item.machine_tool_code,
|
||||
# 'cutter_spacing_code': item.cutter_spacing_code_id.code,
|
||||
# 'functional_tool_name': item.name,
|
||||
# 'barcode': item.barcode_id.name,
|
||||
# 'mrs_cutting_tool_type_code': item.mrs_cutting_tool_type_id.code,
|
||||
# 'diameter': item.diameter,
|
||||
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
# 'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
# 'on_board_time': item.on_board_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
# 'max_lifetime_value': item.max_lifetime_value,
|
||||
# 'alarm_value': item.alarm_value,
|
||||
# 'used_value': item.used_value,
|
||||
# 'functional_tool_status': item.functional_tool_status,
|
||||
# 'alarm_time': item.alarm_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
# 'dispose_user': item.dispose_user,
|
||||
# 'dispose_time': item.dispose_time,
|
||||
# 'dispose_func': item.dispose_func,
|
||||
# }
|
||||
# tool_warning_list.append(val)
|
||||
# kw = json.dumps(tool_warning_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(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'
|
||||
# _description = '功能刀具出入库记录注册'
|
||||
#
|
||||
# crea_url = "/api/functional_tool_move/create"
|
||||
#
|
||||
# # 注册同步功能刀具出入库记录
|
||||
# def enroll_functional_tool_move(self):
|
||||
# logging.info('调用功能刀具出入库记录注册接口: enroll_functional_tool_move()')
|
||||
# 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['stock.move.line'].search([('id', '=', self.id), ('functional_tool_name_id', '!=', False)])
|
||||
# self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def sync_enroll_functional_tool_move_all(self):
|
||||
# logging.info('调用功能刀具出入库记录注册接口: sync_enroll_functional_tool_move_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.env['stock.move.line'].search([('functional_tool_name_id', '!=', False)])
|
||||
# self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def get_sync_stock_move_line(self, objs_all, str_url, token, headers):
|
||||
# tool_stock_list = []
|
||||
# try:
|
||||
# if objs_all:
|
||||
# for item in objs_all:
|
||||
# val = {
|
||||
# 'id': item.id,
|
||||
# 'name': item.functional_tool_name,
|
||||
# 'code': item.code,
|
||||
# 'rfid': item.rfid,
|
||||
# 'tool_groups_name': item.tool_groups_id.name,
|
||||
# 'reference': item.reference,
|
||||
# 'barcode': item.lot_id.name,
|
||||
# 'functional_tool_type_code': item.functional_tool_type_id.code,
|
||||
# 'diameter': item.diameter,
|
||||
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
# 'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
# 'location_id': item.location_id.name,
|
||||
# 'location_dest_name': item.location_dest_id.name,
|
||||
# 'date': item.date.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
# 'qty_done': item.qty_done,
|
||||
# }
|
||||
# tool_stock_list.append(val)
|
||||
# kw = json.dumps(tool_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:
|
||||
# logging.info('没有注册功能刀具出入库记录信息')
|
||||
# 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'
|
||||
# _description = '功能刀具安全库存注册'
|
||||
#
|
||||
# crea_url = "/api/functional_tool_distribution/create"
|
||||
#
|
||||
# # 注册同步功能刀具预警
|
||||
# def enroll_functional_tool_real_time_distribution(self):
|
||||
# logging.info('调用功能刀具安全库存注册接口: enroll_functional_tool_real_time_distribution()')
|
||||
# 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.real.time.distribution.of.functional.tools'].search([('id', '=', self.id)])
|
||||
# self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def sync_enroll_functional_tool_real_time_distribution_all(self):
|
||||
# logging.info('调用功能刀具安全库存注册接口: sync_enroll_functional_tool_real_time_distribution_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.env['sf.real.time.distribution.of.functional.tools'].search([])
|
||||
# self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def get_sync_real_time_distribution_functional_tools(self, objs_all, str_url, token, headers):
|
||||
# tool_distribution_list = []
|
||||
# try:
|
||||
# if objs_all:
|
||||
# for item in objs_all:
|
||||
# functional_tool_codes = []
|
||||
# for obj in item.sf_functional_tool_entity_ids:
|
||||
# functional_tool_codes.append(obj.code)
|
||||
# val = {
|
||||
# 'id': item.id,
|
||||
# 'name': item.name,
|
||||
# 'tool_groups_name': item.tool_groups_id.name,
|
||||
# 'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
|
||||
# 'diameter': item.diameter,
|
||||
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
# 'tool_stock_num': item.tool_stock_num,
|
||||
# 'side_shelf_num': item.side_shelf_num,
|
||||
# 'on_tool_stock_num': item.on_tool_stock_num,
|
||||
# 'tool_stock_total': item.tool_stock_total,
|
||||
# 'min_stock_num': item.min_stock_num,
|
||||
# 'max_stock_num': item.max_stock_num,
|
||||
# 'batch_replenishment_num': item.batch_replenishment_num,
|
||||
# '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):
|
||||
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:
|
||||
@@ -134,9 +128,12 @@ class StockLot(models.Model):
|
||||
record.tool_material_status = '报废'
|
||||
else:
|
||||
record.tool_material_status = '未入库'
|
||||
if record.fixture_material_search_id:
|
||||
# 注册夹具物料状态到cloud平台
|
||||
record.enroll_fixture_material_stock()
|
||||
# if record.tool_material_search_id:
|
||||
# # 注册刀具物料状态到cloud平台
|
||||
# record.enroll_tool_material_stock()
|
||||
# elif record.fixture_material_search_id:
|
||||
# # 注册夹具物料状态到cloud平台
|
||||
# record.enroll_fixture_material_stock()
|
||||
|
||||
@api.model
|
||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -859,36 +859,14 @@ 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):
|
||||
"""
|
||||
判断是否为出库单
|
||||
"""
|
||||
for record in self:
|
||||
if record.name:
|
||||
is_check_in = record.name.split('/')
|
||||
record.check_in = is_check_in[1]
|
||||
if self.name:
|
||||
is_check_in = self.name.split('/')
|
||||
self.check_in = is_check_in[1]
|
||||
|
||||
def button_validate(self):
|
||||
"""
|
||||
|
||||
@@ -149,9 +149,6 @@
|
||||
<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