[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) <nim@odoo.com>
This commit is contained in:
Joseph Caburnay
2019-10-15 13:44:34 +00:00
committed by fw-bot
parent cf6e8e412c
commit 2524d78cab
+2 -1
View File
@@ -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)