콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3541 화면

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) ]]
아바타
취소