diff --git a/grocy.openapi.json b/grocy.openapi.json
index 4e76d30f..f5f5bf41 100644
--- a/grocy.openapi.json
+++ b/grocy.openapi.json
@@ -4797,6 +4797,9 @@
"has_childs": {
"type": "boolean",
"description": "True when the product is a parent product of others"
+ },
+ "default_location": {
+ "$ref": "#/components/schemas/Location"
}
},
"example": {
@@ -4862,7 +4865,8 @@
"row_created_timestamp": "2019-05-02 20:12:25"
},
"average_shelf_life_days": -1,
- "spoil_rate_percent": 0
+ "spoil_rate_percent": 0,
+ "default_consume_location": null
}
},
"ProductPriceHistory": {
diff --git a/localization/strings.pot b/localization/strings.pot
index 7585b951..a7c88736 100644
--- a/localization/strings.pot
+++ b/localization/strings.pot
@@ -2332,3 +2332,6 @@ msgstr ""
msgid "When enabled, on marking this product as opened, the corresponding amount will be moved to the default consume location"
msgstr ""
+
+msgid "Moved to %1$s"
+msgstr ""
diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js
index 6bb6adbf..91bfd144 100644
--- a/public/viewjs/consume.js
+++ b/public/viewjs/consume.js
@@ -189,6 +189,11 @@ $('#save-mark-as-open-button').on('click', function(e)
Grocy.FrontendHelpers.EndUiBusy("consume-form");
toastr.success(__t('Marked %1$s of %2$s as opened', parseFloat(jsonForm.amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name) + '
' + __t("Undo") + '');
+ if (productDetails.product.move_on_open == 1)
+ {
+ toastr.info('' + __t("Moved to %1$s", productDetails.default_consume_location.name) + " ");
+ }
+
if (BoolVal(Grocy.UserSettings.stock_default_consume_amount_use_quick_consume_amount))
{
$('#display_amount').val(productDetails.product.quick_consume_amount);
diff --git a/public/viewjs/stockentries.js b/public/viewjs/stockentries.js
index 47d7a84f..03a1dec5 100644
--- a/public/viewjs/stockentries.js
+++ b/public/viewjs/stockentries.js
@@ -126,10 +126,26 @@ $(document).on('click', '.product-open-button', function(e)
Grocy.Api.Post('stock/products/' + productId + '/open', { 'amount': 1, 'stock_entry_id': specificStockEntryId },
function(bookingResponse)
{
- button.addClass("disabled");
- Grocy.FrontendHelpers.EndUiBusy();
- toastr.success(__t('Marked %1$s of %2$s as opened', 1 + " " + productQuName, productName) + '
' + __t("Undo") + '');
- RefreshStockEntryRow(stockRowId);
+ Grocy.Api.Get('stock/products/' + productId,
+ function(result)
+ {
+ button.addClass("disabled");
+ Grocy.FrontendHelpers.EndUiBusy();
+ toastr.success(__t('Marked %1$s of %2$s as opened', 1 + " " + productQuName, productName) + '
' + __t("Undo") + '');
+
+ if (result.product.move_on_open == 1)
+ {
+ toastr.info('' + __t("Moved to %1$s", result.default_consume_location.name) + " ");
+ }
+
+ RefreshStockEntryRow(stockRowId);
+ },
+ function(xhr)
+ {
+ Grocy.FrontendHelpers.EndUiBusy();
+ console.error(xhr);
+ }
+ );
},
function(xhr)
{
diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js
index 1762c3ee..3cb5bcb4 100755
--- a/public/viewjs/stockoverview.js
+++ b/public/viewjs/stockoverview.js
@@ -208,6 +208,12 @@ $(document).on('click', '.product-open-button', function(e)
Grocy.FrontendHelpers.EndUiBusy();
toastr.success(__t('Marked %1$s of %2$s as opened', parseFloat(amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + productQuName, productName) + '
' + __t("Undo") + '');
+
+ if (result.product.move_on_open == 1)
+ {
+ toastr.info('' + __t("Moved to %1$s", result.default_consume_location.name) + " ");
+ }
+
RefreshStatistics();
RefreshProductRow(productId);
},
diff --git a/services/StockService.php b/services/StockService.php
index c184605f..9e75e49b 100644
--- a/services/StockService.php
+++ b/services/StockService.php
@@ -734,6 +734,12 @@ class StockService extends BaseService
}
$spoilRate = ($consumeCountSpoiled * 100.0) / $consumeCount;
+ $defaultConsumeLocation = null;
+ if (!empty($product->default_consume_location_id))
+ {
+ $defaultConsumeLocation = $this->getDatabase()->locations($product->default_consume_location_id);
+ }
+
return [
'product' => $product,
'product_barcodes' => $productBarcodes,
@@ -758,6 +764,7 @@ class StockService extends BaseService
'spoil_rate_percent' => $spoilRate,
'is_aggregated_amount' => $stockCurrentRow->is_aggregated_amount,
'has_childs' => $this->getDatabase()->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
+ 'default_consume_location' => $defaultConsumeLocation
];
}