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
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");