From 9d2bad977ce0e9a79f38e08b791013002936e9e2 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Mon, 4 Mar 2024 17:10:41 +0800
Subject: [PATCH 01/15] =?UTF-8?q?1=E3=80=81=E4=BA=A7=E5=93=81=E6=A8=A1?=
=?UTF-8?q?=E5=9E=8B=E7=9A=84=E4=BA=A7=E5=93=81=E7=B1=BB=E5=88=AB=E5=AD=97?=
=?UTF-8?q?=E6=AE=B5=E6=B7=BB=E5=8A=A0=E5=BF=85=E5=A1=AB=E6=A0=87=E8=AE=B0?=
=?UTF-8?q?=EF=BC=9B2=E3=80=81=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?=
=?UTF-8?q?=E7=9A=84=E5=B7=A5=E5=8D=95=E6=B7=BB=E5=8A=A0RFID=E7=A0=81(?=
=?UTF-8?q?=E5=B7=B2=E8=A7=A3=E9=99=A4)=E5=AD=97=E6=AE=B5=EF=BC=8C?=
=?UTF-8?q?=E5=BD=93=E5=B7=A5=E5=8D=95=E8=A7=A3=E9=99=A4=E8=A3=85=E5=A4=B9?=
=?UTF-8?q?=E6=97=B6=E4=BF=9D=E5=AD=98RFID=E7=A0=81=E5=88=B0RFID=E7=A0=81(?=
=?UTF-8?q?=E5=B7=B2=E8=A7=A3=E9=99=A4)=E5=AD=97=E6=AE=B5=E8=BF=9B?=
=?UTF-8?q?=E8=A1=8C=E5=B1=95=E7=A4=BA=EF=BC=9B3=E3=80=81=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E5=88=97=E8=A1=A8=E7=9A=84=E5=BD=93?=
=?UTF-8?q?=E5=89=8D=E4=BD=8D=E7=BD=AE=E5=AD=97=E6=AE=B5=E6=94=B9=E4=B8=BA?=
=?UTF-8?q?Selection=E7=B1=BB=E5=9E=8B=EF=BC=8C=E5=B9=B6=E4=BC=98=E5=8C=96?=
=?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97=E5=8A=9F=E8=83=BD=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E5=BD=93=E5=89=8D=E4=BD=8D=E7=BD=AE=E7=9A=84=E6=96=B9?=
=?UTF-8?q?=E6=B3=95=EF=BC=9B4=E3=80=81=E8=8E=B7=E5=8F=96=E6=9C=BA?=
=?UTF-8?q?=E5=BA=8A=E5=88=80=E5=BA=93=E4=BF=A1=E6=81=AF=E6=97=B6=EF=BC=8C?=
=?UTF-8?q?=E5=AF=B9=E6=96=B0=E8=A3=85=E5=88=80=E7=9A=84=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=E5=88=80=E5=85=B7=E8=BF=9B=E8=A1=8C=E5=BA=93=E5=AD=98=E4=BD=8D?=
=?UTF-8?q?=E7=A7=BB=E5=88=80=E5=88=B6=E9=80=A0=E5=89=8D(=E6=9C=BA?=
=?UTF-8?q?=E5=86=85=E5=88=80=E5=BA=93)=EF=BC=9B5=E3=80=81=E4=BC=98?=
=?UTF-8?q?=E5=8C=96=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85?=
=?UTF-8?q?=E6=97=B6=E6=89=AB=E7=A0=81=E8=87=AA=E5=8A=A8=E5=BD=95=E5=85=A5?=
=?UTF-8?q?RFID=E7=A0=81=E5=8A=9F=E8=83=BD=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../product_template_management_view.xml | 2 +-
sf_manufacturing/models/mrp_workorder.py | 2 +
sf_manufacturing/views/mrp_workorder_view.xml | 4 +-
sf_tool_management/models/base.py | 87 +++++++++++--------
.../models/maintenance_equipment.py | 3 +
sf_tool_management/views/tool_base_views.xml | 6 +-
6 files changed, 64 insertions(+), 40 deletions(-)
diff --git a/sf_dlm_management/views/product_template_management_view.xml b/sf_dlm_management/views/product_template_management_view.xml
index 1e761cc8..249decdb 100644
--- a/sf_dlm_management/views/product_template_management_view.xml
+++ b/sf_dlm_management/views/product_template_management_view.xml
@@ -7,7 +7,7 @@
-
+
-
+
+
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 22cb1b42..649c757e 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -39,24 +39,29 @@ class FunctionalCuttingToolEntity(models.Model):
functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')],
string='状态', store=True, default='正常')
current_location_id = fields.Many2one('stock.location', string='当前位置', readonly=True)
- current_location = fields.Char('位置', compute='_compute_current_location_id')
+ current_location = fields.Selection(
+ [('组装后', '组装后'), ('刀具房', '刀具房'), ('线边刀库', '线边刀库'), ('机内刀库', '机内刀库')],
+ string='位置', compute='_compute_current_location_id', store=True)
image = fields.Binary('图片', readonly=True)
active = fields.Boolean(string='已归档', default=True)
- @api.depends('barcode_id')
+ @api.depends('barcode_id.quant_ids')
def _compute_current_location_id(self):
for record in self:
if record.barcode_id.quant_ids:
for quant_id in record.barcode_id.quant_ids:
if quant_id.inventory_quantity_auto_apply > 0:
- record.sudo().current_location_id = quant_id.location_id
- record.sudo().current_location = quant_id.location_id.name
+ record.current_location_id = quant_id.location_id
+ if quant_id.location_id.name == '制造前':
+ record.current_location = '机内刀库'
+ else:
+ record.current_location = quant_id.location_id.name
if record.current_location_id:
record.sudo().get_location_num()
else:
- record.sudo().current_location_id = False
- record.sudo().current_location = False
+ record.current_location_id = False
+ record.current_location = False
def get_location_num(self):
"""
@@ -64,15 +69,15 @@ class FunctionalCuttingToolEntity(models.Model):
"""
for obj in self:
if obj.current_location_id:
- if obj.current_location_id.name in ['刀具房']:
+ if obj.current_location in ['刀具房']:
obj.tool_room_num = 1
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 0
- elif "线边刀库" in obj.current_location_id.name:
+ elif "线边刀库" in obj.current_location:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 1
obj.machine_knife_library_num = 0
- elif "机内刀库" in obj.current_location_id.name:
+ elif "机内刀库" in obj.current_location:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 1
@@ -180,33 +185,45 @@ class FunctionalCuttingToolEntity(models.Model):
('coarse_middle_thin', '=', self.coarse_middle_thin)]
return result
- # ==========刀具组接口==========
- # def _register_functional_tool_groups(self, obj):
- # create_url = '/AutoDeviceApi/ToolGroup'
- # 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(obj, token, sf_secret_key)
- # strurl = sf_sync_config['sf_url'] + create_url
- # val = {
- # 'ToolName': obj.name,
- # 'GroupName': obj.tool_groups_id.name,
- # 'ToolId': obj.code
- # }
- # kw = json.dumps(val, ensure_ascii=False)
- # r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
- # ret = r.json()
- # if r == 200:
- # return "刀具组发送成功"
- # else:
- # raise ValidationError("刀具组发送失败")
+ def tool_inventory_displacement_out(self):
+ """
+ 机床当前刀库实时信息接口,功能刀具出库
+ """
+ # 获取位置对象
+ location_inventory_id = self.current_location_id
+ stock_location_id = self.env['stock.location'].search([('name', '=', '制造前')])
+ # 创建功能刀具该批次/序列号 库存移动和移动历史
+ self.barcode_id.create_stock_quant(location_inventory_id, stock_location_id,
+ self.functional_tool_name_id.id, '机床装刀')
- # @api.model_create_multi
- # def create(self, vals):
- # obj = super(FunctionalCuttingToolEntity, self).create(vals)
- # # 调用刀具组接口
- # self._register_functional_tool_groups(obj)
- # return obj
+
+# ==========刀具组接口==========
+# def _register_functional_tool_groups(self, obj):
+# create_url = '/AutoDeviceApi/ToolGroup'
+# 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(obj, token, sf_secret_key)
+# strurl = sf_sync_config['sf_url'] + create_url
+# val = {
+# 'ToolName': obj.name,
+# 'GroupName': obj.tool_groups_id.name,
+# 'ToolId': obj.code
+# }
+# kw = json.dumps(val, ensure_ascii=False)
+# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
+# ret = r.json()
+# if r == 200:
+# return "刀具组发送成功"
+# else:
+# raise ValidationError("刀具组发送失败")
+
+# @api.model_create_multi
+# def create(self, vals):
+# obj = super(FunctionalCuttingToolEntity, self).create(vals)
+# # 调用刀具组接口
+# self._register_functional_tool_groups(obj)
+# return obj
class FunctionalToolWarning(models.Model):
diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py
index 9f3cefba..467989b7 100644
--- a/sf_tool_management/models/maintenance_equipment.py
+++ b/sf_tool_management/models/maintenance_equipment.py
@@ -79,6 +79,9 @@ class SfMaintenanceEquipment(models.Model):
'functional_tool_name_id': functional_tool_id.id,
'tool_install_time': time
})
+ if functional_tool_id.current_location_id.name != '制造前':
+ # 对功能刀具进行出库到生产线
+ functional_tool_id.tool_inventory_displacement_out()
functional_tool_id.write({
'max_lifetime_value': data['MaxLife'],
'used_value': data['UseLife'],
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index 239845a4..bf5fe0fb 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -152,8 +152,8 @@
-
-
+
+
@@ -203,7 +203,7 @@
-
+
From d85b05f9998889808a6fe2aecb117a4a014efaac Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Mon, 4 Mar 2024 17:11:18 +0800
Subject: [PATCH 02/15] 1
---
sf_tool_management/wizard/wizard.py | 62 +++++++++++++++--------------
1 file changed, 33 insertions(+), 29 deletions(-)
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index 3b2649a2..322cf096 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -300,29 +300,32 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
智能工厂组装单处扫码绑定刀具物料')
"""
for record in self:
- records = record.env['stock.lot'].search([('name', '=', barcode)])
- if not records:
- raise ValidationError('扫描的条形码数据不存在,请重新扫描!')
- for record_stock_lot in records:
- if record_stock_lot.quant_ids[-1].location_id.name == '刀具组装位置':
- raise ValidationError('该刀具物料已使用,请重新选择!!!')
- elif record_stock_lot.quant_ids[-1].location_id.name not in '刀具房':
- raise ValidationError('该刀具物料未入库,请重新选择!!!')
- tool_material_name = record_stock_lot.product_id.cutting_tool_material_id.name
- if tool_material_name == '整体式刀具':
- record.integral_code_id = record_stock_lot.id
- elif tool_material_name == '刀片':
- record.blade_code_id = record_stock_lot.id
- elif tool_material_name == '刀杆':
- record.bar_code_id = record_stock_lot.id
- elif tool_material_name == '刀盘':
- record.pad_code_id = record_stock_lot.id
- elif tool_material_name == '刀柄':
- record.handle_code_id = record_stock_lot.id
- elif tool_material_name == '夹头':
- record.chuck_code_id = record_stock_lot.id
- else:
- raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
+ if 'DJWL' in barcode:
+ records = record.env['stock.lot'].search([('name', '=', barcode)])
+ if not records:
+ raise ValidationError('扫描的条形码数据不存在,请重新扫描!')
+ for record_stock_lot in records:
+ if record_stock_lot.quant_ids[-1].location_id.name == '刀具组装位置':
+ raise ValidationError('该刀具物料已使用,请重新选择!!!')
+ elif record_stock_lot.quant_ids[-1].location_id.name not in '刀具房':
+ raise ValidationError('该刀具物料未入库,请重新选择!!!')
+ tool_material_name = record_stock_lot.product_id.cutting_tool_material_id.name
+ if tool_material_name == '整体式刀具':
+ record.integral_code_id = record_stock_lot.id
+ elif tool_material_name == '刀片':
+ record.blade_code_id = record_stock_lot.id
+ elif tool_material_name == '刀杆':
+ record.bar_code_id = record_stock_lot.id
+ elif tool_material_name == '刀盘':
+ record.pad_code_id = record_stock_lot.id
+ elif tool_material_name == '刀柄':
+ record.handle_code_id = record_stock_lot.id
+ elif tool_material_name == '夹头':
+ record.chuck_code_id = record_stock_lot.id
+ else:
+ raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
+ else:
+ record.rfid = barcode
# 组装功能刀具参数信息
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
@@ -676,7 +679,8 @@ class ProductProduct(models.Model):
location_inventory_id = self.env['stock.location'].search([('name', '=', 'Production')])
stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
- stock_lot.create_stock_quant(location_inventory_id, stock_location_id, functional_tool_assembly.id)
+ stock_lot.create_stock_quant(location_inventory_id, stock_location_id, functional_tool_assembly.id,
+ '功能刀具组装')
return stock_lot
@@ -710,20 +714,20 @@ class ProductProduct(models.Model):
location_inventory_id = tool_material.quant_ids.location_id[-1]
stock_location_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
- tool_material.create_stock_quant(location_inventory_id, stock_location_id, None)
+ tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装')
class StockLot(models.Model):
_inherit = 'stock.lot'
- def create_stock_quant(self, location_inventory_id, stock_location_id, functional_tool_assembly_id):
+ def create_stock_quant(self, location_inventory_id, stock_location_id, functional_tool_assembly_id, name):
"""
对功能刀具组装过程的功能刀具和刀具物料进行库存移动,以及创建移动历史
"""
# 创建库存移动记录
- stock_move_id = self.env['stock.move'].create({
- 'name': '功能刀具组装',
+ stock_move_id = self.env['stock.move'].sudo().create({
+ 'name': name,
'product_id': self.product_id.id,
'location_id': location_inventory_id.id,
'location_dest_id': stock_location_id.id,
@@ -732,7 +736,7 @@ class StockLot(models.Model):
})
# 创建移动历史记录
- stock_move_line_id = self.env['stock.move.line'].create({
+ stock_move_line_id = self.env['stock.move.line'].sudo().create({
'product_id': self.product_id.id,
'functional_tool_name_id': functional_tool_assembly_id,
'lot_id': self.id,
From 1a50a8220e8aa6dbd2ce4aae3dbef3d7aadd1682 Mon Sep 17 00:00:00 2001
From: "qihao.gong@jikimo.com"
Date: Tue, 5 Mar 2024 16:50:08 +0800
Subject: [PATCH 03/15] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=AE=BE=E5=A4=87?=
=?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E7=9B=B8=E5=85=B3=E7=BC=BA?=
=?UTF-8?q?=E9=99=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_base/models/base.py | 38 ++++++++++++----------
sf_base/views/base_view.xml | 12 ++++---
sf_maintenance/models/sf_maintenance.py | 37 +++++++++++----------
sf_maintenance/views/maintenance_views.xml | 13 +++++---
sf_mrs_connect/models/sync_common.py | 4 +++
zpl_print/models/common.py | 2 +-
6 files changed, 63 insertions(+), 43 deletions(-)
diff --git a/sf_base/models/base.py b/sf_base/models/base.py
index 6fc86e94..c3152098 100644
--- a/sf_base/models/base.py
+++ b/sf_base/models/base.py
@@ -106,6 +106,7 @@ class MachineTool(models.Model):
lead_screw = fields.Char('丝杆')
workbench_L = fields.Char('工作台长度(mm)')
workbench_W = fields.Char('工作台宽度(mm)')
+ workbench_H = fields.Char('工作台高度(mm)')
guide_rail = fields.Char('导轨')
machine_tool_L = fields.Char('机床长度(mm)')
machine_tool_W = fields.Char('机床宽度(mm)')
@@ -193,6 +194,7 @@ class MachineTool(models.Model):
item.lead_screw = item.type_id.lead_screw
item.workbench_L = item.type_id.workbench_L
item.workbench_W = item.type_id.workbench_W
+ item.workbench_H = item.type_id.workbench_H
item.guide_rail = item.type_id.guide_rail
item.machine_tool_L = item.type_id.machine_tool_L
item.machine_tool_W = item.type_id.machine_tool_W
@@ -280,6 +282,7 @@ class MachineToolType(models.Model):
workpiece_load = fields.Char('工件最大负载(kg)')
workbench_L = fields.Char('工作台长度(mm)')
workbench_W = fields.Char('工作台宽度(mm)')
+ workbench_H = fields.Char('工作台高度(mm)')
machine_tool_L = fields.Char('机床长度(mm)')
machine_tool_W = fields.Char('机床宽度(mm)')
machine_tool_H = fields.Char('机床高度(mm)')
@@ -295,8 +298,9 @@ class MachineToolType(models.Model):
x_axis = fields.Integer('X轴')
y_axis = fields.Integer('Y轴')
z_axis = fields.Integer('Z轴')
- b_axis = fields.Integer('B轴')
- c_axis = fields.Integer('C轴')
+ a_axis = fields.Char('a轴')
+ b_axis = fields.Char('B轴')
+ c_axis = fields.Char('C轴')
remark = fields.Char('备注')
control_system_id = fields.Many2one('sf.machine.control_system',
string="控制系统")
@@ -309,7 +313,7 @@ class MachineToolType(models.Model):
default="", string="轴数")
# 1212新增字段
- a_axis = fields.Integer('a轴')
+
function_type = fields.Selection(
[("ZXJGZX", "钻铣加工中心"), ("CXJGZX", "车削加工中心"), ("FHJGZX", "复合加工中心")],
default="", string="功能类型")
@@ -335,23 +339,23 @@ class MachineToolType(models.Model):
straight_cutting_feed_rate = fields.Char('直线切削进给速度(mm/min)')
rotary_cutting_feed_rate = fields.Char('回转切削进给速度(mm/min)')
- X_precision = fields.Float('X轴定位精度(mm)', digits=(12, 3))
- X_precision_repeat = fields.Float('X轴重复定位精度(mm)', digits=(12, 3))
- Y_precision = fields.Float('Y轴定位精度(mm)', digits=(12, 3))
- Y_precision_repeat = fields.Float('Y轴重复定位精度(mm)', digits=(12, 3))
- Z_precision = fields.Float('Z轴定位精度(mm)', digits=(12, 3))
- Z_precision_repeat = fields.Float('Z轴重复定位精度(mm)', digits=(12, 3))
- a_precision = fields.Float('a轴定位精度(mm)', digits=(12, 3))
- a_precision_repeat = fields.Float('a轴重复定位精度(mm)', digits=(12, 3))
- b_precision = fields.Float('b轴定位精度(mm)', digits=(12, 3))
- b_precision_repeat = fields.Float('b轴重复定位精度(mm)', digits=(12, 3))
- c_precision = fields.Float('c轴定位精度(mm)', digits=(12, 3))
- c_precision_repeat = fields.Float('c轴重复定位精度(mm)', digits=(12, 3))
+ X_precision = fields.Char('X轴定位精度(mm)')
+ X_precision_repeat = fields.Char('X轴重复定位精度(mm)')
+ Y_precision = fields.Char('Y轴定位精度(mm)')
+ Y_precision_repeat = fields.Char('Y轴重复定位精度(mm)')
+ Z_precision = fields.Char('Z轴定位精度(mm)')
+ Z_precision_repeat = fields.Char('Z轴重复定位精度(mm)')
+ a_precision = fields.Char('a轴定位精度(mm)')
+ a_precision_repeat = fields.Char('a轴重复定位精度(mm)')
+ b_precision = fields.Char('b轴定位精度(mm)')
+ b_precision_repeat = fields.Char('b轴重复定位精度(mm)')
+ c_precision = fields.Char('c轴定位精度(mm)')
+ c_precision_repeat = fields.Char('c轴重复定位精度(mm)')
tool_full_diameter_max = fields.Float('刀具满刀最大直径(mm)')
tool_perimeter_diameter_max = fields.Float('刀具邻空刀最大直径(mm)')
- T_tool_time = fields.Integer('T-T换刀时间(s)')
- C_tool_time = fields.Integer('C-C换刀时间(s)')
+ T_tool_time = fields.Float('T-T换刀时间(s)', digits=(12, 1))
+ C_tool_time = fields.Float('C-C换刀时间(s)', digits=(12, 1))
jg_image_id = fields.Many2many('maintenance.equipment.image', 'jg_equipment_id', string='加工能力',
domain="[('type', '=', '加工能力')]")
diff --git a/sf_base/views/base_view.xml b/sf_base/views/base_view.xml
index ca3aba53..a41d3a2b 100644
--- a/sf_base/views/base_view.xml
+++ b/sf_base/views/base_view.xml
@@ -173,6 +173,10 @@
+
+
+
@@ -239,15 +243,15 @@
attrs="{'invisible': [('number_of_axles', '=', '三轴')]}"
options="{'format': false}"/>
-
-
-
-
diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py
index d0ce2498..5b0db796 100644
--- a/sf_maintenance/models/sf_maintenance.py
+++ b/sf_maintenance/models/sf_maintenance.py
@@ -47,7 +47,7 @@ class SfMaintenanceEquipment(models.Model):
default="", string="轴数")
# 1212新增字段
- a_axis = fields.Integer('a轴')
+
function_type = fields.Selection(
[("ZXJGZX", "钻铣加工中心"), ("CXJGZX", "车削加工中心"), ("FHJGZX", "复合加工中心")],
default="", string="功能类型")
@@ -73,23 +73,23 @@ class SfMaintenanceEquipment(models.Model):
straight_cutting_feed_rate = fields.Char('直线切削进给速度(mm/min)')
rotary_cutting_feed_rate = fields.Char('回转切削进给速度(mm/min)')
- X_precision = fields.Float('X轴定位精度(mm)', digits=(12, 3))
- X_precision_repeat = fields.Float('X轴重复定位精度(mm)', digits=(12, 3))
- Y_precision = fields.Float('Y轴定位精度(mm)', digits=(12, 3))
- Y_precision_repeat = fields.Float('Y轴重复定位精度(mm)', digits=(12, 3))
- Z_precision = fields.Float('Z轴定位精度(mm)', digits=(12, 3))
- Z_precision_repeat = fields.Float('Z轴重复定位精度(mm)', digits=(12, 3))
- a_precision = fields.Float('a轴定位精度(mm)', digits=(12, 3))
- a_precision_repeat = fields.Float('a轴重复定位精度(mm)', digits=(12, 3))
- b_precision = fields.Float('b轴定位精度(mm)', digits=(12, 3))
- b_precision_repeat = fields.Float('b轴重复定位精度(mm)', digits=(12, 3))
- c_precision = fields.Float('c轴定位精度(mm)', digits=(12, 3))
- c_precision_repeat = fields.Float('c轴重复定位精度(mm)', digits=(12, 3))
+ X_precision = fields.Char('X轴定位精度(mm)')
+ X_precision_repeat = fields.Char('X轴重复定位精度(mm)')
+ Y_precision = fields.Char('Y轴定位精度(mm)')
+ Y_precision_repeat = fields.Char('Y轴重复定位精度(mm)')
+ Z_precision = fields.Char('Z轴定位精度(mm)')
+ Z_precision_repeat = fields.Char('Z轴重复定位精度(mm)')
+ a_precision = fields.Char('a轴定位精度(mm)')
+ a_precision_repeat = fields.Char('a轴重复定位精度(mm)')
+ b_precision = fields.Char('b轴定位精度(mm)')
+ b_precision_repeat = fields.Char('b轴重复定位精度(mm)')
+ c_precision = fields.Char('c轴定位精度(mm)')
+ c_precision_repeat = fields.Char('c轴重复定位精度(mm)')
tool_full_diameter_max = fields.Float('刀具满刀最大直径(mm)')
tool_perimeter_diameter_max = fields.Float('刀具邻空刀最大直径(mm)')
- T_tool_time = fields.Integer('T-T换刀时间(s)')
- C_tool_time = fields.Integer('C-C换刀时间(s)')
+ T_tool_time = fields.Float('T-T换刀时间(s)', digits=(12, 1))
+ C_tool_time = fields.Float('C-C换刀时间(s)', digits=(12, 1))
# 待删除字段
precision_min = fields.Float('X轴定位精度min(mm)', digits=(12, 3))
@@ -164,11 +164,12 @@ class SfMaintenanceEquipment(models.Model):
number_of_knife_library = fields.Integer('刀库数量(把)')
rotate_speed = fields.Integer('转速')
# 加工进程
+ a_axis = fields.Char('a轴')
x_axis = fields.Integer('X轴')
y_axis = fields.Integer('Y轴')
z_axis = fields.Integer('Z轴')
- b_axis = fields.Integer('B轴')
- c_axis = fields.Integer('C轴')
+ b_axis = fields.Char('B轴')
+ c_axis = fields.Char('C轴')
remark = fields.Char('备注')
is_binding = fields.Boolean('是否绑定机床', default=False)
control_system_id = fields.Many2one('sf.machine.control_system',
@@ -191,6 +192,7 @@ class SfMaintenanceEquipment(models.Model):
workpiece_load = fields.Char('工件最大负载(kg)')
workbench_L = fields.Char('工作台长度(mm)')
workbench_W = fields.Char('工作台宽度(mm)')
+ workbench_H = fields.Char('工作台高度(mm)')
machine_tool_L = fields.Char('机床长度(mm)')
machine_tool_W = fields.Char('机床宽度(mm)')
machine_tool_H = fields.Char('机床高度(mm)')
@@ -518,6 +520,7 @@ class SfMaintenanceEquipment(models.Model):
'lead_screw': item.lead_screw,
'workbench_L': item.workbench_L,
'workbench_W': item.workbench_W,
+ 'workbench_H': item.workbench_H,
'guide_rail': item.guide_rail,
'machine_tool_L': item.machine_tool_L,
'machine_tool_W': item.machine_tool_W,
diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml
index b6cc3cbb..140456df 100644
--- a/sf_maintenance/views/maintenance_views.xml
+++ b/sf_maintenance/views/maintenance_views.xml
@@ -85,6 +85,11 @@
+
+
+
@@ -155,15 +160,15 @@
attrs="{'invisible': [('number_of_axles', '=', '三轴')]}"
options="{'format': false}"/>
-
-
-
-
diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py
index d3e7bbad..fe806f85 100644
--- a/sf_mrs_connect/models/sync_common.py
+++ b/sf_mrs_connect/models/sync_common.py
@@ -657,6 +657,7 @@ class MachineToolType(models.Model):
# "lead_screw": item['lead_screw'],
"workbench_L": item['workbench_L'],
"workbench_W": item['workbench_W'],
+ "workbench_H": item['workbench_H'],
# "guide_rail": item['guide_rail'],
"machine_tool_L": item['machine_tool_L'],
"machine_tool_W": item['machine_tool_W'],
@@ -739,6 +740,7 @@ class MachineToolType(models.Model):
# "lead_screw": item['lead_screw'],
"workbench_L": item['workbench_L'],
"workbench_W": item['workbench_W'],
+ "workbench_H": item['workbench_H'],
# "guide_rail": item['guide_rail'],
"machine_tool_L": item['machine_tool_L'],
"machine_tool_W": item['machine_tool_W'],
@@ -852,6 +854,7 @@ class MachineToolType(models.Model):
# "lead_screw": item['lead_screw'],
"workbench_L": item['workbench_L'],
"workbench_W": item['workbench_W'],
+ "workbench_H": item['workbench_H'],
# "guide_rail": item['guide_rail'],
"machine_tool_L": item['machine_tool_L'],
"machine_tool_W": item['machine_tool_W'],
@@ -934,6 +937,7 @@ class MachineToolType(models.Model):
# "lead_screw": item['lead_screw'],
"workbench_L": item['workbench_L'],
"workbench_W": item['workbench_W'],
+ "workbench_H": item['workbench_H'],
# "guide_rail": item['guide_rail'],
"machine_tool_L": item['machine_tool_L'],
"machine_tool_W": item['machine_tool_W'],
diff --git a/zpl_print/models/common.py b/zpl_print/models/common.py
index d45f74e0..6e4e7eca 100644
--- a/zpl_print/models/common.py
+++ b/zpl_print/models/common.py
@@ -8,7 +8,7 @@ class Common(models.Model):
_description = u'公用类'
def print_zpl(self, zpl_str):
- WinDll_path = "D://桌面//pythonZPL//tsc_python_sdk_example//TSC_Python_SDK_Example//tsc_sample//libs//TSCLIB.dll"
+ WinDll_path = "D://桌面//pythonZPL//zebra_zpl//libs//TSCLIB.dll"
try:
tsclibrary = ctypes.WinDLL(WinDll_path)
tsclibrary.openportW("USB")
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 04/15] =?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 05/15] =?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
-
\ No newline at end of file
From fbce395321a5c4166301100b414ea44c9a147254 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Mon, 11 Mar 2024 17:34:03 +0800
Subject: [PATCH 11/15] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=89=A9=E6=96=99=E5=BA=8F=E5=88=97=E5=8F=B7=E3=80=81?=
=?UTF-8?q?=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E6=B3=A8=E5=86=8C=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=EF=BC=9B2=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E5=87=BA=E5=85=A5=E5=BA=93=E8=AE=B0=E5=BD=95=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=EF=BC=9B3=E3=80=81=E4=BC=98=E5=8C=96=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=89=A9=E6=96=99=E6=90=9C=E7=B4=A2=E6=A8=A1=E5=9E=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 1 -
.../models/functional_tool_enroll.py | 84 +++++++++++--------
.../models/maintenance_equipment.py | 11 ++-
.../models/tool_material_search.py | 10 +--
4 files changed, 55 insertions(+), 51 deletions(-)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 649c757e..da1433ea 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -136,7 +136,6 @@ class FunctionalCuttingToolEntity(models.Model):
@api.depends('cutting_tool_integral_model_id', 'cutting_tool_blade_model_id')
def _compute_maintenance_equipment_image(self):
for record in self:
- print('111')
if record.cutting_tool_integral_model_id:
print(record.cutting_tool_integral_model_id)
record.sudo().suitable_machining_method_ids = record.cutting_tool_integral_model_id.suitable_machining_method_ids.ids
diff --git a/sf_tool_management/models/functional_tool_enroll.py b/sf_tool_management/models/functional_tool_enroll.py
index 2d2941f5..b14ce16b 100644
--- a/sf_tool_management/models/functional_tool_enroll.py
+++ b/sf_tool_management/models/functional_tool_enroll.py
@@ -25,29 +25,24 @@ class StockLot(models.Model):
val = {
'name': item.name,
'tool_material_status': item.tool_material_status,
- 'location': item.quant_ids[-1].location_id.name,
- 'tool_material_search_code': item.tool_material_search_id.code,
+ 'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
+ 'tool_material_search_id': item.tool_material_search_id.id,
}
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:
+ if ret.get('code') == 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 == '刀具':
+ if record.product_id.categ_id.name == '刀具':
+ record.tool_material_status = '可用'
record.enroll_tool_material_stock()
return records
@@ -74,11 +69,11 @@ class ToolMaterial(models.Model):
barcode_names.append(barcode_id.name)
val = {
'name': item.name,
- 'code': item.code,
+ 'id': item.id,
'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,
+ 'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
'number': item.number,
'usable_num': item.usable_num,
'have_been_used_num': item.have_been_used_num,
@@ -95,6 +90,14 @@ class ToolMaterial(models.Model):
else:
raise UserError("没有注册刀具物料信息")
+ @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):
_inherit = 'sf.functional.cutting.tool.entity'
@@ -113,6 +116,18 @@ class FunctionalCuttingToolEntity(models.Model):
functional_tool_list = []
if objs_all:
for item in objs_all:
+ suitable_machining_method_names = []
+ cutting_direction_names = []
+ suitable_coolant_names = []
+ for suitable_machining_method_id in item.suitable_machining_method_ids:
+ if suitable_machining_method_id:
+ suitable_machining_method_names.append(suitable_machining_method_id.name)
+ for cutting_direction_id in item.cutting_direction_ids:
+ if cutting_direction_id:
+ cutting_direction_names.append(cutting_direction_id.name)
+ for suitable_coolant_id in item.suitable_coolant_ids:
+ if suitable_coolant_id:
+ suitable_coolant_names.append(suitable_coolant_id.name)
val = {
'id': item.id,
'code': item.code,
@@ -143,21 +158,24 @@ class FunctionalCuttingToolEntity(models.Model):
'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,
+ 'cutting_tool_integral_model_id': item.cutting_tool_integral_model_id.tool_material_id,
+ 'cutting_tool_blade_model_id': item.cutting_tool_blade_model_id.tool_material_id,
+ 'cutting_tool_cutterbar_model_id': item.cutting_tool_cutterbar_model_id.tool_material_id,
+ 'cutting_tool_cutterpad_model_id': item.cutting_tool_cutterpad_model_id.tool_material_id,
+ 'cutting_tool_cutterhandle_model_id': item.cutting_tool_cutterhandle_model_id.tool_material_id,
+ 'cutting_tool_cutterhead_model_id': item.cutting_tool_cutterhead_model_id.tool_material_id,
+ 'suitable_machining_method_names': suitable_machining_method_names,
+ 'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name,
+ 'handle_type_name': item.handle_type_id.name,
+ 'cutting_direction_names': cutting_direction_names,
+ 'suitable_coolant_names': suitable_coolant_names,
'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:
+ if ret.get('code') == 200:
return "功能刀具注册成功"
else:
raise UserError("没有注册功能刀具信息")
@@ -192,6 +210,7 @@ class FunctionalToolWarning(models.Model):
'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,
@@ -218,9 +237,7 @@ class FunctionalToolWarning(models.Model):
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:
+ if ret.get('code') == 200:
return "功能刀具预警注册成功"
else:
raise UserError("没有注册功能刀具预警信息")
@@ -255,6 +272,7 @@ class StockMoveLine(models.Model):
'id': item.id,
'name': item.functional_tool_name_id.name,
'code': item.code,
+ 'rfid': item.rfid,
'tool_groups_name': item.tool_groups_id.name,
'reference': item.reference,
'barcode': item.lot_id.name,
@@ -271,9 +289,7 @@ class StockMoveLine(models.Model):
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:
+ if ret.get('code') == 200:
return "功能刀具出入库记录注册成功"
else:
raise UserError("没有注册功能刀具出入库记录信息")
@@ -310,8 +326,9 @@ class RealTimeDistributionFunctionalTools(models.Model):
val = {
'id': item.id,
'name': item.name,
+ 'rfid': item.rfid,
'tool_groups_name': item.tool_groups_id.name,
- 'sf_cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
+ '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,
@@ -332,9 +349,7 @@ class RealTimeDistributionFunctionalTools(models.Model):
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:
+ if ret.get('code') == 200:
return "功能刀具出入库记录注册成功"
else:
raise UserError("没有注册功能刀具出入库记录信息")
@@ -344,10 +359,5 @@ class RealTimeDistributionFunctionalTools(models.Model):
records = super(RealTimeDistributionFunctionalTools, self).create(vals_list)
for record in records:
if record.functional_tool_name_id:
- record.enroll_functional_tool_move()
+ record.enroll_functional_tool_real_time_distribution()
return records
-
- def write(self, vals):
- res = super().write(vals)
- self.enroll_functional_tool_move()
- return res
diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py
index 4fbf0b9e..0dca8868 100644
--- a/sf_tool_management/models/maintenance_equipment.py
+++ b/sf_tool_management/models/maintenance_equipment.py
@@ -109,6 +109,8 @@ class StockLot(models.Model):
record.tool_material_status = '在用'
else:
record.tool_material_status = '可用'
+ # 注册刀具物料状态到cloud平台
+ record.enroll_tool_material_stock()
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
@@ -137,9 +139,7 @@ class StockLot(models.Model):
for record in records:
if record.product_id.categ_id.name == '刀具':
tool_material_search = self.env['sf.tool.material.search'].sudo().search(
- [('cutting_tool_material_id', '=', record.product_id.cutting_tool_material_id.id),
- ('cutting_tool_standard_library_id', '=', record.product_id.cutting_tool_model_id.id),
- ('specification_id', '=', record.product_id.specification_id.id)])
+ [('id', '=', record.product_id.tool_material_id)])
if tool_material_search:
record.tool_material_search_id = tool_material_search
return records
@@ -148,12 +148,15 @@ class StockLot(models.Model):
class ProductProduct(models.Model):
_inherit = 'product.product'
+ tool_material_id = fields.Char('刀具物料搜索模型ID')
+
@api.model_create_multi
def create(self, vals_list):
records = super(ProductProduct, self).create(vals_list)
for record in records:
if record.categ_id.name == '刀具':
- self.env['sf.tool.material.search'].sudo().create({
+ tool_material = self.env['sf.tool.material.search'].sudo().create({
'product_id': record.id
})
+ record.tool_material_id = tool_material.id
return records
diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py
index 1812c489..547bae32 100644
--- a/sf_tool_management/models/tool_material_search.py
+++ b/sf_tool_management/models/tool_material_search.py
@@ -311,7 +311,7 @@ class ToolMaterial(models.Model):
product_id = fields.Many2one('product.product', string='刀具物料产品')
name = fields.Char('名称', related='product_id.name')
- code = fields.Char('编码', compute='_compute_code', store=True)
+ code = fields.Char('编码')
cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料',
related='product_id.cutting_tool_material_id',
store=True,
@@ -331,14 +331,6 @@ 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 0c44bba5f2b8314d4895b043fb9416c01c5a5b21 Mon Sep 17 00:00:00 2001
From: "jinling.yang"
Date: Tue, 12 Mar 2024 17:32:40 +0800
Subject: [PATCH 12/15] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E4=BA=A7=E5=93=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_base/models/tool_base_new.py | 23 +-
sf_base/models/tool_other_features.py | 3 +-
sf_base/views/tool_basic_param.xml | 289 +++++++++++-------
sf_base/views/tool_views.xml | 8 +-
.../product_template_management_view.xml | 6 +-
sf_manufacturing/models/product_template.py | 58 ++--
sf_sale/models/auto_quatotion_common.py | 2 +-
sf_sale/models/quick_easy_order.py | 4 +-
sf_sale/models/sale_order.py | 4 +-
9 files changed, 238 insertions(+), 159 deletions(-)
diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py
index 03a3678b..7e87e3df 100644
--- a/sf_base/models/tool_base_new.py
+++ b/sf_base/models/tool_base_new.py
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
-import json
-import requests
+from datetime import date
from odoo import fields, models, api
-from odoo.exceptions import ValidationError
-from odoo.addons.sf_base.commons.common import Common
class CuttingToolMaterial(models.Model):
@@ -113,6 +110,24 @@ class CuttingToolModel(models.Model):
feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz(整体式刀具)')
feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz(刀片)')
material_model_id = fields.Many2one('sf.materials.model', '材料型号')
+
+ @api.onchange('cutting_tool_material_id')
+ def _get_code(self):
+ if self.is_cloud is False:
+ today = date.today().strftime("%Y%m%d")
+ today_code = 'T-DJWL-%s-%s' % (self.cutting_tool_material_id.code, today)
+ cutting_tool_model = self.search(
+ [('code', 'ilike', today_code), ('is_cloud', '=', False),
+ ('active', 'in', [True, False])],
+ limit=1,
+ order="id desc")
+ if not cutting_tool_model:
+ num = "%03d" % 1
+ else:
+ m = int(today_code[-3:]) + 1
+ num = "%03d" % m
+ return "%s%s" % (today_code, num)
+
# 适用夹头型号可以多选
# chuck_ids = fields.Many2many(
# 'sf.cutting_tool.standard.library',
diff --git a/sf_base/models/tool_other_features.py b/sf_base/models/tool_other_features.py
index 7ad32bc2..ee83735b 100644
--- a/sf_base/models/tool_other_features.py
+++ b/sf_base/models/tool_other_features.py
@@ -10,6 +10,7 @@ class ToolMaterialsBasicParameters(models.Model):
standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具标准库')
cutting_tool_type = fields.Char(related='standard_library_id.cutting_tool_type', string='刀具物料类型',
store=True)
+ is_cloud = fields.Boolean(related='standard_library_id.is_cloud', string='云端数据')
# 整体式刀具参数
total_length = fields.Float('总长度(mm)')
@@ -170,8 +171,6 @@ class FeedPerTooth(models.Model):
feed_per_tooth = fields.Char('每齿走刀量 (mm/z)', size=20)
active = fields.Boolean(string='有效', default=True)
-
-
# @api.depends('product_template_id')
# def _compute_product_template_id(self):
# if self.product_template_id is not None:
diff --git a/sf_base/views/tool_basic_param.xml b/sf_base/views/tool_basic_param.xml
index 616905ca..f73bf71c 100644
--- a/sf_base/views/tool_basic_param.xml
+++ b/sf_base/views/tool_basic_param.xml
@@ -1,132 +1,189 @@
-
-
- sf.tool.materials.basic.parameters.tree
- sf.tool.materials.basic.parameters
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ sf.tool.materials.basic.parameters.tree
+ sf.tool.materials.basic.parameters
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- sf.tool.materials.basic.parameters.tree
- sf.tool.materials.basic.parameters
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ sf.tool.materials.basic.parameters.tree
+ sf.tool.materials.basic.parameters
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- sf.tool.materials.basic.parameters.tree
- sf.tool.materials.basic.parameters
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ sf.tool.materials.basic.parameters.tree
+ sf.tool.materials.basic.parameters
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- sf.tool.materials.basic.parameters.tree
- sf.tool.materials.basic.parameters
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ sf.tool.materials.basic.parameters.tree
+ sf.tool.materials.basic.parameters
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- sf.tool.materials.basic.parameters.search
- sf.tool.materials.basic.parameters
-
-
-
-
-
-
+
+ sf.tool.materials.basic.parameters.search
+ sf.tool.materials.basic.parameters
+
+
+
+
+
+
-
- 基础参数
- sf.tool.materials.basic.parameters
- tree
+
+ sf.tool.materials.basic.parameters.form
+ sf.tool.materials.basic.parameters
+
+
+
+
-
- []
-
-
+
+ 基础参数
+ sf.tool.materials.basic.parameters
+ form
+ {'default_cutting_tool_type': cutting_tool_type}
+ []
+
+
diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml
index d1c0c510..a9604773 100644
--- a/sf_base/views/tool_views.xml
+++ b/sf_base/views/tool_views.xml
@@ -123,7 +123,7 @@