From 1a04071e351dec5f72732fd105bda5cd26bfe3c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Tue, 26 Sep 2023 06:55:11 +0000 Subject: [PATCH] [FIX] stock: Add groups to product tree view to prevent ACLs error with quantity fields Example use case: - Create a product A. - Update the available quantity of the product. - Create a basic user without Inventory permissions. - Go to the product list (product.product or product.template) and get an error when access to stock.move records to set the qty_available field (for example). TT45220 closes odoo/odoo#142472 X-original-commit: e41fbda20582683361a5124db418f152bf80a3ed Signed-off-by: William Henrotin (whe) --- addons/stock/tests/test_move.py | 17 ++++++++++++++++- addons/stock/views/product_views.xml | 16 +++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/addons/stock/tests/test_move.py b/addons/stock/tests/test_move.py index 321d16b8007..ebc8fd348ed 100644 --- a/addons/stock/tests/test_move.py +++ b/addons/stock/tests/test_move.py @@ -3,7 +3,7 @@ from odoo import Command from odoo.exceptions import UserError -from odoo.tests import Form +from odoo.tests import Form, new_test_user from odoo.tests.common import TransactionCase @@ -2028,6 +2028,21 @@ class StockMove(TransactionCase): move_partial._action_assign() self.assertEqual(move_partial.state, 'assigned') + def test_product_tree_views(self): + """Test to make sure that there are no ACLs errors in users with basic permissions.""" + self.env["stock.quant"]._update_available_quantity(self.product, self.stock_location, 3.0) + user = new_test_user(self.env, login="test-basic-user") + product_view = Form( + self.env["product.product"].with_user(user).browse(self.product.id), + view="product.product_product_tree_view", + ) + self.assertEqual(product_view.name, self.product.name) + template_view = Form( + self.env["product.template"].with_user(user).browse(self.product.product_tmpl_id.id), + view="product.product_template_tree_view", + ) + self.assertEqual(template_view.name, self.product.product_tmpl_id.name) + def test_availability_9(self): """ Test the assignment mechanism when the product quantity is increase on a receipt move. diff --git a/addons/stock/views/product_views.xml b/addons/stock/views/product_views.xml index 551119a4100..461a8119aa9 100644 --- a/addons/stock/views/product_views.xml +++ b/addons/stock/views/product_views.xml @@ -42,8 +42,8 @@ - - + + @@ -54,12 +54,12 @@ - - - + + + - + @@ -158,10 +158,12 @@ - + +
On hand:
+