Fix variant_overrides permissions for overrides that belong to the supplier herself

This commit is contained in:
luisramos0
2018-10-31 11:23:29 +00:00
parent 1fbeb43c3a
commit 079d4e0bf5
2 changed files with 13 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
class AllowAllSuppliersOwnVariantOverrides < ActiveRecord::Migration
def up
# This migration is fixing a detail of previous migration RevokeVariantOverrideswithoutPermissions
# Here we allow all variant_overrides where hub_id is the products supplier_id
# This is needed when the supplier herself uses the inventory to manage stock and not the catalog
owned_variant_overrides = VariantOverride.unscoped
.joins(variant: :product).where("spree_products.supplier_id = variant_overrides.hub_id")
owned_variant_overrides.update_all(permission_revoked_at: nil)
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20181020103501) do
ActiveRecord::Schema.define(:version => 20181031105158) do
create_table "account_invoices", :force => true do |t|
t.integer "user_id", :null => false