From 5bce036a6a1b6fbcdaf1beccc06ce1d5758e829e Mon Sep 17 00:00:00 2001 From: jke-openerp Date: Tue, 15 Oct 2013 14:22:16 +0200 Subject: [PATCH] Test on multiCompany updated + some other tiny bug bzr revid: jke@openerp.com-20131015122216-m5itjbwouetc3loj --- addons/stock/product.py | 2 +- addons/stock/stock.py | 6 +- addons/stock/tests/__init__.py | 28 ------ addons/stock/tests/test_multicompany.py | 86 ------------------- .../stock/wizard/stock_change_product_qty.py | 3 +- .../security/ir.model.access.csv | 2 + addons/stock_location/stock_location.py | 10 +-- 7 files changed, 13 insertions(+), 124 deletions(-) delete mode 100644 addons/stock/tests/__init__.py delete mode 100644 addons/stock/tests/test_multicompany.py diff --git a/addons/stock/product.py b/addons/stock/product.py index 9e436dd49c3..a4eae7f2c9d 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -141,7 +141,7 @@ class product_product(osv.osv): moves_in = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_in)) moves_out = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_out)) - + res = {} for id in ids: res[id] = { diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 0b215c6f6af..6c394111d55 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -397,7 +397,7 @@ class stock_quant(osv.osv): #solving_quant, dummy = self._reconcile_single_negative_quant(cr, uid, to_solve_quant, solving_quant, quant_neg, qty, context=context) def _price_update(self, cr, uid, ids, newprice, context=None): - self.write(cr, SUPERSER_ID, ids, {'cost': newprice}, context=context) + self.write(cr, SUPERUSER_ID, ids, {'cost': newprice}, context=context) def write(self, cr, uid, ids, vals, context=None): #We want to trigger the move with nothing on reserved_quant_ids for the store of the remaining quantity @@ -1327,7 +1327,7 @@ class stock_move(osv.osv): default['origin_returned_move_id'] = False default['state'] = 'draft' return super(stock_move, self).copy(cr, uid, id, default, context) - + def _default_location_destination(self, cr, uid, context=None): context = context or {} if context.get('default_picking_type_id', False): @@ -1335,7 +1335,7 @@ class stock_move(osv.osv): return pick_type.default_location_dest_id and pick_type.default_location_dest_id.id or False return False - def _default_location_source(self, cr, uid, context=None): + def _default_location_source(self, cr, uid, context=None): context = context or {} if context.get('default_picking_type_id', False): pick_type = self.pool.get('stock.picking.type').browse(cr, uid, context['default_picking_type_id'], context=context) diff --git a/addons/stock/tests/__init__.py b/addons/stock/tests/__init__.py deleted file mode 100644 index a3f647212c5..00000000000 --- a/addons/stock/tests/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Business Applications -# Copyright (c) 2012-TODAY OpenERP S.A. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -#from . import test_multicompany -# -#checks = [ -# test_multicompany, -#] - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/tests/test_multicompany.py b/addons/stock/tests/test_multicompany.py deleted file mode 100644 index 3f76231492b..00000000000 --- a/addons/stock/tests/test_multicompany.py +++ /dev/null @@ -1,86 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Business Applications -# Copyright (c) 2012-TODAY OpenERP S.A. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp.tests import common - - -class TestStockMulticompany(common.TransactionCase): - - def setUp(self): - super(TestStockMulticompany, self).setUp() - cr, uid = self.cr, self.uid - - # Usefull models - self.ir_model_data = self.registry('ir.model.data') - self.res_users = self.registry('res.users') - self.stock_location = self.registry('stock.location') - self.stock_move = self.registry('stock.move') - self.stock_warehouse = self.registry('stock.warehouse') - - model, group_user_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user') - model, group_stock_manager_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'group_stock_manager') - model, company_2_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'res_company_2') - self.multicompany_user_id = self.res_users.create(cr, uid, - {'name': 'multicomp', 'login': 'multicomp', - 'groups_id': [(6, 0, [group_user_id, group_stock_manager_id])], - 'company_id': company_2_id, 'company_ids': [(6,0,[company_2_id])]}) - - def test_00_multicompany_default_stock_move(self): - """check no error on getting default stock.move values in multicompany setting""" - cr, uid, context = self.cr, self.multicompany_user_id, {} - fields = ['location_id', 'location_dest_id'] - for type in ('in', 'internal', 'out'): - context['picking_type'] = type - defaults = self.stock_move.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context) - for field in fields: - if defaults.get(field): - try: - self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context) - except Exception, exc: - assert False, "unreadable location %s: %s" % (field, exc) - self.assertEqual(defaults['type'], type, "wrong move type") - - - def test_10_multicompany_onchange_move_type(self): - """check onchange_move_type does not return unreadable in multicompany setting""" - cr, uid, context = self.cr, self.multicompany_user_id, {} - fields = ['location_id', 'location_dest_id'] - for type in ('in', 'internal', 'out'): - result = self.stock_move.onchange_move_type(cr, uid, [], type, context)['value'] - for field in fields: - if result.get(field): - try: - self.stock_location.check_access_rule(cr, uid, [result[field]], 'read', context) - except Exception, exc: - assert False, "unreadable location %s: %s" % (field, exc) - - - def test_30_multicompany_default_warehouse_location(self): - """check default locations for warehouse in multicompany setting""" - cr, uid, context = self.cr, self.multicompany_user_id, {} - fields = ['lot_input_id', 'lot_stock_id', 'lot_output_id'] - defaults = self.stock_warehouse.default_get(cr, uid, fields, context) - for field in fields: - if defaults.get(field): - try: - self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context) - except Exception, exc: - assert False, "unreadable default %s: %s" % (field, exc) diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py index 8c601c7e101..243ea7304d8 100644 --- a/addons/stock/wizard/stock_change_product_qty.py +++ b/addons/stock/wizard/stock_change_product_qty.py @@ -104,7 +104,8 @@ class stock_change_product_qty(osv.osv_memory): } inventry_line_obj.create(cr , uid, line_data, context=context) - inventry_obj.action_confirm(cr, uid, [inventory_id], context=context) + #doesn't exist + #inventry_obj.action_confirm(cr, uid, [inventory_id], context=context) inventry_obj.action_done(cr, uid, [inventory_id], context=context) return {} diff --git a/addons/stock_location/security/ir.model.access.csv b/addons/stock_location/security/ir.model.access.csv index 6339ccf579a..8e4217acec9 100644 --- a/addons/stock_location/security/ir.model.access.csv +++ b/addons/stock_location/security/ir.model.access.csv @@ -8,8 +8,10 @@ access_stock_location_path_internal_user,stock location path internal user,model access_stock_location_path_sale_manager,stock.location.path partner salemanager,model_stock_location_path,base.group_sale_manager,1,1,1,1 access_stock_location_path_stock_user,stock.location.path stock user,model_stock_location_path,stock.group_stock_user,1,1,1,1 access_stock_location_path,stock.location.path,model_stock_location_path,base.group_sale_salesman,1,0,0,0 +access_stock_location_route,stock.location.route,model_stock_location_route,stock.group_stock_manager,1,0,1,0 access_procurement_rule,procurement.rule.flow,model_procurement_rule,base.group_sale_salesman,1,0,0,0 access_procurement_rule_internal,procurement.rule.flow internal,model_procurement_rule,base.group_user,1,0,0,0 access_stock_putaway_all,stock.putaway all users,model_stock_move_putaway,base.group_user,1,0,0,0 access_product_putaway_all,product.putaway all users,model_product_putaway,base.group_user,1,0,0,0 access_stock_removal_all,product.removal all users,model_product_removal,base.group_user,1,0,0,0 + diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py index 4cd932773d7..8126b089eb0 100644 --- a/addons/stock_location/stock_location.py +++ b/addons/stock_location/stock_location.py @@ -370,11 +370,11 @@ class stock_warehouse(osv.osv): vals[values['field']] = location_id #create new sequences - in_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence in'), 'prefix': vals.get('code', '') + '\IN\\', 'padding': 5}, context=context) - out_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence out'), 'prefix': vals.get('code', '') + '\OUT\\', 'padding': 5}, context=context) - pack_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence packing'), 'prefix': vals.get('code', '') + '\PACK\\', 'padding': 5}, context=context) - pick_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence picking'), 'prefix': vals.get('code', '') + '\PICK\\', 'padding': 5}, context=context) - int_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence internal'), 'prefix': vals.get('code', '') + '\INT\\', 'padding': 5}, context=context) + in_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence in'), 'prefix': vals.get('code', '') + '\IN\\', 'padding': 5}, context=context) + out_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence out'), 'prefix': vals.get('code', '') + '\OUT\\', 'padding': 5}, context=context) + pack_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence packing'), 'prefix': vals.get('code', '') + '\PACK\\', 'padding': 5}, context=context) + pick_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence picking'), 'prefix': vals.get('code', '') + '\PICK\\', 'padding': 5}, context=context) + int_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence internal'), 'prefix': vals.get('code', '') + '\INT\\', 'padding': 5}, context=context) #create WH new_id = super(stock_warehouse, self).create(cr, uid, vals=vals, context=context)