From 3584b50c577053ce2b8c8568cf32913021414a9e Mon Sep 17 00:00:00 2001 From: ArnauCForgeFlow Date: Thu, 27 Jun 2024 11:34:35 +0200 Subject: [PATCH 1/2] [FIX] stock_inventory: security groups --- stock_inventory/security/ir.model.access.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock_inventory/security/ir.model.access.csv b/stock_inventory/security/ir.model.access.csv index 0dd1ae475..e7bb1509d 100644 --- a/stock_inventory/security/ir.model.access.csv +++ b/stock_inventory/security/ir.model.access.csv @@ -1,3 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_stock_inventory_user,stock.inventory,model_stock_inventory,base.group_user,1,0,0,0 -access_stock_inventory_manager,stock.inventory,model_stock_inventory,base.group_system,1,1,1,1 +access_stock_inventory_user,stock.inventory,model_stock_inventory,stock.group_stock_user,1,1,1,0 +access_stock_inventory_manager,stock.inventory,model_stock_inventory,stock.group_stock_manager,1,1,1,1 From 9c49a57531ec5dc9b6c88f8e228391bb4ae043a4 Mon Sep 17 00:00:00 2001 From: ArnauCForgeFlow Date: Thu, 27 Jun 2024 11:37:10 +0200 Subject: [PATCH 2/2] [FIX] stock_cycle_count: removed some asserts for AccessError --- stock_cycle_count/models/stock_inventory.py | 1 - .../tests/test_stock_cycle_count.py | 39 +++++++++---------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/stock_cycle_count/models/stock_inventory.py b/stock_cycle_count/models/stock_inventory.py index 0fa157098..9993856bf 100644 --- a/stock_cycle_count/models/stock_inventory.py +++ b/stock_cycle_count/models/stock_inventory.py @@ -143,5 +143,4 @@ class StockInventory(models.Model): "with the Cycle Count:\n%(message)s", message=msg, ) - % msg ) diff --git a/stock_cycle_count/tests/test_stock_cycle_count.py b/stock_cycle_count/tests/test_stock_cycle_count.py index ad2066163..449fcd8dd 100644 --- a/stock_cycle_count/tests/test_stock_cycle_count.py +++ b/stock_cycle_count/tests/test_stock_cycle_count.py @@ -228,19 +228,16 @@ class TestStockCycleCount(common.TransactionCase): def test_cycle_count_workflow(self): """Tests workflow.""" - with self.assertRaises(AccessError): - self.cycle_count_1.action_create_inventory_adjustment() + self.cycle_count_1.action_create_inventory_adjustment() inventory = self.inventory_model.search( [("cycle_count_id", "=", self.cycle_count_1.id)] ) - with self.assertRaises(AssertionError): - self.assertTrue(inventory, "Inventory not created.") + self.assertTrue(inventory, "Inventory not created.") inventory.action_state_to_in_progress() inventory.action_state_to_done() - with self.assertRaises(AssertionError): - self.assertEqual( - self.cycle_count_1.state, "done", "Cycle count not set as done." - ) + self.assertEqual( + self.cycle_count_1.state, "done", "Cycle count not set as done." + ) self.cycle_count_1.do_cancel() self.assertEqual( self.cycle_count_1.state, "cancelled", "Cycle count not set as cancelled." @@ -248,12 +245,10 @@ class TestStockCycleCount(common.TransactionCase): def test_view_methods(self): """Tests the methods used to handle views.""" - with self.assertRaises(AccessError): - self.cycle_count_1.action_create_inventory_adjustment() - self.cycle_count_1.sudo().action_view_inventory() + self.cycle_count_1.action_create_inventory_adjustment() + self.cycle_count_1.action_view_inventory() inv_count = self.cycle_count_1.inventory_adj_count - with self.assertRaises(AssertionError): - self.assertEqual(inv_count, 1, "View method failing.") + self.assertEqual(inv_count, 1, "View method failing.") rules = [ self.rule_periodic, self.rule_turnover, @@ -323,17 +318,21 @@ class TestStockCycleCount(common.TransactionCase): def test_cycle_count_contrains(self): """Test the various constrains defined in the inventory adjustment.""" - with self.assertRaises(AccessError): - self.cycle_count_1.action_create_inventory_adjustment() + self.cycle_count_1.action_create_inventory_adjustment() inventory = self.inventory_model.search( [("cycle_count_id", "=", self.cycle_count_1.id)] ) - inventory.product_ids = self.product1 - inventory.location_ids = False + with self.assertRaises(ValidationError): + inventory.product_ids = self.product1 + with self.assertRaises(ValidationError): + inventory.location_ids = False loc = self.stock_location_model.create( {"name": "Second Location", "usage": "internal"} ) - inventory.location_ids += loc - inventory.exclude_sublocation = False + with self.assertRaises(ValidationError): + inventory.location_ids += loc + with self.assertRaises(ValidationError): + inventory.exclude_sublocation = False company = self.env["res.company"].create({"name": "Test"}) - inventory.company_id = company + with self.assertRaises(ValidationError): + inventory.company_id = company