stock.picking.out group by in multi companies

Bug #1309105 reported by Yannick Vaucher @ Camptocamp
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP Publisher's Warranty Team

Bug Description

In multi company context, when using the group by 'state' in Delivery Orders I encountered the following error:

(Document type: Picking List, Operation: read)
Traceback (most recent call last):
  File ".../server/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File ".../server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File ".../server/openerp/osv/osv.py", line 190, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File ".../server/openerp/osv/osv.py", line 132, in wrapper
    return f(self, dbname, *args, **kwargs)
  File ".../server/openerp/osv/osv.py", line 199, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File ".../server/openerp/osv/osv.py", line 187, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File ".../server/openerp/osv/orm.py", line 2759, in read_group
    data = self.read(cr, uid, data_ids, [groupby], context=context)
  File ".../addons/stock/stock.py", line 3128, in read
    return self.pool.get('stock.picking').read(cr, uid, ids, fields=fields, context=context, load=load)
  File ".../server/openerp/osv/orm.py", line 3680, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File ".../server/openerp/osv/orm.py", line 3735, in _read_flat
    self._check_record_rules_result_count(cr, user, sub_ids, result_ids, 'read', context=context)
  File ".../server/openerp/osv/orm.py", line 3939, in _check_record_rules_result_count
    (self._description, operation))
except_osv: (u'Access Denied', u'The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: Picking List, Operation: read)')

After digging a bit, I found that orm method read_group calls

orm.py: 2640
        self._apply_ir_rules(cr, uid, query, 'read', context=context)

In there, we get the get domain on stock.picking.out which will be empty by default. So query will not have any ir_rule applied.

Then, in read_group again, there is the big query that will get the counts. However it will also takes min(id).

The min id will be passed in read() to which will again be applied the ir_rules. But this time it won't be None, it will read stock.picking rule and not the unexistant stock.picking.out rule.

Thus it will fail if min id is a stock picking out from the other company than the current user's company.

As a temporary patch I duplicated stock.stock_picking_rule for stock.picking.in and stock.picking.out

I'll provide a patch to solve it on the read_group method in stock module

Tags: maintenance

Related branches

description: updated
Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello,

Thanks for the report and the patch, it was merged in 7.0

revno: 10010 [merge]
revision-id: <email address hidden>

Changed in openobject-addons:
status: New → Fix Released
importance: Undecided → Low
no longer affects: ocb-addons/7.0
no longer affects: ocb-addons
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.