openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #05609
[Merge] lp:~camptocamp/ocb-addons/6.1-fix-1182111-lep into lp:ocb-addons/6.1
Leonardo Pistone - camptocamp has proposed merging lp:~camptocamp/ocb-addons/6.1-fix-1182111-lep into lp:ocb-addons/6.1.
Requested reviews:
OpenERP Community Backports Team (ocb)
Related bugs:
Bug #1182111 in OpenERP Community Backports (Addons): "[trunk/7.0] multicompany: error message when creating a stock.move"
https://bugs.launchpad.net/ocb-addons/+bug/1182111
For more details, see:
https://code.launchpad.net/~camptocamp/ocb-addons/6.1-fix-1182111-lep/+merge/213979
--
https://code.launchpad.net/~camptocamp/ocb-addons/6.1-fix-1182111-lep/+merge/213979
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~camptocamp/ocb-addons/6.1-fix-1182111-lep into lp:ocb-addons/6.1.
=== modified file 'stock/__openerp__.py'
--- stock/__openerp__.py 2012-01-31 13:36:57 +0000
+++ stock/__openerp__.py 2014-04-03 09:02:09 +0000
@@ -86,6 +86,7 @@
'test/opening_stock.yml',
'test/shipment.yml',
'test/stock_report.yml',
+ 'test/multicompany.yml',
],
'installable': True,
'application': True,
=== modified file 'stock/stock.py'
--- stock/stock.py 2013-09-10 15:12:35 +0000
+++ stock/stock.py 2014-04-03 09:02:09 +0000
@@ -26,6 +26,7 @@
from itertools import groupby
from osv import fields, osv
+from osv.orm import except_orm
from tools.translate import _
import netsvc
import tools
@@ -1651,7 +1652,14 @@
elif picking_type == 'out':
location_xml_id = 'stock_location_customers'
if location_xml_id:
- location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', location_xml_id)
+ try:
+ location = mod_obj.get_object(cr, uid, 'stock', location_xml_id)
+ # can I read?
+ __ = location.name
+ location_id = location.id
+ except (except_orm, ValueError):
+ # likely the user does not have read access on the location
+ location_id = False
return location_id
def _default_location_source(self, cr, uid, context=None):
@@ -1680,7 +1688,15 @@
elif picking_type == 'out':
location_xml_id = 'stock_location_stock'
if location_xml_id:
- location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', location_xml_id)
+ try:
+ location = mod_obj.get_object(cr, uid, 'stock', location_xml_id)
+ # can I read?
+ __ = location.name
+ location_id = location.id
+ except (except_orm, ValueError):
+ # likely the user does not have read access on the location
+ location_id = False
+
return location_id
_defaults = {
=== modified file 'stock/stock_demo.xml'
--- stock/stock_demo.xml 2011-12-21 11:38:22 +0000
+++ stock/stock_demo.xml 2014-04-03 09:02:09 +0000
@@ -264,5 +264,14 @@
<field eval="'account.account,'+str(ref('account.stk'))" model="account.account" name="value"/>
<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_shop0"/>
+ <field name="company_ids" eval="[(6,0,[ref('res_company_shop0')])]"/>
+ <field name="groups_id" eval="[(6,0,[ref('base.group_user'), ref('stock.group_stock_manager')])]"/>
+ </record>
+
</data>
</openerp>
=== added file 'stock/test/multicompany.yml'
--- stock/test/multicompany.yml 1970-01-01 00:00:00 +0000
+++ stock/test/multicompany.yml 2014-04-03 09:02:09 +0000
@@ -0,0 +1,50 @@
+-
+ 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 picking_type in ('in', 'internal', 'out'):
+ context['picking_type'] = picking_type
+ defaults = self.default_get(cr, uid, ['location_id', 'location_dest_id'], context)
+ log('type: %s got defaults: %s', picking_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)
+-
+ 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)
+
Follow ups