Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1771 Vistas

 I am working with odoo 16 and i have this line in a template xml:

  t t-set="payment_provider_model" t-value="request.env['payment.provider'].search([('id', '=', self.id)])[0]"/

(I know it's missing but i can't put my post correctly with them)

The objective of this line is to get me the possibility to use the differant function in my payment_provider class.




The error i get is the following :

"Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo16\server\odoo\http.py", line 2003, in __call__
    response = request._serve_db()
  File "C:\Program Files (x86)\Odoo16\server\odoo\http.py", line 1589, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "C:\Program Files (x86)\Odoo16\server\odoo\service\model.py", line 133, in retrying
    result = func()
  File "C:\Program Files (x86)\Odoo16\server\odoo\http.py", line 1616, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "C:\Program Files (x86)\Odoo16\server\odoo\http.py", line 1730, in dispatch
    return self.request.registry['ir.http']._dispatch(endpoint)
  File "C:\Program Files (x86)\Odoo16\server\odoo\addons\website\models\ir_http.py", line 237, in _dispatch
    response = super()._dispatch(endpoint)
  File "C:\Program Files (x86)\Odoo16\server\odoo\addons\base\models\ir_http.py", line 156, in _dispatch
    result.flatten()
  File "C:\Program Files (x86)\Odoo16\server\odoo\http.py", line 1100, in flatten
    self.response.append(self.render())
  File "C:\Program Files (x86)\Odoo16\server\odoo\http.py", line 1092, in render
    return request.env["ir.ui.view"]._render_template(self.template, self.qcontext)
  File "C:\Program Files (x86)\Odoo16\server\odoo\addons\website\models\ir_ui_view.py", line 419, in _render_template
    return super()._render_template(template, values=values)
  File "C:\Program Files (x86)\Odoo16\server\odoo\addons\base\models\ir_ui_view.py", line 2125, in _render_template
    return self.env['ir.qweb']._render(template, values)
  File "C:\Program Files (x86)\Odoo16\server\odoo\tools\profiler.py", line 292, in _tracked_method_render
    return method_render(self, template, values, **options)
  File "C:\Program Files (x86)\Odoo16\server\odoo\addons\base\models\ir_qweb.py", line 581, in _render
    result = ''.join(rendering)
  File "", line 369, in template_1710
  File "", line 351, in template_1710_content
  File "", line 251, in template_1710_t_call_0
  File "", line 876, in template_1285
  File "", line 663, in template_1285_content
  File "", line 67, in template_1784
odoo.addons.base.models.ir_qweb.QWebException: Error while render the template
KeyError: 'self'



I want to replace the self.id with something that will not raise an error but give me the actual id of my actual payment_provider




Avatar
Descartar
Autor Mejor respuesta

Found a way, instead of using the id i used the code : 

t t-set="payment_provider_model" t-value="request.env['payment.provider'].search([('code', '=', 'mycode')])"/> 

worked perfectly 

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
abr 24
1346
2
abr 24
1895
0
feb 24
728
0
feb 24
711
2
ene 24
1220