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