0
如何從報告模板傳遞文檔到解析器類,這樣我可以修改報告如何將文檔從模板傳遞給解析器類?
class purchase_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(purchase_report, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'get_purchase': self.get_purchase,
})
def get_purchase(self):
cr = self.cr
uid = self.uid
purchase_obj=self.pool.get('purchase.order')
ids = purchase_obj.search(cr, uid, [])
records = purchase_obj.browse(cr, uid, ids)
print "yes"
return record
我的模板
<template id="report_wizard">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="report.external_layout">
<div class="page">
<div class="oe_structure" />
<td>
<strong>Purchase Order:
<t t-set="records" t-value="get_purchase()"/>
<table>
<thead>
<th>Reference</th>
<th>Order Date</th>
</thead>
<tbody>
<tr t-foreach="records" t-as="record">
<tr t-if = "record.partner_id.name == doc.customer.name">
<td><span t-esc="record.name"/> </td>
<td><span t-esc="record.date_order"/></td>
</tr>
</tr>
</tbody>
</table>
</strong>
</td>
</div>
</t>
</t>
</t>
</template>
,現在我有我在此模板文檔嚮導。我需要在我上面提到的解析器類中的文檔。 如何得到它?
需要一個函數,應該在模板中調用。問題解決了我 –