تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
7168 أدوات العرض

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
يوليو 25
1959
1
مايو 25
2046
1
أبريل 25
2477
1
فبراير 25
1749
0
أكتوبر 24
1493