From 3acb4a53892e22efdcb406050abea2d733a6e67f Mon Sep 17 00:00:00 2001 From: len-odoo Date: Tue, 24 Apr 2018 08:41:10 +0200 Subject: [PATCH] [FIX] stock: allow inventory user to validate delivery orders when moves have to be merged When validating a delivery order, some stock moves might be merged by an internal function, which thus might delete some stock moves. Since an inventory user has no right to unlink stock moves, the validation might fail. We simply had a sudo when doing the unlink, since this is an external method. opw 1836761 --- addons/stock/models/stock_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 78c2d99540a..d729b2f7a0f 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -593,7 +593,7 @@ class StockMove(models.Model): # We are using propagate to False in order to not cancel destination moves merged in moves[0] moves_to_unlink.write({'propagate': False}) moves_to_unlink._action_cancel() - moves_to_unlink.unlink() + moves_to_unlink.sudo().unlink() return (self | self.env['stock.move'].concat(*moves_to_merge)) - moves_to_unlink def _get_relevant_state_among_moves(self):