[FIX] stock: unlink scrap

Forbids to unlink a done scrap.

opw-746294
This commit is contained in:
Nicolas Martinelli
2017-06-07 14:26:03 +02:00
parent c638fbdf23
commit 7b21016760
2 changed files with 13 additions and 1 deletions
+7 -1
View File
@@ -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 ""
+6
View File
@@ -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)