diff --git a/yuthon_stock/models/inherit_stock_picking.py b/yuthon_stock/models/inherit_stock_picking.py
index 3517bddfa..a6b95e3ec 100644
--- a/yuthon_stock/models/inherit_stock_picking.py
+++ b/yuthon_stock/models/inherit_stock_picking.py
@@ -41,6 +41,40 @@ class StockPicking(models.Model):
compute='_compute_available_product_ids',
string="可用产品"
)
+ can_certify = fields.Boolean(
+ string="可以证明",
+ compute='_compute_can_certify',
+ store=False
+ )
+
+ @api.depends('user_id', 'employee_id')
+ def _compute_can_certify(self):
+ """计算当前用户是否可以证明(不是采购人也不是验收人)"""
+ current_user = self.env.user
+ for record in self:
+ # 如果当前用户是采购人员,不能证明
+ if record.user_id and record.user_id.id == current_user.id:
+ record.can_certify = False
+ continue
+ # 如果当前用户是验收人,不能证明
+ if record.employee_id and record.employee_id.user_id and record.employee_id.user_id.id == current_user.id:
+ record.can_certify = False
+ continue
+ # 其他情况可以证明
+ record.can_certify = True
+
+ def read(self, fields=None, load='_classic_read'):
+ """重写read方法,打开验收状态的入库单时自动更新验收时间"""
+ result = super(StockPicking, self).read(fields, load)
+ # 导入Fields模块
+ from odoo import fields as odoo_fields
+ for record in self:
+ if record.receipt_status == 'acceptance':
+ # 使用write方法更新验收时间
+ record.write({
+ 'acceptance_date': odoo_fields.Datetime.now()
+ })
+ return result
@api.depends('location_id')
def _compute_available_product_ids(self):
diff --git a/yuthon_stock/views/inherit_stock_picking.xml b/yuthon_stock/views/inherit_stock_picking.xml
index 50031241f..da76036bf 100644
--- a/yuthon_stock/views/inherit_stock_picking.xml
+++ b/yuthon_stock/views/inherit_stock_picking.xml
@@ -6,17 +6,20 @@
-
+
+
+
+ receipt_status in ['acceptance', 'certification']
1
-
+
{'no_create': True}
@@ -28,14 +31,14 @@
-
-
-
+
+
+
-
-
-
+
+
+
@@ -44,10 +47,10 @@
证明
- receipt_status != 'certification'
+ receipt_status != 'certification' or not can_certify
- picking_type_code == 'outgoing' or receipt_status == 'acceptance'
+ 1
1
@@ -63,6 +66,10 @@
供应商
+ receipt_status in ['acceptance', 'certification']
+
+
+ receipt_status in ['acceptance', 'certification']
@@ -245,6 +252,10 @@
name="报废"
action="action_stock_picking_scrap"
sequence="15"/>
+
+
+ 收货
+