From 486116588f04251d724a8fd2aa4938165f8a262b Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Wed, 22 May 2013 17:32:03 +0200 Subject: [PATCH] [TEST] add new tests and refactor bzr revid: alexandre.fayolle@camptocamp.com-20130522153203-wp45pyicciktg8m8 --- addons/stock/test/multicompany.yml | 55 +++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/addons/stock/test/multicompany.yml b/addons/stock/test/multicompany.yml index 962bb825dac..8c5df8fe5c2 100644 --- a/addons/stock/test/multicompany.yml +++ b/addons/stock/test/multicompany.yml @@ -4,20 +4,49 @@ - !context uid: 'stock.multicompany_user' + - - check no error on getting default stock.move values for internal move + check no error on getting default stock.move values in multicompany setting - !python {model: stock.move}: | - multicomp_user = ref('stock.multicompany_user') - context['picking_type'] = 'internal' - log('multicompany user: %s, uid: %s', multicomp_user, uid) - log('current context: %s', context) - defaults = self.default_get(cr, multicomp_user, ['location_id', 'location_dest_id', 'type'], context) - assertion_msg = "did not get the correct default (got: %s)" % defaults - log('got defaults: %s', defaults) - assert defaults == {'location_id': False, 'location_dest_id': False, 'type': 'internal'}, assertion_msg - defaults = self.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context) - assertion_msg = "did not get the correct default with uid %s (got: %s)" % (uid, defaults) - log('got defaults: %s', defaults) - assert defaults == {'location_id': False, 'location_dest_id': False, 'type': 'internal'}, assertion_msg + location_obj = self.pool.get('stock.location') + fields = ['location_id', 'location_dest_id'] + for type in ('in', 'internal', 'out'): + context['picking_type'] = type + defaults = self.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context) + for field in fields: + if defaults[field] != False: + assert location_obj.check_access_rule(cr, uid, defaults[field], 'read', context), "unreadable location %s" % field + assert defaults['type'] == type}, "wrong move type" +- + check onchange_move_type does not return unreadable in multicompany setting +- + !python {model: stock.move}: | + location_obj = self.pool.get('stock.location') + fields = ['location_id', 'location_dest_id'] + for type in ('in', 'internal', 'out'): + result = self.onchange_move_type(cr, uid, [], type, context)['value'] + for field in fields: + if defaults[field] != False: + assert location_obj.check_access_rule(cr, uid, defaults[field], 'read', context), "unreadable default %s" % field + +- + check default location readability for stock_fill_inventory in multicompany setting +- + !python {model: stock.fill.inventory}: | + location_obj = self.pool.get('stock.location') + defaults = self.default_get(cr, uid, ['location_id'], context) + if defaults['location_id'] != False: + assert location_obj.check_access_rule(cr, uid, defaults['location_id'], 'read', context), "unreadable default source location" + +- + check default locations for warehouse in multicompany setting +- + !python {model: stock.warehouse}: | + fields = ['lot_input_id', 'lot_stock_id', 'lot_output_id'] + defaults = self.default_get(cr, uid, fields, context) + for field in fields: + for field in fields: + if defaults[field] != False: + assert location_obj.check_access_rule(cr, uid, defaults[field], 'read', context), "unreadable default %s" % field