ocb team mailing list archive
-
ocb team
-
Mailing list archive
-
Message #00009
ocb-addons/7.0 conflicts in stock.py, mrp.py
-
To:
ocb@xxxxxxxxxxxxxxxxxxx
-
From:
Stefan Rijnhart <stefan@xxxxxxxx>
-
Date:
Wed, 31 Jul 2013 15:51:49 +0200
-
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7
Hi,
unfortuntely, the OpenERP devs decided to fix
https://launchpad.net/bugs/1182111 independently of the available
community fix by Alexandre Fayolle. The fixes are implemented in
lp:openobject-addons/7.0, rev. 9328, 9329 and 9335. These revisions
conflict with lp:ocb-addons/7.0, rev. 9210.
As far as I can see, the patches are roughly equivalent. Both versions
seem to miss one or two of the occurrences of the problem. Of course,
the core patches do not include Alexandre's beautiful tests. What I
would like to suggest is to reverse merge Alexandre's fix on
ocb-addons/7.0 (bzr merge :parent -r 9210..9209) so that the core
changes can be committed as is. Please review the attached diff file
which reflects the outcome of that proces. Please let me know if you can
live with that and I can do it on short notice.
We would have to request Alexandre to resubmit the tests and the
occurrences that the core devs missed in a separate proposal, if he
thinks that it is worth the trouble.
The nightly replay task on this ocb-branch will stall due to the
conflict until this is resolved.
Cheers,
Stefan.
--
Therp - Maatwerk in open ontwikkeling
Stefan Rijnhart - Ontwerp en implementatie
mail: stefan@xxxxxxxx
tel: +31 (0) 614478606
http://therp.nl
https://twitter.com/therp_stefan
=== modified file 'mrp/__openerp__.py'
--- mrp/__openerp__.py 2013-07-11 10:21:56 +0000
+++ mrp/__openerp__.py 2013-07-31 13:34:11 +0000
@@ -77,7 +77,6 @@
#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',
=== modified file 'mrp/mrp.py'
--- mrp/mrp.py 2013-07-25 15:09:09 +0000
+++ mrp/mrp.py 2013-07-31 13:35:14 +0000
@@ -409,21 +409,19 @@
def _src_id_default(self, cr, uid, ids, context=None):
try:
- src_location = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context)
- src_location._model.check_access_rule(cr, uid, [src_location.id], 'read', context=context)
+ location_model, location_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, [location_id], 'read', context=context)
except (orm.except_orm, ValueError):
- # no read access
- return False
- return src_location.id
+ location_id = False
+ return location_id
def _dest_id_default(self, cr, uid, ids, context=None):
try:
- dest_location = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context)
- dest_location._model.check_access_rule(cr, uid, [dest_location.id], 'read', context=context)
+ location_model, location_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, [location_id], 'read', context=context)
except (orm.except_orm, ValueError):
- # no read access
- return False
- return dest_location.id
+ location_id = False
+ return location_id
_columns = {
'name': fields.char('Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
=== removed file 'mrp/test/multicompany.yml'
--- mrp/test/multicompany.yml 2013-05-23 10:01:15 +0000
+++ mrp/test/multicompany.yml 1970-01-01 00:00:00 +0000
@@ -1,20 +0,0 @@
--
- 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)
=== modified file 'stock/__openerp__.py'
--- stock/__openerp__.py 2013-06-03 12:20:25 +0000
+++ stock/__openerp__.py 2013-07-31 13:34:11 +0000
@@ -94,7 +94,6 @@
# '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-07-25 11:44:23 +0000
+++ stock/stock.py 2013-07-31 13:35:14 +0000
@@ -1701,12 +1701,11 @@
location_xml_id = 'stock_location_customers'
if location_xml_id:
try:
- location = mod_obj.get_object(cr, uid, 'stock', location_xml_id, context=context)
- location._model.check_access_rule(cr, uid, [location.id], 'read', context=context)
- location_id = location.id
- except (orm.except_orm, ValueError), exc:
- # likely the user does not have read access on the location
+ location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', location_xml_id)
+ self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
+ except (orm.except_orm, ValueError):
location_id = False
+
return location_id
def _default_location_source(self, cr, uid, context=None):
@@ -1736,12 +1735,11 @@
location_xml_id = 'stock_location_stock'
if location_xml_id:
try:
- location = mod_obj.get_object(cr, uid, 'stock', location_xml_id)
- location._model.check_access_rule(cr, uid, [location.id], 'read', context=context)
- location_id = location.id
+ location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', location_xml_id)
+ self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
except (orm.except_orm, ValueError):
- # likely the user does not have read access on the location
location_id = False
+
return location_id
def _default_destination_address(self, cr, uid, context=None):
@@ -1960,20 +1958,16 @@
location_source_id = 'stock_location_stock'
location_dest_id = 'stock_location_customers'
try:
- location = mod_obj.get_object(cr, uid, 'stock', location_source_id)
- location._model.check_access_rule(cr, uid, [location.id], 'read', context=context)
- source_location_id = location.id
+ source_location = mod_obj.get_object_reference(cr, uid, 'stock', location_source_id)
+ self.pool.get('stock.location').check_access_rule(cr, uid, [source_location[1]], 'read', context=context)
except (orm.except_orm, ValueError):
- # likely the user does not have read access on the location
- source_location_id = False
+ source_location = False
try:
- location = mod_obj.get_object(cr, uid, 'stock', location_dest_id)
- location._model.check_access_rule(cr, uid, [location.id], 'read', context=context)
- dest_location_id = location.id
+ dest_location = mod_obj.get_object_reference(cr, uid, 'stock', location_dest_id)
+ self.pool.get('stock.location').check_access_rule(cr, uid, [dest_location[1]], 'read', context=context)
except (orm.except_orm, ValueError):
- # likely the user does not have read access on the location
- dest_location_id = False
- return {'value':{'location_id': source_location_id, 'location_dest_id': dest_location_id}}
+ dest_location = False
+ return {'value':{'location_id': source_location and source_location[1] or False, 'location_dest_id': dest_location and dest_location[1] or False}}
def onchange_date(self, cr, uid, ids, date, date_expected, context=None):
""" On change of Scheduled Date gives a Move date.
@@ -2908,13 +2902,11 @@
def _default_stock_location(self, cr, uid, context=None):
try:
- location = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
- location._model.check_access_rule(cr, uid, [location.id], 'read', context=context)
- stock_location_id = location.id
- except (ValueError, orm.except_orm):
- # likely the user does not have read access on the location
- stock_location_id = False
- return stock_location_id
+ location_model, location_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, [location_id], 'read', context=context)
+ except (orm.except_orm, ValueError):
+ location_id = False
+ return location_id
_defaults = {
'location_id': _default_stock_location
@@ -2953,24 +2945,12 @@
}
def _default_lot_input_stock_id(self, cr, uid, context=None):
- try:
- lot_input_stock = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
- lot_input_stock._model.check_access_rule(cr, uid, [lot_input_stock.id], 'read', context=context)
- lot_input_stock_id = lot_input_stock.id
- except (ValueError, orm.except_orm):
- # likely the user does not have read access on the location
- lot_input_stock_id = False
- return lot_input_stock_id
+ lot_input_stock = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
+ return lot_input_stock.id
def _default_lot_output_id(self, cr, uid, context=None):
- try:
- lot_output = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_output')
- lot_output._model.check_access_rule(cr, uid, [lot_output.id], 'read', context=context)
- lot_output_id = lot_output.id
- except (ValueError, orm.except_orm):
- # likely the user does not have read access on the location
- lot_output_id = False
- return lot_output_id
+ lot_output = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_output')
+ 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),
=== modified file 'stock/stock_demo.xml'
--- stock/stock_demo.xml 2013-05-23 10:01:15 +0000
+++ stock/stock_demo.xml 2013-07-31 13:34:11 +0000
@@ -287,16 +287,6 @@
<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>
=== removed file 'stock/test/multicompany.yml'
--- stock/test/multicompany.yml 2013-05-23 10:01:15 +0000
+++ stock/test/multicompany.yml 1970-01-01 00:00:00 +0000
@@ -1,68 +0,0 @@
-
--
- 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)
=== modified file 'stock/wizard/stock_change_product_qty.py'
--- stock/wizard/stock_change_product_qty.py 2012-12-19 20:55:13 +0000
+++ stock/wizard/stock_change_product_qty.py 2013-07-31 13:34:58 +0000
@@ -19,7 +19,7 @@
#
##############################################################################
-from openerp.osv import fields, osv
+from openerp.osv import fields, osv, orm
import openerp.addons.decimal_precision as dp
from openerp.tools.translate import _
from openerp import tools
@@ -62,7 +62,11 @@
if 'product_id' in fields:
res.update({'product_id': product_id})
if 'location_id' in fields:
- location_id = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context)
+ try:
+ model, location_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, [location_id], 'read', context=context)
+ except (orm.except_orm, ValueError):
+ location_id = False
res.update({'location_id': location_id and location_id.id or False})
return res
=== modified file 'stock/wizard/stock_fill_inventory.py'
--- stock/wizard/stock_fill_inventory.py 2013-05-23 10:01:15 +0000
+++ stock/wizard/stock_fill_inventory.py 2013-07-31 13:34:11 +0000
@@ -19,7 +19,7 @@
#
##############################################################################
-from openerp.osv import fields, osv, orm
+from openerp.osv import fields, osv
from openerp.tools.translate import _
class stock_fill_inventory(osv.osv_memory):
@@ -28,10 +28,8 @@
def _default_location(self, cr, uid, ids, context=None):
try:
- 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:
+ loc_model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
+ except ValueError, e:
return False
return location_id or False