';
// Batch number in same column than the stock movement picto
@@ -1510,9 +1510,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
});
function updateselectbatchbywarehouse() {
- var element = $("select[name*='idwarehouse']");
-
- element.change(function () {
+ $(document).on('change', "select[name*='idwarehouse']", function () {
+ console.log("We change warehouse so we update the list of possible batch number");
var selectwarehouse = $(this);
@@ -1529,13 +1528,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
action: "updateselectbatchbywarehouse",
permissiontoproduce: ,
warehouse_id: $(this).val(),
+ token: '',
product_id: $("input[name='" + product_element_name + "']").val()
}
}).done(function (data) {
selectbatch.empty();
- var data = JSON.parse(data);
+ if (typeof data == "object") {
+ console.log("data is already type object, no need to parse it");
+ } else {
+ console.log("data is type "+(typeof data));
+ data = JSON.parse(data);
+ }
selectbatch.append($('