diff --git a/yuthon_purchase/models/inherit_purchase_order.py b/yuthon_purchase/models/inherit_purchase_order.py index 61eac7e4e..ec4cab94c 100644 --- a/yuthon_purchase/models/inherit_purchase_order.py +++ b/yuthon_purchase/models/inherit_purchase_order.py @@ -86,6 +86,29 @@ class InheritPurchaseOrder(models.Model): else: record.display_end_time = record.write_date + @api.depends('picking_ids', 'picking_ids.receipt_status', 'picking_ids.picking_type_code') + def _compute_picking_receipt_state(self): + """根据关联入库单的 receipt_status 计算入库状态。 + + 只考虑入库类型的调拨(picking_type_code == 'incoming'): + - 任一为 receipt → 已入库 + - 否则任一为 certification → 证明入库 + - 否则任一为 acceptance → 待验收 + - 否则为空 + """ + for order in self: + state = False + incoming_pickings = order.picking_ids.filtered(lambda p: p.picking_type_code == 'incoming') + if incoming_pickings: + statuses = set(incoming_pickings.mapped('receipt_status')) + if 'receipt' in statuses: + state = 'done' + elif 'certification' in statuses: + state = 'certification' + elif 'acceptance' in statuses: + state = 'waiting' + order.picking_receipt_state = state + @api.depends_context('uid', 'company') @api.depends('company_id') def _compute_is_company(self): diff --git a/yuthon_purchase/views/inherit_purchase_order_views.xml b/yuthon_purchase/views/inherit_purchase_order_views.xml index b98b9872e..64ea56edc 100644 --- a/yuthon_purchase/views/inherit_purchase_order_views.xml +++ b/yuthon_purchase/views/inherit_purchase_order_views.xml @@ -40,6 +40,14 @@ + + + + +