revert "remove subquery for optimization"

- we are using OR between two queries here: 53ec6621bc/app/services/search_orders.rb (L31-L32)
- so to make it compatible with this, had to revert

Throws following error:
Relation passed to #or must be structurally compatible. Incompatible values: [:left_outer_joins]
This commit is contained in:
Ahmed Ejaz
2025-03-05 04:14:51 +05:00
parent 3474734418
commit acdffb0aa1

View File

@@ -24,7 +24,8 @@ module Permissions
# Any orders that the user can edit
def editable_orders
orders = if @user.can_manage_line_items_in_orders_only?
produced_orders.joins(:distributor).where(
Spree::Order.joins(:distributor).where(
id: produced_orders.select(:id),
distributor: { enable_producers_to_edit_orders: true }
)
else