diff --git a/addons/stock/stock.py b/addons/stock/stock.py index ecf2b3998a7..1c610b1a79f 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -563,6 +563,9 @@ class stock_quant(osv.osv): negative quants. If it's possible, apply the cost of the new quant to the conter-part of the negative quant. """ + context = context or {} + context = dict(context) + context.update({'force_unlink': True}) solving_quant = quant dom = [('qty', '<', 0)] if quant.lot_id: @@ -654,6 +657,12 @@ class stock_quant(osv.osv): raise osv.except_osv(_('Error'), _('You cannot move to a location of type view %s.') % (location.name)) return True + def unlink(self, cr, uid, ids, context=None): + context = context or {} + if not context.get('force_unlink'): + raise osv.except_osv(_('Error!'), _('Under no circumstances should you delete or change quants yourselves!')) + super(stock_quant, self).unlink(cr, uid, ids, context=context) + #---------------------------------------------------------- # Stock Picking #---------------------------------------------------------- diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index a9de687c688..4f752559b5b 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -1666,7 +1666,7 @@ stock.quant -
+
@@ -1692,7 +1692,7 @@ stock.quant - +