diff --git a/changelog/58_UNRELEASED_2020-xx-xx.md b/changelog/58_UNRELEASED_2020-xx-xx.md
index ae4b3779..133fddea 100644
--- a/changelog/58_UNRELEASED_2020-xx-xx.md
+++ b/changelog/58_UNRELEASED_2020-xx-xx.md
@@ -18,6 +18,7 @@
- Fixed that the form validation limits for the amount input and products with enabled tare weight handling were wrong
- Fixed that the price was saved wrong for products with a different purchase/stock quantity unit when using "Total price" on purchase (resulted for example in wrong recipe costs)
- Fixed that undoing "product-opened"-actions was not possible
+- Fixed/improved consuming from the stock overview page for products with enabled tare weight handling ("consume 1" button is now disabled for such products, "consume all" works again)
### Shopping list fixes
- Fixed that the "shopping list to stock workflow"-dialog was not visible in compact view
diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js
index 1735e3f8..8d90abf1 100644
--- a/public/viewjs/stockoverview.js
+++ b/public/viewjs/stockoverview.js
@@ -77,6 +77,7 @@ $(document).on('click', '.product-consume-button', function(e)
var productId = $(e.currentTarget).attr('data-product-id');
var consumeAmount = $(e.currentTarget).attr('data-consume-amount');
+ var originalTotalStockAmount = $(e.currentTarget).attr('data-original-total-stock-amount');
var wasSpoiled = $(e.currentTarget).hasClass("product-consume-button-spoiled");
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount, 'spoiled': wasSpoiled },
@@ -85,7 +86,15 @@ $(document).on('click', '.product-consume-button', function(e)
Grocy.Api.Get('stock/products/' + productId,
function(result)
{
- var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '
' + __t("Undo") + '';
+ if (result.product.enable_tare_weight_handling == 1)
+ {
+ var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(originalTotalStockAmount).toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '
' + __t("Undo") + '';
+ }
+ else
+ {
+ var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '
' + __t("Undo") + '';
+ }
+
if (wasSpoiled)
{
toastMessage += " (" + __t("Spoiled") + ")";
diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php
index cbe628ce..98fe643c 100644
--- a/views/stockoverview.blade.php
+++ b/views/stockoverview.blade.php
@@ -100,7 +100,7 @@
@foreach($currentStock as $currentStockEntry)