Can anyone provide me the sample code how to use message_post_with_view helper method and pass data to the template.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
1
Responder
6647
Vistas
Hello,
You can find this method code in odoo addons module. for eg. in mail thread module use below code
@api.multi
def message_post_with_view(self, views_or_xmlid, **kwargs):
""" Helper method to send a mail / post a message using a view_id to
render using the ir.qweb engine. This method is stand alone, because
there is nothing in template and composer that allows to handle
views in batch. This method should probably disappear when templates
handle ir ui views. """
values = kwargs.pop('values', None) or dict()
try:
from odoo.addons.http_routing.models.ir_http import slug
values['slug'] = slug
except ImportError:
values['slug'] = lambda self: self.id
if isinstance(views_or_xmlid, pycompat.string_types):
views = self.env.ref(views_or_xmlid, raise_if_not_found=False)
else:
views = views_or_xmlid
if not views:
return
for record in self:
values['object'] = record
rendered_template = views.render(values, engine='ir.qweb', minimal_qcontext=True)
kwargs['body'] = rendered_template
record.message_post_with_template(False, **kwargs)
Thanks
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
InscribirsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
4
oct 21
|
7503 | ||
js file, css file, in odoo 12
Resuelto
|
|
1
dic 19
|
8410 | |
|
1
jun 24
|
9297 | ||
Why can't Odoo find my view?
Resuelto
|
|
1
mar 15
|
4978 | |
|
1
jul 25
|
2805 |