Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
4887 Zobrazení

Hello everyone, here's a question

How can I show a computed field (without store=True) in the qweb view of the website?
I added this field to product.template:

    es_novedad = fields.Boolean(string="Es una novedad", compute="_check_novedad", readonly=True)

    @api.one     def _check_novedad(self):         if datetime.datetime.strptime(self.create_date, '%Y-%m-%d %H:%M:%S') +
relativedelta(days=self.env.user.company_id.dias_novedad) >= datetime.datetime.now():             self.es_novedad = True         else:             self.es_novedad = False


But now there's no way I can show this field at the qweb...

Appreciate any effort trying to help me.

Avatar
Zrušit
Nejlepší odpověď

Hello,

You can use t-field to get computed fields in q-web templates

<span t-field="option.your_computed_field"/>

Hope this helps

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
led 24
1362
0
říj 22
3316
0
čvc 20
2155
3
led 25
4826
2
úno 16
5726