From 3882d3a3cb21674bbe80d9a6af2f21c8da7af8d6 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Tue, 4 Jun 2024 11:26:00 +0800
Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E6=8B=86=E8=A7=A3=E5=8D=95=E6=8B=86=E8=A7=A3=E6=B5=81=E7=A8=8B?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9B2=E3=80=81=E4=BC=98=E5=8C=96?=
=?UTF-8?q?=E8=B4=A7=E4=BD=8D=E7=9C=8B=E6=9D=BF=E6=98=BE=E7=A4=BA=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 67 ++++++++++----------
sf_tool_management/views/tool_base_views.xml | 27 ++++----
sf_tool_management/wizard/wizard.py | 12 +---
sf_warehouse/views/shelf_location.xml | 8 +--
4 files changed, 57 insertions(+), 57 deletions(-)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index f763ed4b..e4fdf3ef 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -847,43 +847,48 @@ class FunctionalToolDismantle(models.Model):
if self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
# 除刀柄外物料报废 入库到Scrap
if self.integral_product_id:
- self.integral_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
+ self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location,
+ location_dest_scrap)
elif self.blade_product_id:
- self.blade_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
+ self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, location_dest_scrap)
if self.bar_product_id:
- self.bar_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
+ self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, location_dest_scrap)
elif self.pad_product_id:
- self.pad_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
+ self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, location_dest_scrap)
if self.chuck_product_id:
- self.chuck_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
+ self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, location_dest_scrap)
# ===========功能刀具[磨削]拆解==============
- elif self.dismantle_cause in ['刀具需磨削']:
- location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
- # 除刀柄外物料拆解 入库到具体库位
- if self.integral_product_id:
- self.integral_product_id.dismantle_stock_moves(False, location, location_dest)
- elif self.blade_product_id:
- self.blade_product_id.dismantle_stock_moves(False, location, location_dest)
- if self.bar_product_id:
- self.bar_product_id.dismantle_stock_moves(False, location, location_dest)
- elif self.pad_product_id:
- self.pad_product_id.dismantle_stock_moves(False, location, location_dest)
- if self.chuck_product_id:
- self.chuck_product_id.dismantle_stock_moves(False, location, location_dest)
- # ==============功能刀具[更换]拆解==============
- elif self.dismantle_cause in ['更换为其他刀具']:
- # 除刀柄外物料拆解 入库到具体库位
+ # elif self.dismantle_cause in ['刀具需磨削']:
+ # location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
+ # # 除刀柄外物料拆解 入库到具体库位
+ # if self.integral_product_id:
+ # self.integral_product_id.dismantle_stock_moves(False, location, location_dest)
+ # elif self.blade_product_id:
+ # self.blade_product_id.dismantle_stock_moves(False, location, location_dest)
+ # if self.bar_product_id:
+ # self.bar_product_id.dismantle_stock_moves(False, location, location_dest)
+ # elif self.pad_product_id:
+ # self.pad_product_id.dismantle_stock_moves(False, location, location_dest)
+ # if self.chuck_product_id:
+ # self.chuck_product_id.dismantle_stock_moves(False, location, location_dest)
+ # ==============功能刀具[更换,磨削]拆解==============
+ elif self.dismantle_cause in ['更换为其他刀具', '刀具需磨削']:
+ # 除刀柄外物料拆解 入库到具体货位
if self.integral_freight_id:
- self.integral_product_id.dismantle_stock_moves(self.integral_freight_id.barcode, location,
+ self.integral_product_id.dismantle_stock_moves(self.integral_freight_id, self.integral_lot_id, location,
location_dest)
elif self.blade_freight_id:
- self.blade_product_id.dismantle_stock_moves(self.blade_freight_id.barcode, location, location_dest)
+ self.blade_product_id.dismantle_stock_moves(self.blade_freight_id, self.blade_lot_id, location,
+ location_dest)
if self.bar_freight_id:
- self.bar_product_id.dismantle_stock_moves(self.bar_freight_id.barcode, location, location_dest)
+ self.bar_product_id.dismantle_stock_moves(self.bar_freight_id, self.bar_lot_id, location,
+ location_dest)
elif self.pad_freight_id:
- self.pad_product_id.dismantle_stock_moves(self.pad_freight_id.barcode, location, location_dest)
+ self.pad_product_id.dismantle_stock_moves(self.pad_freight_id, self.pad_lot_id, location,
+ location_dest)
if self.chuck_freight_id:
- self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id.barcode, location, location_dest)
+ self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id, self.chuck_lot_id, location,
+ location_dest)
# ===============删除功能刀具的Rfid字段的值, 赋值给Rfid(已拆解)字段=====
self.functional_tool_id.write({
'rfid_dismantle': self.functional_tool_id.rfid,
@@ -904,7 +909,7 @@ class FunctionalToolDismantle(models.Model):
class ProductProduct(models.Model):
_inherit = 'product.product'
- def dismantle_stock_moves(self, shelf_location_barcode, location_id, location_dest_id):
+ def dismantle_stock_moves(self, shelf_location_id, lot_id, location_id, location_dest_id):
# 创建功能刀具拆解单产品库存移动记录
stock_move_id = self.env['stock.move'].sudo().create({
'name': '功能刀具拆解',
@@ -914,16 +919,12 @@ class ProductProduct(models.Model):
'product_uom_qty': 1.00,
'state': 'done'
})
- if shelf_location_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)])
- location.product_num = location.product_num + 1
- else:
- location = self.env['sf.shelf.location']
# 创建移动历史记录
stock_move_line_id = self.env['stock.move.line'].sudo().create({
'product_id': self.id,
+ 'lot_id': lot_id.id,
'move_id': stock_move_id.id,
- 'current_location_id': location.id,
+ 'destination_location_id': shelf_location_id.id,
'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0,
'state': 'done',
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index cc9d4cd9..7e74b8fc 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -847,8 +847,8 @@
-
+
@@ -861,11 +861,12 @@
-
-
+
@@ -877,11 +878,12 @@
-
-
+
@@ -893,11 +895,12 @@
-
-
+
@@ -907,11 +910,12 @@
-
-
+
@@ -921,11 +925,12 @@
-
-
+
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index 1789ffab..05bf6189 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -335,8 +335,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# =================夹头型号==============
chuck_freight_barcode_id = fields.Many2one('sf.shelf.location', string='夹头货位',
- domain="[('product_id.cutting_tool_material_id.name', '=', '刀盘'),('product_num', '>', 0)]")
- chuck_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀盘批次',
+ domain="[('product_id.cutting_tool_material_id.name', '=', '夹头'),('product_num', '>', 0)]")
+ chuck_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='夹头批次',
domain="[('shelf_location_id', '=', chuck_freight_barcode_id)]")
chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id',
store=True)
@@ -826,18 +826,12 @@ class ProductProduct(models.Model):
stock_move_line_id = self.env['stock.move.line'].sudo().create({
'product_id': self.id,
'move_id': stock_move_id.id,
- 'lot_id': lot_id.id,
+ 'lot_id': lot_id.lot_id.id,
'current_location_id': shelf_location_barcode_id.id,
'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0,
'state': 'done',
})
- if shelf_location_barcode_id.product_num > 0:
- shelf_location_barcode_id.product_num = shelf_location_barcode_id.product_num - 1
- else:
- raise ValidationError(
- '【%s】货位的【%s】产品库存数量为零,请采购入库后再重新组装!' % (
- shelf_location_barcode_id.barcode, shelf_location_barcode_id.product_id.name))
return stock_move_id, stock_move_line_id
diff --git a/sf_warehouse/views/shelf_location.xml b/sf_warehouse/views/shelf_location.xml
index 6fca54f1..2716dd91 100644
--- a/sf_warehouse/views/shelf_location.xml
+++ b/sf_warehouse/views/shelf_location.xml
@@ -172,11 +172,11 @@
-
-
-
-
+
+
+