Odoo Help

Welcome!

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.

0

how to create pdf report with db parameters

By
kalyan
on 4/21/14, 9:11 AM 750 views

hi i have created query in python file class project_list_print(report_sxw.rml_parse): def lines(self, dm_name_id, *args): self.cr.execute('SELECT dm_name.id as dm_name_id,dm_name.name FROM res_users dm,res_partner dm_name WHERE dm.partner_id = dm_name.id and dm_name.id = %s', (dm_name_id,)) ids = map(lambda x: x[0], self.cr.fetchall()) logging.info('----------------------------------') res = self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids) return res

def __init__(self, cr, uid, name, context):
    super(project_list_print, self).__init__(cr, uid, name, context=context)
    self.localcontext.update({
        'time': time,
        'lines': self.lines,
    })

report_sxw.report_sxw('report.project.list.report','project.list.report','addons/project_htc/report/project_list_report.rml',parser=project_list_print, header=False)

using this file how to call and generate report??

2

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
3577
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 4/21/14, 9:52 AM

Hi, You can call any function in py from rml report.

Code in Your py file

class report(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(report, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            'checkbalance': self.checkbalance
        })

    def checkbalance(self, var1, var2):
        var3 = var1 + var2
        return var3

Call this code from sxw like

checkbalance(10,5)

Or you can call the method directly from rml file using:

[[ checkbalance(10,5) ]]

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

0 follower(s)

Stats

Asked: 4/21/14, 9:11 AM
Seen: 750 times
Last updated: 3/16/15, 8:10 AM