← Back to team overview

openerp-community team mailing list archive

Re: [Merge] lp:~openerp-community/openobject-addons/6.0_bug_801562 into lp:openobject-addons/6.0

 

Review: Needs Fixing
Leonardo,

I am sorry, but this does not look a better approach.
Instead, it will give a wrong report because you will only search move lines with company=user's company. Here, it would be possible that the transaction wof user's company has different partner on mpve line,which just happened to me.

You should search partner_id's company = user's company.

I prefer this piece of code:
=== modified file 'account/report/account_partner_ledger.py'
--- account/report/account_partner_ledger.py	2011-01-14 00:11:01 +0000
+++ account/report/account_partner_ledger.py	2011-06-30 10:20:09 +0000
@@ -59,6 +59,8 @@
         self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context', {}))
         ctx2 = data['form'].get('used_context',{}).copy()
         ctx2.update({'initial_bal': True})
+        current_company = self.pool.get('res.users').browse(self.cr, self.uid, self.uid).company_id.id
+        valid_partners = obj_partner.search(self.cr, self.uid, [('company_id','=',current_company)])
         self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2)
         self.reconcil = data['form'].get('reconcil', True)
         self.initial_balance = data['form'].get('initial_balance', True)
@@ -69,7 +71,6 @@
         move_state = ['draft','posted']
         if self.target_move == 'posted':
             move_state = ['posted']
-
         if (data['model'] == 'res.partner'):
             ## Si on imprime depuis les partenaires
             if ids:
@@ -101,12 +102,13 @@
 #                    "AND " + self.query +" " \
                     "AND l.account_id IN %s " \
                     " " + PARTNER_REQUEST + " " \
-                    "AND account.active ",
+                    "AND account.active",
                 (tuple(move_state), tuple(self.account_ids),))
 
         res = self.cr.dictfetchall()
         for res_line in res:
-            partner_to_use.append(res_line['partner_id'])
+            if res_line['partner_id'] in valid_partners:
+                partner_to_use.append(res_line['partner_id'])
         new_ids = partner_to_use
         self.partner_ids = new_ids
         objects = obj_partner.browse(self.cr, self.uid, new_ids)

Hope this helps.

-- 
https://code.launchpad.net/~openerp-community/openobject-addons/6.0_bug_801562/+merge/65792
Your team OpenERP Community is subscribed to branch lp:~openerp-community/openobject-addons/6.0_bug_801562.


References