我有以下代码.rml代码从表单中提取字段值。但我有很多2个字段,所以它的索引值是由值或字符串
<?xml version="1.0"?>
<document filename="test.pdf">
<template showBoundary="1">
<pageTemplate id="main">
<pageGraphics>
</pageGraphics>
<frame id="first" x1="200" y1="400" width="150" height="400"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="blocktablestyle4">
<!-- show a grid: this also comes in handy for debugging your tables.-->
<lineStyle kind="GRID" colorName="black" thickness="1" start="0,0" stop="-1,-1" />
</blockTableStyle>
<paraStyle name="textstyle1" fontName="Helvetica" fontSize="9" textColor="black"/>
<paraStyle name="textstyle2" fontName="Helvetica-Bold" fontSize="9" textColor="blue"/>
<paraStyle name="P5" fontName="Helvetica-Bold" fontSize="16.0" textColor="blue" leading="22" alignment="CENTER"/>
</stylesheet>
<story>
<para style="P1">[[ repeatIn(objects,'o') ]]</para>
<para style="P2">
<font color="white"> </font>
</para>
<para style="P5">Feedback Form</para>
<blockTable style="blocktablestyle4">
<tr>
<td>
<para style="textstyle1">ID : [[ o.folionum]]</para>
<para style="textstyle1">Folio : [[ o.folio_number ]]</para>
</td>
<td>
<para style="textstyle1">Inspection Type : [[ o.inspec_type ]]</para>
</td>
</tr>
</blockTable>
</story>
</document>
这是我想要这个报告的.py模块
from openerp.osv import fields, osv
from openerp import api
import logging
class feedback_form(osv.Model):
_name = 'feedback.form'
_rec_name = 'inspec_type'
_columns = {
'folionum' : fields.many2one('calendar.event','Maintainace ID',),
'folio_number' : fields.many2one('asset.asset','Folio number',),
'inspec_type' : fields.many2one('asset1.inspection','Inspection Type',),
'frequency' : fields.char('Frequency'),
'shutdown' : fields.char('Shut Down'),
#'insp_msr1' : fields.many2one('results.measure','Result',),
'insp_msr1' : fields.many2many('results.measure','results_measure_rel','super_id','results_measure_id','Result',),
'insp_rslt' : fields.one2many('feedback.tree','insp_rsltts','Inspection Result',),
}
def onchange_folio(self, cr, uid, ids, folionum, context=None):
dids = []
for record in self.pool.get('calendar.event').browse(cr, uid, folionum, context=context):
dids = [x.id for x in record.folio_num]
return {'domain':{'folio_number':[('id','in',dids)]}}
def onchange_client(self, cr, uid, ids, folio_number, inspec_type, context=None):
res={}
order_obj = self.pool.get('calendar.event')
order_ids = order_obj.search(cr,uid, [('folio_num','=',folio_number)])
return {'domain':{'inspec_type':[('id','in',order_ids)]}}
'''def onchange_insp(self, cr, uid, ids, folio_number, context=None):
dids = []
for record in self.pool.get('calendar.event').browse(cr, uid, folio_number, context=context):
dids = [x.id for x in record.inspection_name]
return {'domain':{'inspec_type':[('id','in',dids)]}}'''
def onchange_measure(self, cr, uid, ids, inspec_type, context=None):
dids = []
for record in self.pool.get('asset1.inspection').browse(cr, uid, inspec_type, context=context):
dids = [x.id for x in record.msr_insp]
return {'domain':{'insp_msr1':[('id','in',dids)]}}
feedback_form()
class feedback_tree(osv.Model):
_name = 'feedback.tree'
_columns = {
'valuess' : fields.char('Values/Results'),
'insp_rsltts': fields.many2one('feedback.form','Result Id'),
}
feedback_tree()
答案 0 :(得分:1)
尝试使用此代码
<blockTable style="blocktablestyle4">
<tr>
<td>
<para style="textstyle1">ID : [[ o.folionum and o.folionum.name or '']]</para>
<para style="textstyle1">Folio : [[ o.folio_number and o.folio_number.name or '' ]]</para>
</td>
<td>
<para style="textstyle1">Inspection Type : [[ o.inspec_type and o.inspec_type.name or '']]</para>
</td>
</tr>
</blockTable>
如果你有多个字段,我们可以使用many2one_field.field_name
访问表值