Odoo Help


Partner Ledger Custimisation

Erhuvwu Akpobaro
on 4/13/15, 6:27 AM 1,344 views

Hello All ,

I am currently overiding the default partner ledger report . I want to add a field in the report called invcompany_id , currently i have only edited one function of  the report which is def Lines and i have inserted some lines in the sql of the function. :

def lines(self, partner):

move_state = ['draft','posted']

if self.target_move == 'posted':

move_state = ['posted']

full_account = []

if self.reconcil:



RECONCILE_TAG = "AND l.reconcile_id IS NULL"


"SELECT l.id, aaa.invcompany_id as invcompany_id ,l.partner_id ,l.analytic_account_id as analytic_account_id,l.company_id, l.date, j.code, acc.code as a_code, acc.name as a_name, l.ref, m.name as move_name, l.name, l.debit, l.credit " \

"FROM account_move_line l " \

" LEFT JOIN account_analytic_account aaa ON (l.analytic_account_id = aaa.id)" \

"LEFT JOIN account_journal j " \

"ON (l.journal_id = j.id) " \

"LEFT JOIN account_account acc " \

"ON (l.account_id = acc.id) " \

"LEFT JOIN res_currency c ON (l.currency_id=c.id) " \

"LEFT JOIN account_move m ON (m.id=l.move_id)" \

"WHERE l.partner_id = %s " \

"AND l.account_id IN %s AND " + self.query +" " \

"AND m.state IN %s " \

" " + RECONCILE_TAG + " "\

"ORDER BY aaa.invcompany_id ,l.date",

(partner.id, tuple(self.account_ids), tuple(move_state)))

res = self.cr.dictfetchall()

print res

sum = 0.0

if self.initial_balance:

sum = self.init_bal_sum

for r in res:

sum += r['debit'] - r['credit']

r['progress'] = sum


return full_account

If i run this report the field i want to display is empty , when i print the dinctionary(res) it shows empty for field i am calling which is aaa.invoicing company , However when i run this sql query in pgadmin / postgres i get the right results and data .

Is there a reason why the code shows empty data for my sql but in pgadmin i get the right results ?.

you have to differentiate sql_query = "" into different string then print your sql_query string before applying into cr.execute(), For more info contact@tidyway.in

TidyWay Software Solutions, TidyWay
on 4/24/15, 9:53 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/13/15, 6:27 AM
Seen: 1344 times
Last updated: 4/24/15, 9:53 AM