تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
2017 أدوات العرض

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.


الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يوليو 25
6855
2
مارس 24
1979
0
نوفمبر 23
1392
1
سبتمبر 23
2341
1
يوليو 22
1125