Merge lp:~camptocamp/ocb-addons/7.0-fix-lp-1210195-RDE into lp:ocb-addons

Proposed by Romain Deheele - Camptocamp
Status: Rejected
Rejected by: Stefan Rijnhart (Opener)
Proposed branch: lp:~camptocamp/ocb-addons/7.0-fix-lp-1210195-RDE
Merge into: lp:ocb-addons
Diff against target: 45 lines (+12/-5)
2 files modified
procurement/procurement.py (+3/-5)
stock/stock.py (+9/-0)
To merge this branch: bzr merge lp:~camptocamp/ocb-addons/7.0-fix-lp-1210195-RDE
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, test Needs Fixing
Review via email: mp+181227@code.launchpad.net

Description of the change

Hello,

This branch fixes bug #1210195:access denied when a subsidiary company's user tries to create a reordering rule(multicompany context)

https://bugs.launchpad.net/openobject-addons/+bug/1210195

Romain

To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

This fix breaks the database creation from scratch.

2013-09-26 07:53:54,261 8361 INFO openerp_prod_doremi openerp.modules.loading: module procurement: loading stock_orderpoint.xml
2013-09-26 07:53:54,321 8361 ERROR openerp_prod_doremi openerp.tools.convert: Parse error in /home/afayolle/work/customers/doremi/openerp_buildout_prod/parts/addons/procurement/stock_orderpoint.xml:7:
<record id="stock_warehouse_orderpoint_0" model="stock.warehouse.orderpoint">
            <field name="product_max_qty">25.0</field>
            <field name="product_min_qty">5.0</field>
            <field model="product.uom" name="product_uom" ref="product.product_uom_dozen"/>
            <field model="stock.warehouse" name="warehouse_id" search="[]"/>
            <field model="product.product" name="product_id" ref="product.product_product_36"/>
            <field name="location_id" ref="stock.stock_location_stock"/>
        </record>
Traceback (most recent call last):
  File "/home/afayolle/work/customers/doremi/openerp_buildout_prod/parts/server/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "/home/afayolle/work/customers/doremi/openerp_buildout_prod/parts/server/openerp/tools/convert.py", line 814, in _tag_record
    id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "/home/afayolle/work/customers/doremi/openerp_buildout_prod/parts/server/openerp/addons/base/ir/ir_model.py", line 963, in _update
    res_id = model_obj.create(cr, uid, values, context=context)
  File "/home/afayolle/work/customers/doremi/openerp_buildout_prod/parts/server/openerp/osv/orm.py", line 4318, in create
    vals = self._add_missing_default_values(cr, user, vals, context)
  File "/home/afayolle/work/customers/doremi/openerp_buildout_prod/parts/server/openerp/osv/orm.py", line 2487, in _add_missing_default_values
    defaults = self.default_get(cr, uid, missing_defaults, context)
  File "/home/afayolle/work/customers/doremi/openerp_buildout_prod/parts/addons/procurement/procurement.py", line 554, in default_get
    warehouse = self.pool.get('stock.warehouse').browse(cr, uid, res['warehouse_id'], context)
KeyError: 'warehouse_id'

review: Needs Fixing (code review, test)
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

setting to work in progress due to inactivity

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Competing fix was merged in upstream 7.0: https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-opw-596679-rgo/+merge/186294. Setting to rejected.

Unmerged revisions

9414. By Romain Deheele - Camptocamp

[FIX] fix bug #1210195:fix access denied when a subsidiary company's user tries to create a reordering rule(multicompany context)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'procurement/procurement.py'
--- procurement/procurement.py 2012-10-23 16:05:04 +0000
+++ procurement/procurement.py 2013-08-21 08:52:01 +0000
@@ -537,7 +537,8 @@
537 'qty_multiple': lambda *a: 1,537 'qty_multiple': lambda *a: 1,
538 'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'stock.orderpoint') or '',538 'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'stock.orderpoint') or '',
539 'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False),539 'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False),
540 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c)540 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c),
541 'warehouse_id': lambda self, cr, uid, c: self.pool.get('stock.warehouse')._default_warehouse_id(cr, uid, context=c)
541 }542 }
542 _sql_constraints = [543 _sql_constraints = [
543 ('qty_multiple_check', 'CHECK( qty_multiple > 0 )', 'Qty Multiple must be greater than zero.'),544 ('qty_multiple_check', 'CHECK( qty_multiple > 0 )', 'Qty Multiple must be greater than zero.'),
@@ -548,10 +549,7 @@
548549
549 def default_get(self, cr, uid, fields, context=None):550 def default_get(self, cr, uid, fields, context=None):
550 res = super(stock_warehouse_orderpoint, self).default_get(cr, uid, fields, context)551 res = super(stock_warehouse_orderpoint, self).default_get(cr, uid, fields, context)
551 # default 'warehouse_id' and 'location_id'552 # default location_id'
552 if 'warehouse_id' not in res:
553 warehouse = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'warehouse0', context)
554 res['warehouse_id'] = warehouse.id
555 if 'location_id' not in res:553 if 'location_id' not in res:
556 warehouse = self.pool.get('stock.warehouse').browse(cr, uid, res['warehouse_id'], context)554 warehouse = self.pool.get('stock.warehouse').browse(cr, uid, res['warehouse_id'], context)
557 res['location_id'] = warehouse.lot_stock_id.id555 res['location_id'] = warehouse.lot_stock_id.id
558556
=== modified file 'stock/stock.py'
--- stock/stock.py 2013-08-15 07:54:23 +0000
+++ stock/stock.py 2013-08-21 08:52:01 +0000
@@ -2944,6 +2944,15 @@
2944 'lot_output_id': fields.many2one('stock.location', 'Location Output', required=True, domain=[('usage','<>','view')]),2944 'lot_output_id': fields.many2one('stock.location', 'Location Output', required=True, domain=[('usage','<>','view')]),
2945 }2945 }
29462946
2947 def _default_warehouse_id(self, cr, uid, context=None):
2948 company_id = self.pool.get('res.users').read(cr, uid, uid, ['company_id'])['company_id']
2949 if company_id:
2950 default_warehouse_id = self.search(cr, uid, [('company_id','=',company_id[0])])
2951 if default_warehouse_id:
2952 return default_warehouse_id[0]
2953 else:
2954 raise osv.except_osv(_("Warning"), _("Please define the warehouse and locations for %s company first."%(company_id[1])))
2955
2947 def _default_lot_input_stock_id(self, cr, uid, context=None):2956 def _default_lot_input_stock_id(self, cr, uid, context=None):
2948 lot_input_stock = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')2957 lot_input_stock = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
2949 return lot_input_stock.id2958 return lot_input_stock.id