From 8a906f80b4120ca96afcc58331e4ef8733be28c6 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 29 Mar 2018 11:50:11 +0200 Subject: [PATCH] [FIX] stock: Inventory Adjustments Deletion It's not allowed to delete inventory adjustement linked to validated moves. opw:1826300 --- addons/stock/i18n/stock.pot | 6 ++++++ addons/stock/models/stock_inventory.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index 559aa1d3b85..e6f8f7478aa 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -6647,6 +6647,12 @@ msgstr "" msgid "You cannot delete a scrap which is done." msgstr "" +#. module: stock +#: code:addons/stock/models/stock_inventory.py:103 +#, python-format +msgid "You cannot delete a validated inventory adjustement." +msgstr "" + #. module: stock #: code:addons/stock/models/stock_inventory.py:374 #, python-format diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index 283dc12ee5f..2f1b757960a 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -96,6 +96,13 @@ class Inventory(models.Model): else: self.total_qty = 0 + @api.multi + def unlink(self): + for inventory in self: + if inventory.state == 'done': + raise UserError(_('You cannot delete a validated inventory adjustement.')) + return super(Inventory, self).unlink() + @api.model def _selection_filter(self): """ Get the list of filter allowed according to the options checked