diff --git a/yuthon_stock/models/inherit_stock_picking.py b/yuthon_stock/models/inherit_stock_picking.py index 70bcc7076..0baebbf65 100644 --- a/yuthon_stock/models/inherit_stock_picking.py +++ b/yuthon_stock/models/inherit_stock_picking.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from odoo import api, fields, models +from odoo.exceptions import UserError import json @@ -276,6 +277,20 @@ class StockPicking(models.Model): } } + def action_revoke_receipt(self): + """撤回入库:仅系统管理员可操作,将入库状态回退到证明状态""" + self.ensure_one() + if not self.env.user.has_group('base.group_system'): + raise UserError('只有系统管理员才能撤回入库!') + if self.receipt_status != 'receipt': + raise UserError('只有入库状态才能撤回!') + self.write({ + 'receipt_status': 'certification', + 'certifier_id': False, + 'certification_date': False, + }) + return True + def action_acceptance(self): """验收按钮:自动填充验收人和验收时间""" self.ensure_one() diff --git a/yuthon_stock/views/inherit_stock_picking.xml b/yuthon_stock/views/inherit_stock_picking.xml index b0d99a975..03388a1af 100644 --- a/yuthon_stock/views/inherit_stock_picking.xml +++ b/yuthon_stock/views/inherit_stock_picking.xml @@ -32,6 +32,9 @@