From 6517d2bd12a5e9d63ca0adc2dedea3dc5f787bd3 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Fri, 13 Jun 2025 10:19:11 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84?=
=?UTF-8?q?=E8=A3=85=E7=82=B9=E3=80=90=E6=9B=B4=E5=A4=9A=E3=80=91=E6=8C=89?=
=?UTF-8?q?=E9=92=AE=E5=BC=B9=E7=AA=97=E7=9A=84=E7=89=A9=E6=96=99=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E3=80=90BOM=E7=89=A9=E6=96=99=E3=80=91=E9=BB=98?=
=?UTF-8?q?=E8=AE=A4=E7=AD=9B=E9=80=89=EF=BC=8C=E6=A0=B9=E6=8D=AEBOM?=
=?UTF-8?q?=E7=AD=9B=E9=80=89=E5=87=BA=E7=AC=A6=E5=90=88=E6=9D=A1=E4=BB=B6?=
=?UTF-8?q?=E7=9A=84=E7=89=A9=E6=96=99=E4=BF=A1=E6=81=AF=EF=BC=9B=E5=8F=96?=
=?UTF-8?q?=E6=B6=88=E9=BB=98=E8=AE=A4=E7=AD=9B=E9=80=89=E5=90=8E=E8=AE=B0?=
=?UTF-8?q?=E5=BD=95=E6=8C=89=E6=BB=A1=E8=B6=B3BOM=E7=9A=84=E5=92=8C?=
=?UTF-8?q?=E4=B8=8D=E6=BB=A1=E8=B6=B3BOM=E7=9A=84=E9=A1=BA=E5=BA=8F?=
=?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=87=BA=E7=8E=B0=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 32 +++++++++----------
sf_tool_management/models/stock.py | 32 +++++++++++++++++++
.../views/functional_tool_views.xml | 1 +
sf_tool_management/views/stock.xml | 18 +++++++++++
4 files changed, 67 insertions(+), 16 deletions(-)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 3cbaf974..ff8f4e6f 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -833,8 +833,8 @@ class FunctionalToolAssembly(models.Model):
location_lots = self.env['sf.shelf.location.lot'].sudo().search([('lot_id', '=', lot_id.id)])
if location_lots:
return location_lots[0]
- raise ValidationError(f'【{lot_ids[0].product_id.cutting_tool_material_id.name}】物料在货位库存不足,请先进行盘点入库')
-
+ raise ValidationError(
+ f'【{lot_ids[0].product_id.cutting_tool_material_id.name}】物料在货位库存不足,请先进行盘点入库')
def _get_inventory_bom(self, inventory_id):
"""获取BOM的刀具物料产品信息"""
@@ -894,25 +894,25 @@ class FunctionalToolAssembly(models.Model):
tool_material_ids = self._get_all_material_location_lot(tool_data.get('pad_ids'))
tool_material_tree_id = self.env.ref('sf_tool_management.view_shelf_location_lot_tree_4')
+ action = {
+ "type": "ir.actions.act_window",
+ "target": "new",
+ "domain": [('cutting_tool_type', '=', tool_type)],
+ "context": {'tool_id': self.id, 'search_default_bom_ids': 1, 'tool_material_ids': tool_material_ids.ids}
+ }
if tool_type == '刀柄':
- return {
- "type": "ir.actions.act_window",
+ action.update({
"res_model": "product.product",
"views": [[tool_material_tree_id.id, "tree"],
- [self.env.ref('sf_tool_management.view_tool_product_search').id, "search"]],
- "target": "new",
- "domain": [('id', 'in', tool_material_ids.ids)],
- "context": {'tool_id': self.id}
- }
+ [self.env.ref('sf_tool_management.view_tool_product_search').id, "search"]]
+ })
elif tool_type in ['整体式刀具', '刀片', '刀杆', '刀盘']:
- return {
- "type": "ir.actions.act_window",
+ action.update({
"res_model": "sf.shelf.location.lot",
- "views": [[tool_material_tree_id.id, "tree"]],
- "target": "new",
- "domain": [('id', 'in', tool_material_ids.ids)],
- "context": {'tool_id': self.id}
- }
+ "views": [[tool_material_tree_id.id, "tree"],
+ [self.env.ref('sf_tool_management.view_shelf_location_lot_search').id, 'search']]
+ })
+ return action
def _get_all_material_location_lot(self, material_ids):
""" 获取所有满足条件 """
diff --git a/sf_tool_management/models/stock.py b/sf_tool_management/models/stock.py
index 92198239..1fc5aa47 100644
--- a/sf_tool_management/models/stock.py
+++ b/sf_tool_management/models/stock.py
@@ -256,6 +256,22 @@ class ProductProduct(models.Model):
})
return stock_lot
+ def search(self, domain, offset=0, limit=None, order=None, count=False):
+ context = self.env.context
+ tool_material_ids = context.get('tool_material_ids')
+ if tool_material_ids:
+ if context.get('default_tool_bom_id'):
+ domain += [('id', 'in', tool_material_ids)]
+ return super(ProductProduct, self).search(domain, offset=0, limit=None, order=None, count=False)
+ else:
+ domain_1 = domain + [('id', 'in', tool_material_ids)]
+ domain_2 = domain + [('id', 'not in', tool_material_ids)]
+ res_1 = super(ProductProduct, self).search(domain_1, offset=0, limit=None, order=None, count=False)
+ res_2 = super(ProductProduct, self).search(domain_2, offset=0, limit=None, order=None, count=False)
+ return res_1 + res_2
+ else:
+ return super(ProductProduct, self).search(domain, offset=0, limit=None, order=None, count=False)
+
def get_stock_lot_name(self, obj):
"""
生成功能刀具序列号
@@ -317,6 +333,22 @@ class SfShelfLocationLot(models.Model):
fit_blade_shape_id = fields.Many2one('maintenance.equipment.image', '适配刀片形状',
related='product_id.fit_blade_shape_id')
+ def search(self, domain, offset=0, limit=None, order=None, count=False):
+ context = self.env.context
+ tool_material_ids = context.get('tool_material_ids')
+ if tool_material_ids:
+ if context.get('default_tool_bom_id'):
+ domain += [('id', 'in', tool_material_ids)]
+ return super(SfShelfLocationLot, self).search(domain, offset=0, limit=None, order=None, count=False)
+ else:
+ domain_1 = domain + [('id', 'in', tool_material_ids)]
+ domain_2 = domain + [('id', 'not in', tool_material_ids)]
+ res_1 = super(SfShelfLocationLot, self).search(domain_1, offset=0, limit=None, order=None, count=False)
+ res_2 = super(SfShelfLocationLot, self).search(domain_2, offset=0, limit=None, order=None, count=False)
+ return res_1 + res_2
+ else:
+ return super(SfShelfLocationLot, self).search(domain, offset=0, limit=None, order=None, count=False)
+
@api.depends('lot_id')
def _compute_product_id(self):
for item in self:
diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml
index a306d6dd..37e520af 100644
--- a/sf_tool_management/views/functional_tool_views.xml
+++ b/sf_tool_management/views/functional_tool_views.xml
@@ -187,6 +187,7 @@
+
diff --git a/sf_tool_management/views/stock.xml b/sf_tool_management/views/stock.xml
index 60e94886..c869817d 100644
--- a/sf_tool_management/views/stock.xml
+++ b/sf_tool_management/views/stock.xml
@@ -33,10 +33,15 @@
+ 刀柄产品搜索视图
product.product
+
+
+
+
@@ -141,4 +146,17 @@
+
+
+ sf.shelf.location.lot.search
+ sf.shelf.location.lot
+
+
+
+
+
+
+
+
+
\ No newline at end of file