Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add nested attributes for stock movements to stock transfer (#12216)

Damian Kaczmarczykce00f163519d
diff --git a/core/app/models/spree/stock_movement.rb b/core/app/models/spree/stock_movement.rb
index b3835f0028..b2f0a2c854 100644
--- a/core/app/models/spree/stock_movement.rb
+++ b/core/app/models/spree/stock_movement.rb
@@ -23,7 +23,7 @@ module Spree
scope :recent, -> { order(created_at: :desc) }
- delegate :variant, to: :stock_item
+ delegate :variant, to: :stock_item, allow_nil: true
delegate :product, to: :variant
self.whitelisted_ransackable_attributes = ['quantity']
diff --git a/core/app/models/spree/stock_transfer.rb b/core/app/models/spree/stock_transfer.rb
index 34cfce2266..7faeeb3ae8 100644
--- a/core/app/models/spree/stock_transfer.rb
+++ b/core/app/models/spree/stock_transfer.rb
@@ -9,6 +9,7 @@ module Spree
end
has_many :stock_movements, as: :originator
+ accepts_nested_attributes_for :stock_movements, reject_if: :all_blank
belongs_to :source_location, class_name: 'StockLocation', optional: true
belongs_to :destination_location, class_name: 'StockLocation'