From 2524d78cab3facc52dbe309db585d9aa8ac0e4a9 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Tue, 15 Oct 2019 08:40:11 +0000 Subject: [PATCH] [FIX] point_of_sale: recursive pos.category error message Instead of showing a traceback, show a user-friendly error message to the user to avoid recursive pos.category. closes odoo/odoo#38803 X-original-commit: babcbf8a2bdf3ea9813705c5fce42e883831e009 Signed-off-by: Nicolas Martinelli (nim) --- addons/point_of_sale/models/pos_category.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_category.py b/addons/point_of_sale/models/pos_category.py index 2f2ea7bb94e..1d986867919 100644 --- a/addons/point_of_sale/models/pos_category.py +++ b/addons/point_of_sale/models/pos_category.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError class PosCategory(models.Model): @@ -11,7 +12,7 @@ class PosCategory(models.Model): @api.constrains('parent_id') def _check_category_recursion(self): if not self._check_recursion(): - raise ValueError(_('Error ! You cannot create recursive categories.')) + raise ValidationError(_('Error ! You cannot create recursive categories.')) name = fields.Char(string='Category Name', required=True, translate=True) parent_id = fields.Many2one('pos.category', string='Parent Category', index=True)