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