Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
4949 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
gen 24
1427
0
ott 22
3463
0
lug 20
2211
3
gen 25
4962
2
feb 16
5821