Don't allow a min. stock amount for child products when the parent has "Accumulate sub products min. stock amount" set (references #1409)

This commit is contained in:
Bernd Bestel 2021-07-04 17:36:44 +02:00
parent 734e174442
commit 0dc37fb361
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 34 additions and 0 deletions

View File

@ -505,4 +505,36 @@ else if (Grocy.EditMode === 'create')
}
}
Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
{
var parentProductId = $(e.target).val();
if (parentProductId)
{
Grocy.Api.Get('objects/products/' + parentProductId,
function(parentProduct)
{
if (BoolVal(parentProduct.cumulate_min_stock_amount_of_sub_products))
{
$("#min_stock_amount").attr("disabled", "");
}
else
{
$('#min_stock_amount').removeAttr("disabled");
}
},
function(xhr)
{
console.error(xhr);
}
);
}
else
{
$('#min_stock_amount').removeAttr("disabled");
}
});
Grocy.FrontendHelpers.ValidateForm("product-form");
Grocy.Components.ProductPicker.GetPicker().trigger("change");

View File

@ -606,8 +606,10 @@
title="{{ $__t('grocycode is a unique referer to this product in your grocy instance - print it onto a label and scan it like any other barcode') }}"></i>
</h4>
<p>
@if($mode == 'edit')
<img src="{{ $U('/product/' . $product->id . '/grocycode?size=60') }}"
class="float-lg-left">
@endif
</p>
<p>
<a class="btn btn-outline-primary btn-sm"