Merge pull request #7330 from Matt-Yorkley/adjustments-deleted-originator

Update unscoping of deleted_at on Adjustment originator association
This commit is contained in:
Pau Pérez Fabregat
2021-04-09 09:15:46 +02:00
committed by GitHub
4 changed files with 10 additions and 9 deletions

View File

@@ -38,7 +38,7 @@ module Spree
belongs_to :adjustable, polymorphic: true
belongs_to :source, polymorphic: true
belongs_to :originator, polymorphic: true
belongs_to :originator, -> { with_deleted }, polymorphic: true
belongs_to :order, class_name: "Spree::Order"
belongs_to :tax_rate, -> { where spree_adjustments: { originator_type: 'Spree::TaxRate' } },
@@ -139,13 +139,6 @@ module Spree
included_tax.positive?
end
# Allow accessing soft-deleted originator objects
def originator
return if originator_type.blank?
originator_type.constantize.unscoped { super }
end
private
def update_adjustable_adjustment_total

View File

@@ -2,6 +2,8 @@
module Spree
class ReturnAuthorization < ActiveRecord::Base
acts_as_paranoid
belongs_to :order, class_name: 'Spree::Order', inverse_of: :return_authorizations
has_many :inventory_units, inverse_of: :return_authorization

View File

@@ -0,0 +1,5 @@
class AddDeletedAtToReturnAuthorizations < ActiveRecord::Migration[5.0]
def change
add_column :spree_return_authorizations, :deleted_at, :datetime
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20210329123820) do
ActiveRecord::Schema.define(version: 20210407170804) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -754,6 +754,7 @@ ActiveRecord::Schema.define(version: 20210329123820) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "stock_location_id"
t.datetime "deleted_at"
end
create_table "spree_roles", force: :cascade do |t|