From e3c720589d7544d96b084bad269f50657edca02a Mon Sep 17 00:00:00 2001 From: Florian Lentsch Date: Fri, 5 Feb 2021 11:55:41 +0100 Subject: [PATCH] On #779 Use new `received` state for 'Receive' button in orders index This slightly increases the performance as the associated order_articles no longer need to be fetched. --- app/helpers/orders_helper.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/helpers/orders_helper.rb b/app/helpers/orders_helper.rb index b600860f..1a99ba54 100644 --- a/app/helpers/orders_helper.rb +++ b/app/helpers/orders_helper.rb @@ -151,8 +151,7 @@ module OrdersHelper if order.stockit? content_tag :div, t('orders.index.action_receive'), class: "btn disabled #{options[:class]}" else - was_received = order.order_articles.where('units_received IS NOT NULL').any? - link_to t('orders.index.action_receive'), receive_order_path(order), class: "btn#{' btn-success' unless was_received} #{options[:class]}" + link_to t('orders.index.action_receive'), receive_order_path(order), class: "btn#{' btn-success' unless order.received?} #{options[:class]}" end end end