hello guys
I am trying to fetch data using sql query
my code :
wizard :
class dbreport(models.TransientModel):
_name = "bdb.wizard.report"
_description = "trying to run report from db query"
gl = fields.Many2one('account.account', string='general ledge name')
def rep_print(self):
rr = """ select b.code,a.debit,a.credit from account_move_line a
inner join account_account b on b.id = a.account_id
"""
self.cr.execute(rr)
datas = self.env.cr.fetchone()[0] or 0.0
data = {
'form_data': self.read()[0],
'datas': datas,
}
return self.env.ref('nidal.db_wizard').report_action(self, data=data)
in report and template :
xml version="1.0" encoding="utf-8"?>
id="db_wizard" model="ir.actions.report">
name="name">dbwizard
name="model">bdb.wizard.report
name="report_type">qweb-pdf
name="report_name">nidal.report_db_wizard
name="report_file">nidal.report_db_wizard
name="binding_model_id" ref="model_bdb_wizard_report"/>
name="binding_type">report
id="report_db_wizard">
t-call="web.html_container">
t-call="web.external_layout">
class="page">
class="oe_structure">
class="text-center">
تقرير
id
:
t-esc="form_data['gl'][0]"/>
class="table table-bordered">
code
debit
credit
t-foreach="datas" t-as="line">
t-esc="line['b.code']"/>
t-esc="line['b.debit']"/>
t-esc="line['b.credit']"/>
id="report_db_wizard">
class="page">
class="oe_structure">
class="text-center">
id
:
class="table table-bordered">
code
debit
credit
t-call="web.html_container">
t-call="web.external_layout">
تقرير
t-esc="form_data['gl'][0]"/>
t-foreach="datas" t-as="line">
t-esc="line['b.code']"/>
t-esc="line['b.debit']"/>
t-esc="line['b.credit']"/>