diff --git a/stock_usability/stock.py b/stock_usability/stock.py index ea2f3cb..490745f 100644 --- a/stock_usability/stock.py +++ b/stock_usability/stock.py @@ -31,6 +31,13 @@ class StockPicking(models.Model): pick.message_post(_("Using Force Availability!")) return res + @api.multi + def do_unreserve(self): + res = super(StockPicking, self).do_unreserve() + for pick in self: + pick.message_post(_("Picking unreserved.")) + return res + class StockLocation(models.Model): _inherit = 'stock.location' @@ -115,6 +122,22 @@ class StockMove(models.Model): res.append((line.id, name)) return res + def button_do_unreserve(self): + for move in self: + move.do_unreserve() + if move.picking_id: + product = move.product_id + self.picking_id.message_post(_( + "Product %s qty %s %s unreserved") + % (product.id, product.display_name, + move.product_qty, move.product_id.uom_id.name)) + ops = self.env['stock.pack.operation'] + for smol in move.linked_move_operation_ids: + if smol.operation_id: + ops += smol.operation_id + ops.unlink() + class StockIncoterms(models.Model): _inherit = 'stock.incoterms' diff --git a/stock_usability/stock_view.xml b/stock_usability/stock_view.xml index 50a0d16..3e5bb3a 100644 --- a/stock_usability/stock_view.xml +++ b/stock_usability/stock_view.xml @@ -114,14 +114,11 @@ stock.move - + @@ -152,6 +149,11 @@ stock.move + +