From 71cb09c08bc22d5e9685ca02f0f65076e52bb3d3 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Wed, 6 Mar 2024 17:30:54 +0800
Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E5=88=80=E5=85=B7=E7=89=A9?=
=?UTF-8?q?=E6=96=99=E6=90=9C=E7=B4=A2=E6=A8=A1=E5=9E=8B=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E7=BC=96=E7=A0=81=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97=E7=BC=96=E7=A0=81=E6=96=B9?=
=?UTF-8?q?=E6=B3=95=EF=BC=9B2=E3=80=81=E5=AE=8C=E5=96=84=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=89=A9=E6=96=99=E6=90=9C=E7=B4=A2=E5=92=8C=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E5=88=97=E8=A1=A8=E6=B3=A8=E5=86=8C?=
=?UTF-8?q?=E5=88=B0cloud=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/functional_tool_enroll.py | 327 ++++++++++++++++++
.../models/maintenance_equipment.py | 9 +-
.../models/tool_material_search.py | 9 +
3 files changed, 341 insertions(+), 4 deletions(-)
create mode 100644 sf_tool_management/models/functional_tool_enroll.py
diff --git a/sf_tool_management/models/functional_tool_enroll.py b/sf_tool_management/models/functional_tool_enroll.py
new file mode 100644
index 00000000..261ef8b2
--- /dev/null
+++ b/sf_tool_management/models/functional_tool_enroll.py
@@ -0,0 +1,327 @@
+import json
+import base64
+import requests
+from odoo import models, api
+from odoo.addons.sf_base.commons.common import Common
+from odoo.exceptions import UserError
+
+
+class StockLot(models.Model):
+ _inherit = 'stock.lot'
+ _description = '刀具物料序列号注册'
+
+ crea_url = "/api/tool_material_stock/create"
+
+ def enroll_tool_material_stock(self):
+ sf_sync_config = self.env['res.config.settings'].get_values()
+ token = sf_sync_config['token']
+ sf_secret_key = sf_sync_config['sf_secret_key']
+ headers = Common.get_headers(self, token, sf_secret_key)
+ str_url = sf_sync_config['sf_url'] + self.crea_url
+ objs_all = self.env['stock.lot'].search([('id', '=', self.id)])
+ tool_material_stock_list = []
+ if objs_all:
+ for item in objs_all:
+ val = {
+ 'name': item.name,
+ 'tool_material_status': item.tool_material_status,
+ 'location': item.quant_ids[-1].location_id.name
+ }
+ tool_material_stock_list.append(val)
+ kw = json.dumps(tool_material_stock_list, ensure_ascii=False)
+ r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
+ ret = r.json()
+ if r == 200:
+ return '刀具物料序列号注册成功'
+ else:
+ raise UserError("没有注册刀具物料序列号信息")
+
+ @api.onchange('quant_ids')
+ def _onchange_quant_ids(self):
+ for item in self:
+ if item.product_id.categ_id == '刀具':
+ item.enroll_tool_material_stock()
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ records = super(StockLot, self).create(vals_list)
+ for record in records:
+ if record.product_id.categ_id == '刀具':
+ record.enroll_tool_material_stock()
+ return records
+
+
+class ToolMaterial(models.Model):
+ _inherit = 'sf.tool.material.search'
+ _description = '刀具物料注册'
+
+ crea_url = '/api/tool_material/create'
+
+ def enroll_tool_material(self):
+ sf_sync_config = self.env['res.config.settings'].get_values()
+ token = sf_sync_config['token']
+ sf_secret_key = sf_sync_config['sf_secret_key']
+ headers = Common.get_headers(self, token, sf_secret_key)
+ str_url = sf_sync_config['sf_url'] + self.crea_url
+ objs_all = self.env['product.template'].search([('id', '=', self.id)])
+ tool_material_list = []
+ if objs_all:
+ for item in objs_all:
+ barcode_names = []
+ for barcode_id in item.barcode_ids:
+ if barcode_id.name:
+ barcode_names.append(barcode_id.name)
+ val = {
+ 'name': item.name,
+ 'code': item.code,
+ 'cutting_tool_material_code': item.cutting_tool_material_id.code,
+ 'cutting_tool_standard_library_code': item.cutting_tool_standard_library_id.code,
+ 'specification_name': item.specification_id.name,
+ 'image': item.image,
+ 'number': item.number,
+ 'usable_num': item.usable_num,
+ 'have_been_used_num': item.have_been_used_num,
+ 'scrap_num': item.scrap_num,
+ 'barcode_names': barcode_names,
+ 'active': item.active
+ }
+ tool_material_list.append(val)
+ kw = json.dumps(tool_material_list, ensure_ascii=False)
+ r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
+ ret = r.json()
+ if r == 200:
+ return '刀具物料注册成功'
+ else:
+ raise UserError("没有注册刀具物料信息")
+
+
+class FunctionalCuttingToolEntity(models.Model):
+ _inherit = 'sf.functional.cutting.tool.entity'
+ _description = '功能刀具列表注册'
+
+ crea_url = "/api/functional_tool_entity/create"
+
+ # 注册同步功能刀具列表
+ def enroll_functional_tool_entity(self):
+ sf_sync_config = self.env['res.config.settings'].get_values()
+ token = sf_sync_config['token']
+ sf_secret_key = sf_sync_config['sf_secret_key']
+ headers = Common.get_headers(self, token, sf_secret_key)
+ str_url = sf_sync_config['sf_url'] + self.crea_url
+ objs_all = self.env['sf.functional.cutting.tool.entity'].search([('id', '=', self.id)])
+ functional_tool_list = []
+ if objs_all:
+ for item in objs_all:
+ val = {
+ 'id': item.id,
+ 'code': item.code,
+ 'name': item.name,
+ 'tool_groups_name': item.tool_groups_id.name,
+ 'barcode': item.barcode_id.name,
+ 'cutting_tool_type_code': item.cutting_tool_type_id.code,
+ 'functional_tool_diameter': item.functional_tool_diameter,
+ 'knife_tip_r_angle': item.knife_tip_r_angle,
+ 'coarse_middle_thin': item.coarse_middle_thin,
+ 'new_former': item.new_former,
+ 'tool_loading_length': item.tool_loading_length,
+ 'functional_tool_length': item.functional_tool_length,
+ 'effective_length': item.effective_length,
+ 'tool_room_num': item.tool_room_num,
+ 'line_edge_knife_library_num': item.line_edge_knife_library_num,
+ 'machine_knife_library_num': item.machine_knife_library_num,
+ 'max_lifetime_value': item.max_lifetime_value,
+ 'alarm_value': item.alarm_value,
+ 'used_value': item.used_value,
+ 'functional_tool_status': item.functional_tool_status,
+ 'current_location': item.current_location_id.name,
+ 'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
+ 'whether_standard_knife': item.whether_standard_knife,
+ 'L_D_number': item.L_D_number,
+ 'hiding_length': item.hiding_length,
+ 'cut_time': item.cut_time,
+ 'cut_length': item.cut_length,
+ 'cut_number': item.cut_number,
+ 'cutting_tool_integral_model_code': item.cutting_tool_integral_model_id.code,
+ 'cutting_tool_blade_model_code': item.cutting_tool_blade_model_id.code,
+ 'cutting_tool_cutterbar_model_code': item.cutting_tool_cutterbar_model_id.code,
+ 'cutting_tool_cutterpad_model_code': item.cutting_tool_cutterpad_model_id.code,
+ 'cutting_tool_cutterhandle_model_code': item.cutting_tool_cutterhandle_model_id.code,
+ 'cutting_tool_cutterhead_model_code': item.cutting_tool_cutterhead_model_id.code,
+ 'active': item.active,
+ }
+ functional_tool_list.append(val)
+ kw = json.dumps(functional_tool_list, ensure_ascii=False)
+ r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
+ ret = r.json()
+ # self.code = ret['data']
+ # self.state_zc = "已注册"
+ if r == 200:
+ return "功能刀具注册成功"
+ else:
+ raise UserError("没有注册功能刀具信息")
+
+ @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):
+ _inherit = 'sf.functional.tool.warning'
+ _description = '功能刀具预警注册'
+
+ crea_url = "/api/functional_tool_warning/create"
+
+ # 注册同步功能刀具预警
+ def enroll_functional_tool_warning(self):
+ sf_sync_config = self.env['res.config.settings'].get_values()
+ token = sf_sync_config['token']
+ sf_secret_key = sf_sync_config['sf_secret_key']
+ headers = Common.get_headers(self, token, sf_secret_key)
+ str_url = sf_sync_config['sf_url'] + self.crea_url
+ objs_all = self.env['sf.functional.tool.warning'].search([('id', '=', self.id)])
+ tool_warning_list = []
+ if objs_all:
+ for item in objs_all:
+ val = {
+ 'id': item.id,
+ 'name': item.name,
+ 'code': item.code,
+ '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,
+ 'machine_table_type_code': item.machine_table_type_id.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,
+ 'on_board_time': item.on_board_time,
+ '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,
+ '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()
+ # self.code = ret['data']
+ # self.state_zc = "已注册"
+ if r == 200:
+ return "功能刀具预警注册成功"
+ else:
+ raise UserError("没有注册功能刀具预警信息")
+
+ @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/tool_move/create"
+
+ # 注册同步功能刀具预警
+ def enroll_functional_tool_move(self):
+ sf_sync_config = self.env['res.config.settings'].get_values()
+ token = sf_sync_config['token']
+ sf_secret_key = sf_sync_config['sf_secret_key']
+ headers = Common.get_headers(self, token, sf_secret_key)
+ 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)])
+ tool_stock_list = []
+ if objs_all:
+ for item in objs_all:
+ val = {
+ 'id': item.id,
+ 'name': item.functional_tool_name_id.name,
+ 'code': item.code,
+ 'tool_groups_name': item.tool_groups_id.name,
+ 'reference': item.reference,
+ 'barcode': item.barcode_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,
+ 'location_id': item.location_id.name,
+ 'location_dest_id': item.location_dest_id.name,
+ 'date': item.date,
+ '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()
+ # self.code = ret['data']
+ # self.state_zc = "已注册"
+ if r == 200:
+ return "功能刀具出入库记录注册成功"
+ else:
+ raise UserError("没有注册功能刀具出入库记录信息")
+
+ @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/tool_distribution/create"
+
+ # 注册同步功能刀具预警
+ def enroll_functional_tool_real_time_distribution(self):
+ sf_sync_config = self.env['res.config.settings'].get_values()
+ token = sf_sync_config['token']
+ sf_secret_key = sf_sync_config['sf_secret_key']
+ headers = Common.get_headers(self, token, sf_secret_key)
+ 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)])
+ tool_distribution_list = []
+ if objs_all:
+ for item in objs_all:
+ val = {
+ 'id': item.id,
+ 'name': item.name,
+ 'tool_groups_name': item.tool_groups_id.name,
+ }
+ 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()
+ # self.code = ret['data']
+ # self.state_zc = "已注册"
+ if r == 200:
+ return "功能刀具出入库记录注册成功"
+ else:
+ raise UserError("没有注册功能刀具出入库记录信息")
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ records = super(RealTimeDistributionFunctionalTools, self).create(vals_list)
+ for record in records:
+ if record.functional_tool_name_id:
+ record.enroll_functional_tool_move()
+ return records
diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py
index 467989b7..4fbf0b9e 100644
--- a/sf_tool_management/models/maintenance_equipment.py
+++ b/sf_tool_management/models/maintenance_equipment.py
@@ -104,10 +104,11 @@ class StockLot(models.Model):
def _compute_tool_material_status(self):
for record in self:
if record:
- if record.quant_ids[-1].location_id.name == '刀具组装位置':
- record.tool_material_status = '在用'
- else:
- record.tool_material_status = '可用'
+ if record.quant_ids:
+ if record.quant_ids[-1].location_id.name == '刀具组装位置':
+ record.tool_material_status = '在用'
+ else:
+ record.tool_material_status = '可用'
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py
index d62a4b5f..9e493bad 100644
--- a/sf_tool_management/models/tool_material_search.py
+++ b/sf_tool_management/models/tool_material_search.py
@@ -311,6 +311,7 @@ class ToolMaterial(models.Model):
product_id = fields.Many2one('product.product', string='刀具物料产品')
name = fields.Char('名称', related='product_id.name')
+ code = fields.Char('编码', store=True)
cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料',
related='product_id.cutting_tool_material_id',
store=True,
@@ -330,6 +331,14 @@ class ToolMaterial(models.Model):
active = fields.Boolean(string='已归档', default=True)
+ @api.depends('product_id')
+ def _compute_code(self):
+ for record in self:
+ if record:
+ code = '%s_%s' % (record.cutting_tool_standard_library_id.code, record.specification_id.name)
+ obj = self.search([('code', 'like', code)], limit=1, order="id desc")
+ record.code = '%s_%03d' % (code, 1 if obj else int(obj.code[-3:]) + 1)
+
@api.depends('barcode_ids')
def _compute_number(self):
for record in self:
From 47692a9b434022c0b5f9cb4c6350bcde32e00ce5 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Thu, 7 Mar 2024 17:20:43 +0800
Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E6=B5=8B=E8=AF=95=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=9B=B8=E5=85=B3=E6=A8=A1=E5=9E=8B?=
=?UTF-8?q?=E7=9A=84=E6=B3=A8=E5=86=8C=E6=8E=A5=E5=8F=A3=E5=B9=B6=E4=BC=98?=
=?UTF-8?q?=E5=8C=96=EF=BC=9B2=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97=E4=B8=AD=E7=9A=84?=
=?UTF-8?q?=E9=9C=80=E8=A6=81=E6=B3=A8=E5=86=8C=E7=9A=84=E6=A8=A1=E5=9E=8B?=
=?UTF-8?q?=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E6=B3=A8?=
=?UTF-8?q?=E5=86=8C=E6=8C=89=E9=92=AE=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/__init__.py | 1 +
.../models/functional_tool_enroll.py | 52 ++++++++++++++-----
sf_tool_management/views/tool_base_views.xml | 9 ++++
.../views/tool_material_search.xml | 3 ++
4 files changed, 51 insertions(+), 14 deletions(-)
diff --git a/sf_tool_management/models/__init__.py b/sf_tool_management/models/__init__.py
index 98c06d41..05637f26 100644
--- a/sf_tool_management/models/__init__.py
+++ b/sf_tool_management/models/__init__.py
@@ -2,4 +2,5 @@ from . import base
from . import tool_material_search
from . import maintenance_equipment
from . import mrp_workorder
+from . import functional_tool_enroll
diff --git a/sf_tool_management/models/functional_tool_enroll.py b/sf_tool_management/models/functional_tool_enroll.py
index 261ef8b2..cdd6c24c 100644
--- a/sf_tool_management/models/functional_tool_enroll.py
+++ b/sf_tool_management/models/functional_tool_enroll.py
@@ -63,7 +63,7 @@ class ToolMaterial(models.Model):
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['product.template'].search([('id', '=', self.id)])
+ objs_all = self.search([('id', '=', self.id)])
tool_material_list = []
if objs_all:
for item in objs_all:
@@ -82,7 +82,7 @@ class ToolMaterial(models.Model):
'usable_num': item.usable_num,
'have_been_used_num': item.have_been_used_num,
'scrap_num': item.scrap_num,
- 'barcode_names': barcode_names,
+ 'barcode_names': str(barcode_names),
'active': item.active
}
tool_material_list.append(val)
@@ -118,7 +118,7 @@ class FunctionalCuttingToolEntity(models.Model):
'name': item.name,
'tool_groups_name': item.tool_groups_id.name,
'barcode': item.barcode_id.name,
- 'cutting_tool_type_code': item.cutting_tool_type_id.code,
+ 'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
'functional_tool_diameter': item.functional_tool_diameter,
'knife_tip_r_angle': item.knife_tip_r_angle,
'coarse_middle_thin': item.coarse_middle_thin,
@@ -133,7 +133,7 @@ class FunctionalCuttingToolEntity(models.Model):
'alarm_value': item.alarm_value,
'used_value': item.used_value,
'functional_tool_status': item.functional_tool_status,
- 'current_location': item.current_location_id.name,
+ 'current_location': item.current_location,
'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
'whether_standard_knife': item.whether_standard_knife,
'L_D_number': item.L_D_number,
@@ -201,15 +201,15 @@ class FunctionalToolWarning(models.Model):
'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,
- 'on_board_time': item.on_board_time,
+ '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,
'dispose_user': item.dispose_user,
- 'dispose_time': item.dispose_time,
+ 'dispose_time': item.dispose_time.strftime('%Y-%m-%d %H:%M:%S'),
'dispose_func': item.dispose_func,
}
tool_warning_list.append(val)
@@ -236,9 +236,9 @@ class StockMoveLine(models.Model):
_inherit = 'stock.move.line'
_description = '功能刀具出入库记录注册'
- crea_url = "/api/tool_move/create"
+ crea_url = "/api/functional_tool_move/create"
- # 注册同步功能刀具预警
+ # 注册同步功能刀具出入库记录
def enroll_functional_tool_move(self):
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
@@ -255,14 +255,14 @@ class StockMoveLine(models.Model):
'code': item.code,
'tool_groups_name': item.tool_groups_id.name,
'reference': item.reference,
- 'barcode': item.barcode_id.name,
+ '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,
+ 'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
'location_id': item.location_id.name,
- 'location_dest_id': item.location_dest_id.name,
- 'date': item.date,
+ '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)
@@ -289,7 +289,7 @@ class RealTimeDistributionFunctionalTools(models.Model):
_inherit = 'sf.real.time.distribution.of.functional.tools'
_description = '功能刀具安全库存注册'
- crea_url = "/api/tool_distribution/create"
+ crea_url = "/api/functional_tool_distribution/create"
# 注册同步功能刀具预警
def enroll_functional_tool_real_time_distribution(self):
@@ -302,10 +302,29 @@ class RealTimeDistributionFunctionalTools(models.Model):
tool_distribution_list = []
if objs_all:
for item in objs_all:
+ functional_tool_codes = []
+ for obj in item.sf_functional_cutting_tool_entity_ids:
+ functional_tool_codes.append(obj.code)
val = {
'id': item.id,
'name': item.name,
'tool_groups_name': item.tool_groups_id.name,
+ 'sf_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),
+ 'whether_standard_knife': item.whether_standard_knife,
+ 'coarse_middle_thin': item.coarse_middle_thin,
+ 'active': item.active
}
tool_distribution_list.append(val)
kw = json.dumps(tool_distribution_list, ensure_ascii=False)
@@ -325,3 +344,8 @@ class RealTimeDistributionFunctionalTools(models.Model):
if record.functional_tool_name_id:
record.enroll_functional_tool_move()
return records
+
+ def write(self, vals):
+ res = super().write(vals)
+ self.enroll_functional_tool_move()
+ return res
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index bf5fe0fb..afd13ce0 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -40,6 +40,8 @@
@@ -318,6 +322,10 @@
sf.real.time.distribution.of.functional.tools