summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Binsfeld <thomas.binsfeld@acsone.eu>2019-08-20 11:48:18 +0000
committerfw-bot <otis@odoo.com>2019-10-04 11:39:55 +0000
commitc6480a23a6ae35f651e470751a3e485095e6c32a (patch)
treef4f796a7e7a193d46225000e786c416e9fb18250
parentb6e7ed6c7be47dcdf8a00226c016d868f0ad1c4f (diff)
[FIX] point_of_sale: access rights on POS for product deletion
When we are trying to delete a product, a check is made to be sure that no POS session is running. This check is not made as sudo, leading to raise an access right error when you are trying to delete a product without having access rights on the pos session object. So we just call the search_read in sudo. closes odoo/odoo#37977 X-original-commit: edb591cc1eae65660f88e676315276bba8b70ee8 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
-rw-r--r--addons/point_of_sale/models/product.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/point_of_sale/models/product.py b/addons/point_of_sale/models/product.py
index 828c08c43c8..b367c766a9e 100644
--- a/addons/point_of_sale/models/product.py
+++ b/addons/point_of_sale/models/product.py
@@ -16,7 +16,7 @@ class ProductTemplate(models.Model):
def unlink(self):
product_ctx = dict(self.env.context or {}, active_test=False)
if self.with_context(product_ctx).search_count([('id', 'in', self.ids), ('available_in_pos', '=', True)]):
- if self.env['pos.session'].search_count([('state', '!=', 'closed')]):
+ if self.env['pos.session'].sudo().search_count([('state', '!=', 'closed')]):
raise UserError(_('You cannot delete a product saleable in point of sale while a session is still opened.'))
return super(ProductTemplate, self).unlink()
@@ -31,7 +31,7 @@ class ProductProduct(models.Model):
def unlink(self):
product_ctx = dict(self.env.context or {}, active_test=False)
- if self.env['pos.session'].search_count([('state', '!=', 'closed')]):
+ if self.env['pos.session'].sudo().search_count([('state', '!=', 'closed')]):
if self.with_context(product_ctx).search_count([('id', 'in', self.ids), ('product_tmpl_id.available_in_pos', '=', True)]):
raise UserError(_('You cannot delete a product saleable in point of sale while a session is still opened.'))
return super(ProductProduct, self).unlink()