Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
7186 Vizualizări

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.

Imagine profil
Abandonează
Autor

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

Cel mai bun răspuns

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.

Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

  just try any of the following

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

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

 retrun record['name1']                                                                                                          

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
iul. 25
1962
1
mai 25
2050
1
apr. 25
2482
1
feb. 25
1751
0
oct. 24
1494