From 7b210167604d4450d0b52dfddd39ca3ccc672564 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 6 Jun 2017 20:25:59 +0200 Subject: [PATCH] [FIX] stock: unlink scrap Forbids to unlink a done scrap. opw-746294 --- addons/stock/i18n/stock.pot | 8 +++++++- addons/stock/models/stock_scrap.py | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index e7182b88541..e01b6291165 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -6566,7 +6566,13 @@ msgid "You cannot cancel a stock move that has been set to 'Done'." msgstr "" #. module: stock -#: code:addons/stock/models/stock_inventory.py:352 +#: code:addons/stock/models/stock_scrap.py:72 +#, python-format +msgid "You cannot delete a scrap which is done." +msgstr "" + +#. module: stock +#: code:addons/stock/models/stock_inventory.py:374 #, python-format msgid "You cannot have two inventory adjustements in state 'in Progess' with the same product(%s), same location(%s), same package, same owner and same lot. Please first validatethe first inventory adjustement with this product before creating another one." msgstr "" diff --git a/addons/stock/models/stock_scrap.py b/addons/stock/models/stock_scrap.py index 355f0139d04..16be4d9b73b 100644 --- a/addons/stock/models/stock_scrap.py +++ b/addons/stock/models/stock_scrap.py @@ -66,6 +66,12 @@ class StockScrap(models.Model): scrap.do_scrap() return scrap + @api.multi + def unlink(self): + if 'done' in self.mapped('state'): + raise UserError(_('You cannot delete a scrap which is done.')) + return super(StockScrap, self).unlink() + def _get_origin_moves(self): return self.picking_id and self.picking_id.move_lines.filtered(lambda x: x.product_id == self.product_id)