Test on multiCompany updated + some other tiny bug

bzr revid: jke@openerp.com-20131015122216-m5itjbwouetc3loj
This commit is contained in:
jke-openerp 2013-10-15 14:22:16 +02:00
parent af84a5dbb5
commit 5bce036a6a
7 changed files with 13 additions and 124 deletions

View File

@ -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] = {

View File

@ -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)

View File

@ -1,28 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
#from . import test_multicompany
#
#checks = [
# test_multicompany,
#]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,86 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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)

View File

@ -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 {}

View File

@ -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

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
8 access_stock_location_path_sale_manager stock.location.path partner salemanager model_stock_location_path base.group_sale_manager 1 1 1 1
9 access_stock_location_path_stock_user stock.location.path stock user model_stock_location_path stock.group_stock_user 1 1 1 1
10 access_stock_location_path stock.location.path model_stock_location_path base.group_sale_salesman 1 0 0 0
11 access_stock_location_route stock.location.route model_stock_location_route stock.group_stock_manager 1 0 1 0
12 access_procurement_rule procurement.rule.flow model_procurement_rule base.group_sale_salesman 1 0 0 0
13 access_procurement_rule_internal procurement.rule.flow internal model_procurement_rule base.group_user 1 0 0 0
14 access_stock_putaway_all stock.putaway all users model_stock_move_putaway base.group_user 1 0 0 0
15 access_product_putaway_all product.putaway all users model_product_putaway base.group_user 1 0 0 0
16 access_stock_removal_all product.removal all users model_product_removal base.group_user 1 0 0 0
17

View File

@ -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)