+ options="{'no_create': True}" attrs="{‘readonly': [('state', '=', '已拆解')]}"/>
@@ -807,76 +812,103 @@
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/sf_tool_management/views/tool_material_search.xml b/sf_tool_management/views/tool_material_search.xml
index ee63ba26..d4772244 100644
--- a/sf_tool_management/views/tool_material_search.xml
+++ b/sf_tool_management/views/tool_material_search.xml
@@ -94,12 +94,5 @@
sf.tool.material.search
tree,form
-
From 8bc23f5136a4063db6abcedefd8d8ca2f2c0cb8d Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Tue, 23 Apr 2024 14:15:45 +0800
Subject: [PATCH 3/4] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E6=8B=86=E8=A7=A3=E5=8D=95=E6=8B=86?=
=?UTF-8?q?=E8=A7=A3=E5=8E=9F=E5=9B=A0=E4=B8=BA=E6=9B=B4=E6=8D=A2=E5=85=B6?=
=?UTF-8?q?=E4=BB=96=E5=88=80=E5=85=B7=E6=97=B6=E7=9A=84=E6=89=AB=E7=A0=81?=
=?UTF-8?q?=E5=BD=95=E5=85=A5=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E8=B4=A7?=
=?UTF-8?q?=E4=BD=8D=E4=BF=A1=E6=81=AF=E5=8A=9F=E8=83=BD=EF=BC=9B2?=
=?UTF-8?q?=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E6=8B=86=E8=A7=A3=E5=8D=95=E7=A1=AE=E8=AE=A4=E6=8B=86=E8=A7=A3?=
=?UTF-8?q?=E5=90=8E=E7=9A=84=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E6=8B=86?=
=?UTF-8?q?=E8=A7=A3=E6=B5=81=E7=A8=8B=EF=BC=8C=E5=8F=8A=E5=85=B6=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=89=A9=E6=96=99=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E7=9A=84=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1=E7=AD=89=EF=BC=9B?=
=?UTF-8?q?3=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E6=8B=86?=
=?UTF-8?q?=E8=A7=A3=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E6=A8=A1?=
=?UTF-8?q?=E5=9D=97=E6=B7=BB=E5=8A=A0=E5=8A=A8=E4=BD=9C=E8=BF=87=E6=BB=A4?=
=?UTF-8?q?=E5=B7=B2=E6=8B=86=E8=A7=A3=E7=8A=B6=E6=80=81=E7=9A=84=E8=AE=B0?=
=?UTF-8?q?=E5=BD=95=EF=BC=8C=E5=B9=B6=E6=B7=BB=E5=8A=A0=E7=AD=9B=E9=80=89?=
=?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=9B4=E3=80=81=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E6=B5=81=E7=A8=8B=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E8=B4=A7=E4=BD=8D?=
=?UTF-8?q?=E6=95=B0=E9=87=8F=E6=A0=A1=E9=AA=8C=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 79 +++++++++++++------
sf_tool_management/models/functional_tool.py | 11 ++-
.../models/maintenance_equipment.py | 2 +
.../models/tool_material_search.py | 4 +-
.../views/functional_tool_views.xml | 10 ++-
sf_tool_management/views/tool_base_views.xml | 31 +++++---
sf_tool_management/wizard/wizard.py | 35 ++++----
sf_tool_management/wizard/wizard_view.xml | 2 +-
8 files changed, 114 insertions(+), 60 deletions(-)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 350658a4..43baaab5 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -647,33 +647,56 @@ class FunctionalToolDismantle(models.Model):
"""
# 对barcode进行校验是否为货位编码
if not re.match(r'^[A-Za-z0-9]+-[A-Za-z0-9]+-\d{3}-\d{3}$', barcode):
- tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search([('rfid', '=', barcode)])
+ tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
+ [('rfid', '=', barcode), ('functional_tool_status', '!=', '已拆除')])
if tool_id:
self.functional_tool_id = tool_id.id
else:
raise ValidationError('Rfid为【%s】的功能刀具不存在,请重新扫描!' % barcode)
else:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', barcode)])
- if not location:
- raise ValidationError('【%s】该货位不存在,请重新扫码!' % barcode)
- else:
- # 判断是否有夹头物料
- if not self.chuck_product_id:
- # 判断是否有整体式刀具物料
- if self.integral_product_id:
- # 判断货位是否为空货位 或者 是存有整体式刀具的货位
- if location.product_id in [False, self.integral_product_id]:
- self.integral_freight_id = location.id
- else:
- raise ValidationError('【%s】该货位已存在【%s】产品,请重新扫码!' % location.barcode,
- location.product_id.name)
- # 判断是否有刀片物料
- elif self.blade_product_id:
- # 判断是否有刀杆物料
- if self.bar_product_id:
- pass
+ if self.dismantle_cause == '更换为其他刀具':
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', barcode)])
+ if not location:
+ raise ValidationError('【%s】该货位不存在,请重新扫码!' % barcode)
else:
- pass
+ if not location.product_id:
+ # 判断功能刀具存在哪些刀具物料需要录入库位
+ if self.chuck_product_id: # 夹头
+ if not self.chuck_freight_id:
+ self.chuck_freight_id = location.id
+ return True
+ if self.integral_product_id: # 整体式刀具
+ if not self.integral_freight_id:
+ self.integral_freight_id = location.id
+ return True
+ elif self.blade_product_id: # 刀片
+ if not self.blade_freight_id:
+ self.blade_freight_id = location.id
+ return True
+ if self.bar_product_id: # 刀杆
+ if not self.bar_freight_id:
+ self.bar_freight_id = location.id
+ return True
+ elif self.pad_product_id: # 刀盘
+ if not self.pad_freight_id:
+ self.pad_freight_id = location.id
+ return True
+ else:
+ # 判断货位存放的是那个刀具物料产品
+ if self.integral_product_id == location.product_id: # 整体式刀具
+ self.integral_freight_id = location.id
+ elif self.blade_product_id == location.product_id: # 刀片
+ self.blade_freight_id = location.id
+ elif self.bar_product_id == location.product_id: # 刀杆
+ self.bar_freight_id = location.id
+ elif self.pad_product_id == location.product_id: # 刀盘
+ self.pad_freight_id = location.id
+ elif self.chuck_product_id == location.product_id: # 夹头
+ self.chuck_freight_id = location.id
+ elif self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
+ raise ValidationError('该功能刀具因为%s拆解,无需录入库位' % self.dismantle_cause)
+ else:
+ raise ValidationError('该功能刀具因为%s拆解,无需录入库位' % self.dismantle_cause)
name = fields.Char('名称', related='functional_tool_id.name')
@@ -698,6 +721,7 @@ class FunctionalToolDismantle(models.Model):
grinding_id = fields.Char('磨削单号', readonly=True)
state = fields.Selection([('待拆解', '待拆解'), ('已拆解', '已拆解')], default='待拆解')
+ active = fields.Boolean('有效', default=True)
# 刀柄
handle_product_id = fields.Many2one('product.product', string='刀柄', compute='_compute_functional_tool_num',
@@ -787,22 +811,24 @@ class FunctionalToolDismantle(models.Model):
item.chuck_product_id = False
def confirmation_disassembly(self):
- logging.info('%s刀具确认拆解' % self.dismantle_cause)
+ logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
+ if self.functional_tool_id.functional_tool_status == '已拆除':
+ raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
# =================刀柄是否报废拆解=======
location_dest_scrap = self.env['stock.location'].search([('name', '=', 'Scrap')])
if self.handle_rfid:
- lot = self.env['stock.lot'].sudo().search([('name', '=', self.handle_rfid)])
+ lot = self.env['stock.lot'].sudo().search([('rfid', '=', self.handle_rfid)])
functional_tool_assembly = self.functional_tool_id.functional_tool_name_id
if self.scrap_boolean:
# 刀柄报废 入库到Scrap
lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, '功能刀具拆解',
- functional_tool_assembly)
+ functional_tool_assembly, functional_tool_assembly.tool_groups_id)
else:
# 刀柄不报废 入库到刀具房
lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, '功能刀具拆解',
- functional_tool_assembly)
+ functional_tool_assembly, functional_tool_assembly.tool_groups_id)
# ==============功能刀具报废拆解================
if self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
# 除刀柄外物料报废 入库到Scrap
@@ -853,9 +879,12 @@ class FunctionalToolDismantle(models.Model):
# 修改拆解单的值
self.write({
'rfid_dismantle': self.rfid,
+ 'dismantle_data': fields.Datetime.now(),
+ 'dismantle_person': self.env.user.name,
'rfid': '',
'state': '已拆解'
})
+ logging.info('刀具拆解成功!')
class ProductProduct(models.Model):
diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py
index d4718f34..eae00080 100644
--- a/sf_tool_management/models/functional_tool.py
+++ b/sf_tool_management/models/functional_tool.py
@@ -45,7 +45,7 @@ class FunctionalCuttingToolEntity(models.Model):
active = fields.Boolean(string='已归档', default=True)
- @api.depends('barcode_id.quant_ids')
+ @api.depends('barcode_id.quant_ids', 'functional_tool_status')
def _compute_current_location_id(self):
for record in self:
if record.barcode_id.quant_ids:
@@ -61,6 +61,12 @@ class FunctionalCuttingToolEntity(models.Model):
else:
record.current_location_id = False
record.current_location = False
+ if record.functional_tool_status == '已拆除':
+ record.current_location_id = False
+ record.current_location = False
+ record.tool_room_num = 0
+ record.line_edge_knife_library_num = 0
+ record.machine_knife_library_num = 0
def get_location_num(self):
"""
@@ -185,7 +191,8 @@ class FunctionalCuttingToolEntity(models.Model):
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, '机床装刀', self.functional_tool_name_id)
+ self.functional_tool_name_id.id, '机床装刀', self.functional_tool_name_id,
+ self.functional_tool_name_id.tool_groups_id)
# ==========刀具组接口==========
# def _register_functional_tool_groups(self, obj):
diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py
index d39dc685..4452f768 100644
--- a/sf_tool_management/models/maintenance_equipment.py
+++ b/sf_tool_management/models/maintenance_equipment.py
@@ -112,6 +112,8 @@ class StockLot(models.Model):
record.tool_material_status = '可用'
elif record.quant_ids[-1].location_id.name == '刀具组装位置':
record.tool_material_status = '在用'
+ elif record.quant_ids[-1].location_id.name == 'Scrap':
+ record.tool_material_status = '报废'
else:
record.tool_material_status = '未入库'
if record.tool_material_search_id:
diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py
index bfb8d64b..ee60c048 100644
--- a/sf_tool_management/models/tool_material_search.py
+++ b/sf_tool_management/models/tool_material_search.py
@@ -39,9 +39,7 @@ class ToolMaterial(models.Model):
usable_num += quant.quantity
elif location == '刀具组装位置':
have_been_used_num += quant.quantity
- elif location == '进货':
- pass
- elif location != 'Vendors':
+ elif location == 'Scrap':
scrap_num += quant.quantity
record.usable_num = usable_num
record.have_been_used_num = have_been_used_num
diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml
index 82fbd8bc..53e050d9 100644
--- a/sf_tool_management/views/functional_tool_views.xml
+++ b/sf_tool_management/views/functional_tool_views.xml
@@ -85,7 +85,10 @@
-
+
+
@@ -202,6 +205,9 @@
+
+
+
@@ -218,6 +224,8 @@
sf.functional.cutting.tool.entity
tree,form,search
+
+ {'search_default_no_state_removed':1}
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index 944decd2..1db89ddb 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -783,6 +783,7 @@
+