コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
7176 ビュー

How change format display a field in qweb report?


function in python file:

def _get_name(self,partner_id):

    sql = """ select name as name1 from res_partner
                    where id=%s """ %(partner_id)
    self.env.cr.execute(sql)
    return self.env.cr.dictfetchone()


template xml:

            <span t-esc="get_name(partner_id)"/>

output pdf report:


    {'name1': mosao}


I want just display: mosao

please help me.

アバター
破棄
著作者

Hi Anu and Sudhir Arya, Thanks for your answer correct.

最善の回答

dictfetchone will give you the dictionary for the single record. So you have to fetch the value from the dict.

Try following code:

return self.env.cr.dictfetchone().get('name1', '')

See different python fetch types for fetching data from query.

アバター
破棄
最善の回答

Hi,

  just try any of the following

     <span t-esc="get_name(partner_id)['name1']"/>

or 
      record =  self.env.cr.dictfetchone() 

 retrun record['name1']                                                                                                          

アバター
破棄
関連投稿 返信 ビュー 活動
1
7月 25
1960
1
5月 25
2047
1
4月 25
2479
1
2月 25
1749
0
10月 24
1493