From 400f4b6201f4386133a49bdbde314d2404f63b3c Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Wed, 13 Sep 2023 17:13:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=9B=BE=E6=96=87=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=B8=AD=E5=9B=BE=E7=89=87=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B=E6=96=B0=E5=A2=9E=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=89=A9=E6=96=99=E8=83=BD=E5=8A=9B=E5=AF=B9=E8=B1=A1=E7=9A=84?= =?UTF-8?q?form=E8=A7=86=E5=9B=BE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/tool_other_features.py | 155 ++++++++++++++++++ .../views/tool_other_features_view.xml | 83 +++++++++- 2 files changed, 233 insertions(+), 5 deletions(-) diff --git a/sf_manufacturing/models/tool_other_features.py b/sf_manufacturing/models/tool_other_features.py index ddad9da8..03a954f9 100644 --- a/sf_manufacturing/models/tool_other_features.py +++ b/sf_manufacturing/models/tool_other_features.py @@ -8,6 +8,37 @@ class SuitableMachiningMethod(models.Model): name = fields.Char('名称') image = fields.Image('图片') + @api.model + def name_search(self, name='', args=None, operator='ilike', limit=100): + # 调用父类的name_search方法,获取原始的结果列表 + res = super().name_search(name, args, operator, limit) + # 定义一个空字典用来存储id和name的映射关系 + name_dict = {} + # 遍历结果列表,将id和name存入字典中 + for item in res: + id = item[0] + name = item[1] + name_dict[id] = name + # 根据id列表搜索符合条件的记录 + records = self.browse(name_dict.keys()) + # 定义一个新的结果列表用来存储修改后的结果 + new_res = [] + # 遍历每条记录 + for record in records: + # 获取记录的id,name和image属性 + id = record.id + name = name_dict[id] + image = record.image + # 如果image不为空,将其转换为data URI scheme + if image: + data_uri = f"data:image/png;base64,{image.decode('utf-8')}" + else: + data_uri = "" + # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result + new_res.append([id, name, data_uri]) + # 返回新的结果列表 + return new_res + class BladeTipCharacteristics(models.Model): _name = 'sf.blade.tip.characteristics' @@ -16,6 +47,37 @@ class BladeTipCharacteristics(models.Model): name = fields.Char('名称') image = fields.Image('图片') + @api.model + def name_search(self, name='', args=None, operator='ilike', limit=100): + # 调用父类的name_search方法,获取原始的结果列表 + res = super().name_search(name, args, operator, limit) + # 定义一个空字典用来存储id和name的映射关系 + name_dict = {} + # 遍历结果列表,将id和name存入字典中 + for item in res: + id = item[0] + name = item[1] + name_dict[id] = name + # 根据id列表搜索符合条件的记录 + records = self.browse(name_dict.keys()) + # 定义一个新的结果列表用来存储修改后的结果 + new_res = [] + # 遍历每条记录 + for record in records: + # 获取记录的id,name和image属性 + id = record.id + name = name_dict[id] + image = record.image + # 如果image不为空,将其转换为data URI scheme + if image: + data_uri = f"data:image/png;base64,{image.decode('utf-8')}" + else: + data_uri = "" + # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result + new_res.append([id, name, data_uri]) + # 返回新的结果列表 + return new_res + class HandleType(models.Model): _name = 'sf.handle.type' @@ -24,6 +86,37 @@ class HandleType(models.Model): name = fields.Char('名称') image = fields.Image('图片') + @api.model + def name_search(self, name='', args=None, operator='ilike', limit=100): + # 调用父类的name_search方法,获取原始的结果列表 + res = super().name_search(name, args, operator, limit) + # 定义一个空字典用来存储id和name的映射关系 + name_dict = {} + # 遍历结果列表,将id和name存入字典中 + for item in res: + id = item[0] + name = item[1] + name_dict[id] = name + # 根据id列表搜索符合条件的记录 + records = self.browse(name_dict.keys()) + # 定义一个新的结果列表用来存储修改后的结果 + new_res = [] + # 遍历每条记录 + for record in records: + # 获取记录的id,name和image属性 + id = record.id + name = name_dict[id] + image = record.image + # 如果image不为空,将其转换为data URI scheme + if image: + data_uri = f"data:image/png;base64,{image.decode('utf-8')}" + else: + data_uri = "" + # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result + new_res.append([id, name, data_uri]) + # 返回新的结果列表 + return new_res + class CuttingDirection(models.Model): _name = 'sf.cutting.direction' @@ -32,6 +125,37 @@ class CuttingDirection(models.Model): name = fields.Char('名称') image = fields.Image('图片') + @api.model + def name_search(self, name='', args=None, operator='ilike', limit=100): + # 调用父类的name_search方法,获取原始的结果列表 + res = super().name_search(name, args, operator, limit) + # 定义一个空字典用来存储id和name的映射关系 + name_dict = {} + # 遍历结果列表,将id和name存入字典中 + for item in res: + id = item[0] + name = item[1] + name_dict[id] = name + # 根据id列表搜索符合条件的记录 + records = self.browse(name_dict.keys()) + # 定义一个新的结果列表用来存储修改后的结果 + new_res = [] + # 遍历每条记录 + for record in records: + # 获取记录的id,name和image属性 + id = record.id + name = name_dict[id] + image = record.image + # 如果image不为空,将其转换为data URI scheme + if image: + data_uri = f"data:image/png;base64,{image.decode('utf-8')}" + else: + data_uri = "" + # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result + new_res.append([id, name, data_uri]) + # 返回新的结果列表 + return new_res + class SuitableCoolant(models.Model): _name = 'sf.suitable.coolant' @@ -40,6 +164,37 @@ class SuitableCoolant(models.Model): name = fields.Char('名称') image = fields.Image('图片') + @api.model + def name_search(self, name='', args=None, operator='ilike', limit=100): + # 调用父类的name_search方法,获取原始的结果列表 + res = super().name_search(name, args, operator, limit) + # 定义一个空字典用来存储id和name的映射关系 + name_dict = {} + # 遍历结果列表,将id和name存入字典中 + for item in res: + id = item[0] + name = item[1] + name_dict[id] = name + # 根据id列表搜索符合条件的记录 + records = self.browse(name_dict.keys()) + # 定义一个新的结果列表用来存储修改后的结果 + new_res = [] + # 遍历每条记录 + for record in records: + # 获取记录的id,name和image属性 + id = record.id + name = name_dict[id] + image = record.image + # 如果image不为空,将其转换为data URI scheme + if image: + data_uri = f"data:image/png;base64,{image.decode('utf-8')}" + else: + data_uri = "" + # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result + new_res.append([id, name, data_uri]) + # 返回新的结果列表 + return new_res + class CuttingSpeed(models.Model): _name = 'sf.cutting.speed' diff --git a/sf_manufacturing/views/tool_other_features_view.xml b/sf_manufacturing/views/tool_other_features_view.xml index 3af6d0e8..952f7bc8 100644 --- a/sf_manufacturing/views/tool_other_features_view.xml +++ b/sf_manufacturing/views/tool_other_features_view.xml @@ -12,11 +12,26 @@ + + 适合加工方式 + sf.suitable.machining.method + +
+ + + + + + +
+
+
+ 适合加工方式 ir.actions.act_window sf.suitable.machining.method - tree + tree,form @@ -32,11 +47,26 @@ + + 刀尖特征 + sf.blade.tip.characteristics + +
+ + + + + + +
+
+
+ 刀尖特征 ir.actions.act_window sf.blade.tip.characteristics - tree + tree,form @@ -52,11 +82,26 @@ + + 柄部类型 + sf.handle.type + +
+ + + + + + +
+
+
+ 柄部类型 ir.actions.act_window sf.handle.type - tree + tree,form @@ -72,11 +117,26 @@ + + 走刀方向 + sf.cutting.direction + +
+ + + + + + +
+
+
+ 走刀方向 ir.actions.act_window sf.cutting.direction - tree + tree,form @@ -92,11 +152,24 @@ + + 适合冷却液 + sf.suitable.coolant + +
+ + + + +
+
+
+ 适合冷却液 ir.actions.act_window sf.suitable.coolant - tree + tree,form