Skip to Content
Menu
This question has been flagged
3 Replies
7130 Views

i have the following code : 

<p t-field="o.request_id"/>
<t t-foreach="docs" t-as="o">
<p>
<t t-set="latest_partner" t-value="o.run_sql('SELECT purchase_request.Name, purchase_request.origin FROM purchase_request join purchase_request_line on purchase_request_line.request_id = purchase_request.id where purchase_request_line.id =84')"/>
<t t-foreach="latest_partner" t-as="part">
<p> pr - <span t-esc="part_index"/>:  <span t-esc="part"/>  </p>
</t></p></t>

i want to replace the in sql query value mentioned 84 with the field <p t-field="o.request_id"/>  how to do that 

Avatar
Discard
Best Answer

Hi,

You can try it like this,

<t t-set="latest_partner" t-value="o.run_sql('SELECT purchase_request.Name, purchase_request.origin FROM purchase_request join purchase_request_line on purchase_request_line.request_id = purchase_request.id where purchase_request_line.id=%s', % o.request_id)"/>


Avatar
Discard
Best Answer

Could not format the return values? This my problem too

Avatar
Discard
Author Best Answer

Yes Finally its word :)

inside the qweb 

<t t-set= "amount" t-value="o.id" ></t>
<t t-foreach="docs" t-as="o">
<t t-set="latest_partner" t-value="o.run_sql('SELECT DISTINCT purchase_request.Name as MaterialRequest,purchase_request.origin as Source Fromm purchase_request INNER JOIN purchase_request_line on purchase_request_line.request_id = purchase_request.id
INNER JOIN purchase_order_purchase_request_line_rel on purchase_order_purchase_request_line_rel.purchase_request_line_id = purchase_request_line.id
where
purchase_order_purchase_request_line_rel.purchase_order_id =%s' % amount)"/>
<span t-esc="latest_partner"/>
<span t-esc="part"/>  </t> </t>

inside the py 

@api.model
def run_sql(self, qry):
self._cr.execute(qry)
_res = self._cr.fetchall()
return _res

my issue now is its return with self._cr.fetchall() the following result 
result : [(u'PR00005', u'872'), (u'PR00003', u'4545454')]

i want to return the value without letter u :)



Avatar
Discard