Skip to Content
मेन्यू
This question has been flagged
2 Replies
7173 Views

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.

Avatar
Discard
Author

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

Best Answer

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.

Avatar
Discard
Best Answer

Hi,

  just try any of the following

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

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

 retrun record['name1']                                                                                                          

Avatar
Discard
Related Posts Replies Views Activity
1
जुल॰ 25
1959
1
मई 25
2047
1
अप्रैल 25
2479
1
फ़र॰ 25
1749
0
अक्तू॰ 24
1493