Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1931 Vistas

Hi, im using Odoo 14, i want to pop up a warning window when compute field calculating incorrect results.

i try to raise UserError, but this will hinder the display of the page.and returning the following code in compute callback function will not have any effect.

notification = {
    'type': 'ir.actions.client',
    'tag': 'display_notification',
    'params': {
        'title': ('Warning'),
        'message': ('Sensor value exceeds threshold'),
        'sticky': True,
        'type': 'danger'
    },
}

how can i do in this function

is_check = fields.Integer(compute="_is_check")
def _is_check(self, *args):
    for record in self:
        record.is_check = 0
    notification = {
        'type': 'ir.actions.client',
        'tag': 'display_notification',
        'params': {
            'title': ('Warning'),
            'message': ('Sensor value exceeds threshold'),
            'sticky': True,
            'type': 'danger'
        },
    }
    return notification



Avatar
Descartar
Mejor respuesta

Hi,
Refer to the forum it shows how to add Compute Field Popup Error Message
https://www.odoo.com/forum/help-1/to-compute-field-popup-error-message-152075

Hope it helps

Avatar
Descartar
Mejor respuesta
is_warn = fields.Boolean("Is Warn", compute="_compute_is_warn")

def _compute_is_warn(self):
for rec in self:
if rec:
rec.is_warn = True
raise UserError(_("###### Error ######"))
else:
rec.is_warn = False

You can try withUserError with correct condition.
Hope it Helps.


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
jul 25
6528
2
mar 24
1864
0
nov 23
1339
1
sept 23
2260
1
jul 22
1125