Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
7191 Widoki

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.

Awatar
Odrzuć
Autor

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

Najlepsza odpowiedź

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.

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

  just try any of the following

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

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

 retrun record['name1']                                                                                                          

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lip 25
1963
1
maj 25
2050
1
kwi 25
2484
1
lut 25
1756
0
paź 24
1495