Ant贸n
11/25/2022, 12:18 PM# config/initializers/spree.rb
config.roles.assign_permissions :warehouse_admin, [
'Spree::PermissionSets::RestrictedStockManagement'
]
but the user sees all warehouse. The problem is because of the query that is launched
this is the query
Where does the OR ("spree_stock_locations"."active" = TRUE) ?
Spree::StockLocation Load (0.3ms) SELECT "spree_stock_locations".* FROM "spree_stock_locations" WHERE (("spree_stock_locations"."id" = 3) OR ("spree_stock_locations"."active" = TRUE)) /* loading for inspect */ LIMIT $1 [["LIMIT", 11]]
I have tried having a custom permissions class but the result is the same.
#app/models/spree/permissions_sets/warehouse_admin.rb(
require 'cancan'
module Spree
module PermissionSets
class WarehouseAdmin < Spree::PermissionSets::Base
def activate!
can :read, Spree::StockLocation, id: location_ids
end
def location_ids
@location_ids ||= user.stock_locations.pluck(:id)
end
end
end
end
# config/initializers/spree.rb
config.roles.assign_permissions :warehouse_admin, [
'Spree::PermissionSets::WarehouseAdmin'
]
thanks!!waiting_for_dev
11/25/2022, 3:34 PMAnt贸n
11/25/2022, 8:43 PMSpree::Admin::StockItemsController class in the load_stock_management_data method with @stock_locations = Spree::StockLocation.accessible_by(current_ability)waiting_for_dev
11/28/2022, 10:04 AMAnt贸n
11/28/2022, 11:12 AMwaiting_for_dev
11/28/2022, 11:57 AM