diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 00dcec250bf..962e19a03de 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1444,6 +1444,20 @@ class stock_move(osv.osv): 'date_expected': time.strftime('%Y-%m-%d %H:%M:%S'), } + def write(self, cr, uid, ids, vals, context=None): + if not context: + context={} + group_id = self.pool.get('res.groups').search(cr, uid, [('name', 'in', ('Administration / Configuration','Administration / Access Rights'))]) + user_obj = self.pool.get('res.users') + user_rec = user_obj.read(cr, uid, uid) + for move in self.browse(cr, uid, ids): + if move.state=='done': + for i in group_id: + if i not in user_rec['groups_id']: + raise osv.except_osv(_('Error!'), _('Quantities, UoMs, Products and Locations cannot be modified on stock moves in Done state (except by the Administrator ' )) +# + return super(stock_move, self).write(cr, uid, ids, vals, context=context) + def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {}