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.
This commit is contained in:
Florian Lentsch 2021-02-05 11:55:41 +01:00 committed by Patrick Gansterer
parent a96dbd563b
commit e3c720589d

View file

@ -151,8 +151,7 @@ module OrdersHelper
if order.stockit? if order.stockit?
content_tag :div, t('orders.index.action_receive'), class: "btn disabled #{options[:class]}" content_tag :div, t('orders.index.action_receive'), class: "btn disabled #{options[:class]}"
else 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 order.received?} #{options[:class]}"
link_to t('orders.index.action_receive'), receive_order_path(order), class: "btn#{' btn-success' unless was_received} #{options[:class]}"
end end
end end
end end