diff --git a/lib/redmine_qbo/patches/query_patch.rb b/lib/redmine_qbo/patches/query_patch.rb index 8c657af..6be9c51 100644 --- a/lib/redmine_qbo/patches/query_patch.rb +++ b/lib/redmine_qbo/patches/query_patch.rb @@ -16,12 +16,17 @@ module RedmineQbo def base_scope scope = super + if filters['customer_name'].present? scope = scope.left_outer_joins(:customer) end + + if has_column?(:customer) || filters['customer_name'].present? + scope = scope.includes(:customer) + end + scope end - # Add qbo options to the aviable columns def available_columns