Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
1957 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Beste antwoord
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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
jul. 25
6650
2
mrt. 24
1942
0
nov. 23
1351
1
sep. 23
2304
1
jul. 22
1125