[MERGE] base mp, courtesy of Alexandre Fayolle (camptocamp)

lp bug: https://launchpad.net/bugs/1182111 fixed

bzr revid: mat@openerp.com-20130823095912-5kwshj6nkdzduejx
This commit is contained in:
Martin Trigaux 2013-08-23 11:59:12 +02:00
commit 3d6dc36407
7 changed files with 119 additions and 7 deletions

View File

@ -77,6 +77,7 @@ Dashboard / Reports for MRP will include:
#TODO: This yml tests are needed to be completely reviewed again because the product wood panel is removed in product demo as it does not suit for new demo context of computer and consultant company
# so the ymls are too complex to change at this stage
'test': [
'test/multicompany.yml',
# 'test/order_demo.yml',
# 'test/order_process.yml',
# 'test/cancel_order.yml',

View File

@ -0,0 +1,20 @@
-
Set the current user as multicompany user
-
!context
uid: 'stock.multicompany_user'
-
check no error on getting default mrp.production values in multicompany setting
-
!python {model: mrp.production}: |
location_obj = self.pool.get('stock.location')
fields = ['location_src_id', 'location_dest_id']
defaults = self.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context)
log('got defaults: %s', defaults)
for field in fields:
if defaults.get(field):
try:
location_obj.check_access_rule(cr, uid, [defaults[field]], 'read', context)
except Exception, exc:
assert False, "unreadable location %s: %s" % (field, exc)

View File

@ -94,6 +94,7 @@ Dashboard / Reports for Warehouse Management will include:
# 'test/opening_stock.yml',
# 'test/shipment.yml',
# 'test/stock_report.yml',
'test/multicompany.yml'
],
'installable': True,
'application': True,

View File

@ -2945,12 +2945,22 @@ class stock_warehouse(osv.osv):
}
def _default_lot_input_stock_id(self, cr, uid, context=None):
lot_input_stock = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
return lot_input_stock.id
try:
lot_input_stock_model, lot_input_stock_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, [lot_input_stock_id], 'read', context=context)
except (ValueError, orm.except_orm):
# the user does not have read access on the location or it does not exists
lot_input_stock_id = False
return lot_input_stock_id
def _default_lot_output_id(self, cr, uid, context=None):
lot_output = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_output')
return lot_output.id
try:
lot_input_stock_model, lot_input_stock_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_output')
self.pool.get('stock.location').check_access_rule(cr, uid, [lot_input_stock_id], 'read', context=context)
except (ValueError, orm.except_orm):
# the user does not have read access on the location or it does not exists
lot_output_id = False
return lot_output_id
_defaults = {
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c),

View File

@ -287,6 +287,16 @@
<field name="company_id" ref="base.main_company"/>
</record>
<record id="multicompany_user" model="res.users">
<field name="name">multicomp</field>
<field name="login">multicomp</field>
<field name="password">multicomp</field>
<field name="company_id" ref="res_company_2"/>
<field name="company_ids" eval="[(6,0,[ref('res_company_2')])]"/>
<field name="groups_id" eval="[(6,0,[ref('base.group_user'), ref('stock.group_stock_manager')])]"/>
</record>
</data>
</openerp>

View File

@ -0,0 +1,68 @@
-
Set the current user as multicompany user
-
!context
uid: 'stock.multicompany_user'
-
check no error on getting default stock.move values 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'):
context['picking_type'] = type
defaults = self.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context)
log('type: %s got defaults: %s', type, defaults)
for field in fields:
if defaults.get(field):
try:
location_obj.check_access_rule(cr, uid, [defaults[field]], 'read', context)
except Exception, exc:
assert False, "unreadable location %s: %s" % (field, exc)
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']
log('type: %s got: %s', type, result)
for field in fields:
if result.get(field):
try:
location_obj.check_access_rule(cr, uid, [result[field]], 'read', context)
except Exception, exc:
assert False, "unreadable location %s: %s" % (field, exc)
-
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)
log('got defaults: %s', defaults)
if defaults.get('location_id'):
try:
location_obj.check_access_rule(cr, uid, [defaults['location_id']], 'read', context)
except Exception, exc:
assert False, "unreadable source location: %s" % exc
-
check default locations for warehouse in multicompany setting
-
!python {model: stock.warehouse}: |
location_obj = self.pool.get('stock.location')
fields = ['lot_input_id', 'lot_stock_id', 'lot_output_id']
defaults = self.default_get(cr, uid, fields, context)
log('got defaults: %s', defaults)
for field in fields:
if defaults.get(field):
try:
location_obj.check_access_rule(cr, uid, [defaults[field]], 'read', context)
except Exception, exc:
assert False, "unreadable default %s: %s" % (field, exc)

View File

@ -19,7 +19,7 @@
#
##############################################################################
from openerp.osv import fields, osv
from openerp.osv import fields, osv, orm
from openerp.tools.translate import _
class stock_fill_inventory(osv.osv_memory):
@ -28,8 +28,10 @@ class stock_fill_inventory(osv.osv_memory):
def _default_location(self, cr, uid, ids, context=None):
try:
loc_model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
except ValueError, e:
location = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
location.check_access_rule('read', context=context)
location_id = location.id
except (ValueError, orm.except_orm), e:
return False
return location_id or False