Merge lp:~openerp-dev/openobject-addons/trunk-bug-1217779-mba into lp:openobject-addons

Proposed by Mahendra Barad(OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-1217779-mba
Merge into: lp:openobject-addons
Diff against target: 14 lines (+2/-1)
1 file modified
account/wizard/account_subscription_generate.py (+2/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-1217779-mba
Reviewer Review Type Date Requested Status
Nicolas Bessi - Camptocamp (community) Disapprove
Alexandre Fayolle - camptocamp (community) code review, no test Needs Information
OpenERP Core Team Pending
Review via email: mp+200769@code.launchpad.net

Description of the change

Hello sir,

I have fix the issue the wizard that generate recurring move ignore company and breaks on security rules in multi company mode.

Thank you.

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

The way the query is written strikes me as very inefficient. Why use 2 nested subqueries instead of relational joins for which the database optimizer will be able to generate a widely more efficient execution plan?

Something along the line of

select account_subscription_line.id
from account_subscription_line join account_subscription on (subscription_id=account_subscription.id) join account_model on (account_subscription.model_id=account_model.id)
where account_subscription_line.date<%s and account_subscription_line.move_id is null
and account_model.company_id=%s;

(not tested, maybe outer joins should be used)

review: Needs Information (code review, no test)
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Current SQL is faulty and gives following
error

 ERROR: more than one row returned by a subquery used as an expression.

If we look to the query this error seems logical.

I have not investigate more, it is maybe due to corrupted setup and we should never have such configuration but I dont think so.

Alexandre query works out of the box.

Regards

Nicolas

review: Disapprove

Unmerged revisions

9038. By Mahendra Barad(OpenERP)

[FIX]generate recurring move ignore company issue

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/wizard/account_subscription_generate.py'
2--- account/wizard/account_subscription_generate.py 2013-10-27 12:31:04 +0000
3+++ account/wizard/account_subscription_generate.py 2014-01-08 06:06:07 +0000
4@@ -37,8 +37,9 @@
5 mod_obj = self.pool.get('ir.model.data')
6 act_obj = self.pool.get('ir.actions.act_window')
7 moves_created=[]
8+ company_id = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.id
9 for data in self.read(cr, uid, ids, context=context):
10- cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['date'],))
11+ cr.execute('select id from account_subscription_line where date<%s and move_id is null and subscription_id=(select id from account_subscription where model_id=(select id from account_model where company_id=%s))', (data['date'],company_id,))
12 line_ids = map(lambda x: x[0], cr.fetchall())
13 moves = self.pool.get('account.subscription.line').move_create(cr, uid, line_ids, context=context)
14 moves_created.extend(moves)

Subscribers

People subscribed via source and target branches

to all changes: