Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
1996 Представления

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



Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Лучший ответ
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.


Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
июл. 25
6773
2
мар. 24
1968
0
нояб. 23
1373
1
сент. 23
2333
1
июл. 22
1125