diff --git a/addons/point_of_sale/models/product.py b/addons/point_of_sale/models/product.py index 82af00add11..963e9da3bce 100644 --- a/addons/point_of_sale/models/product.py +++ b/addons/point_of_sale/models/product.py @@ -41,7 +41,7 @@ class ProductTemplate(models.Model): def _check_combo_inclusions(self): for product in self: if not product.available_in_pos: - combo_name = self.env['pos.combo.line'].search([('product_id', 'in', product.product_variant_ids.ids)], limit=1).combo_id.name + combo_name = self.env['pos.combo.line'].sudo().search([('product_id', 'in', product.product_variant_ids.ids)], limit=1).combo_id.name if combo_name: raise UserError(_('You must first remove this product from the %s combo', combo_name)) diff --git a/addons/point_of_sale/tests/test_pos_stock_account.py b/addons/point_of_sale/tests/test_pos_stock_account.py index 7611fb996a0..45483a30f54 100644 --- a/addons/point_of_sale/tests/test_pos_stock_account.py +++ b/addons/point_of_sale/tests/test_pos_stock_account.py @@ -267,3 +267,11 @@ class TestPoSStock(TestPoSCommon): self.pos_session.action_pos_session_validate() expense_account_move_line = self.env['account.move.line'].search([('account_id', '=', self.expense_account.id)]) self.assertEqual(expense_account_move_line.balance, 0.0, "Expense account should be 0.0") + + def test_stock_user_without_pos_permissions_can_create_product(self): + stock_manager = odoo.tests.common.new_test_user( + self.env, 'temp_stock_manager', 'stock.group_stock_manager', + ) + self.env['product.product'].with_user(stock_manager).create({ + 'name': 'temp', 'type': 'product', 'available_in_pos': False, + })