diff --git a/yuthon_stock/models/__init__.py b/yuthon_stock/models/__init__.py
index b756e8246..fd8656311 100644
--- a/yuthon_stock/models/__init__.py
+++ b/yuthon_stock/models/__init__.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from . import inherit_stock_picking
from . import Inherit_stock_picking_type
-from . import inherit_stock_location
\ No newline at end of file
+from . import inherit_stock_location
+from . import inherit_stock_move
\ No newline at end of file
diff --git a/yuthon_stock/models/inherit_stock_move.py b/yuthon_stock/models/inherit_stock_move.py
new file mode 100644
index 000000000..8b1978895
--- /dev/null
+++ b/yuthon_stock/models/inherit_stock_move.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from odoo import models, fields, api
+
+
+class ProductProduct(models.Model):
+ _inherit = 'product.product'
+
+ display_name = fields.Char(
+ string="Display Name",
+ compute='_compute_display_name',
+ store=False
+ )
+
+ @api.depends('name', 'qty_available')
+ def _compute_display_name(self):
+ """计算产品显示名称,包含在手数量"""
+ for record in self:
+ name = record.name or ""
+ qty_available = record.qty_available
+ record.display_name = f"{name} (在手: {qty_available:.2f})"
+
+
+class StockMove(models.Model):
+ _inherit = 'stock.move'
diff --git a/yuthon_stock/models/inherit_stock_picking.py b/yuthon_stock/models/inherit_stock_picking.py
index 809029168..513fca290 100644
--- a/yuthon_stock/models/inherit_stock_picking.py
+++ b/yuthon_stock/models/inherit_stock_picking.py
@@ -28,7 +28,7 @@ class StockPicking(models.Model):
('acceptance', '验收'),
('certification', '证明'),
('receipt', '入库')
- ], string="入库单状态", default='receipt')
+ ], string="入库单状态", default='acceptance')
acceptance_date = fields.Datetime(string="验收时间", readonly=True)
certification_date = fields.Datetime(string="证明时间", readonly=True)
json_display = fields.Char(
@@ -36,6 +36,24 @@ class StockPicking(models.Model):
compute='_compute_json_display',
store=True
)
+ available_product_ids = fields.Many2many(
+ 'product.product',
+ compute='_compute_available_product_ids',
+ string="可用产品"
+ )
+
+ @api.depends('location_id')
+ def _compute_available_product_ids(self):
+ """根据仓库计算可用产品列表"""
+ for record in self:
+ if record.location_id:
+ # 查询该仓库中有库存的产品
+ quants = self.env['stock.quant'].search([
+ ('location_id', '=', record.location_id.id)
+ ])
+ record.available_product_ids = quants.mapped('product_id')
+ else:
+ record.available_product_ids = False
@api.onchange('user_id')
def _onchange_user_id(self):
diff --git a/yuthon_stock/views/inherit_stock_picking.xml b/yuthon_stock/views/inherit_stock_picking.xml
index 5d48574f8..2ee3177b1 100644
--- a/yuthon_stock/views/inherit_stock_picking.xml
+++ b/yuthon_stock/views/inherit_stock_picking.xml
@@ -9,11 +9,14 @@
-
+
+
+
{'no_create': True}
+ [('id', 'in', parent.available_product_ids)]
@@ -37,9 +40,11 @@
证明
+ receipt_status != 'certification'
证明
+ receipt_status != 'certification'
1
@@ -56,8 +61,11 @@
供应商
-
-
+
+
+
+
+