Odoo Help


This community 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.


Partner Ledger Custimisation

Erhuvwu Akpobaro
on 4/13/15, 6:27 AM 540 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

Tidy Way
on 4/24/15, 9:53 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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