跳至内容
菜单
此问题已终结
1 回复
3532 查看

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??

形象
丢弃
最佳答案

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) ]]
形象
丢弃