diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index 8b95992855..9d9bd0ac7e 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -140,6 +140,15 @@ module Spree end } + scope :editable_by_producers, ->(enterprises) { + joins( + :distributor, line_items: :supplier + ).where( + supplier: enterprises, + distributor: { enable_producers_to_edit_orders: true } + ) + } + scope :distributed_by_user, lambda { |user| if user.admin? where(nil) @@ -171,14 +180,6 @@ module Spree scope :invoiceable, -> { where(state: [:complete, :resumed]) } scope :by_state, lambda { |state| where(state:) } scope :not_state, lambda { |state| where.not(state:) } - scope :editable_by_producers, ->(enterprises) { - joins( - :distributor, line_items: :supplier - ).where( - supplier: { id: enterprises.ids }, - distributor: { enable_producers_to_edit_orders: true } - ) - } def initialize(*_args) @checkout_processing = nil