From 2f07aac8b2d17e962f4493a7aa616ad2fefcceb5 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 29 Jul 2013 15:58:44 +0200 Subject: [PATCH] [FIX] stock: remove warning popup on update product quantity wizard and correctly verify access rights on stock.location lp bug: https://launchpad.net/bugs/1200194 fixed bzr revid: mat@openerp.com-20130729135844-jtanbteqtg52ztnu --- addons/stock/stock.py | 8 ++++---- addons/stock/wizard/stock_change_product_qty.py | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index daf0d114b61..48ec9d9e751 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1697,13 +1697,13 @@ class stock_move(osv.osv): if picking_type in ('in', 'internal'): try: location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', 'stock_location_stock') - self.check_access_rule(cr, uid, [location_id], 'read', context=context) + self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context) except (orm.except_orm, ValueError): location_id = False elif picking_type == 'out': try: location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', 'stock_location_customers') - self.check_access_rule(cr, uid, [location_id], 'read', context=context) + self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context) except (orm.except_orm, ValueError): location_id = False @@ -1955,12 +1955,12 @@ class stock_move(osv.osv): location_dest_id = 'stock_location_customers' try: source_location = mod_obj.get_object_reference(cr, uid, 'stock', location_source_id) - self.check_access_rule(cr, uid, [source_location[1]], 'read', context=context) + self.pool.get('stock.location').check_access_rule(cr, uid, [source_location[1]], 'read', context=context) except (orm.except_orm, ValueError): source_location = False try: dest_location = mod_obj.get_object_reference(cr, uid, 'stock', location_dest_id) - self.check_access_rule(cr, uid, [dest_location[1]], 'read', context=context) + self.pool.get('stock.location').check_access_rule(cr, uid, [dest_location[1]], 'read', context=context) except (orm.except_orm, ValueError): dest_location = False return {'value':{'location_id': source_location and source_location[1] or False, 'location_dest_id': dest_location and dest_location[1] or False}} diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py index c6db9a7dfb6..a5f700b442d 100644 --- a/addons/stock/wizard/stock_change_product_qty.py +++ b/addons/stock/wizard/stock_change_product_qty.py @@ -19,7 +19,7 @@ # ############################################################################## -from openerp.osv import fields, osv +from openerp.osv import fields, osv, orm import openerp.addons.decimal_precision as dp from openerp.tools.translate import _ from openerp import tools @@ -62,7 +62,11 @@ class stock_change_product_qty(osv.osv_memory): if 'product_id' in fields: res.update({'product_id': product_id}) if 'location_id' in fields: - location_id = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context) + try: + model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock') + self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context) + except (orm.except_orm, ValueError): + location_id = False res.update({'location_id': location_id and location_id.id or False}) return res