fix: serial and batch bundle return not working (#38754)
* fix: serial and batch bundle return not working * test: added test case for delivery note return against denormalized serial no
This commit is contained in:
@@ -32,22 +32,39 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
||||
});
|
||||
|
||||
this.dialog.show();
|
||||
|
||||
let qty = this.item.stock_qty || this.item.transfer_qty || this.item.qty;
|
||||
this.dialog.set_value("qty", qty).then(() => {
|
||||
if (this.item.serial_no) {
|
||||
this.dialog.set_value("scan_serial_no", this.item.serial_no);
|
||||
frappe.model.set_value(this.item.doctype, this.item.name, 'serial_no', '');
|
||||
} else if (this.item.batch_no) {
|
||||
this.dialog.set_value("scan_batch_no", this.item.batch_no);
|
||||
frappe.model.set_value(this.item.doctype, this.item.name, 'batch_no', '');
|
||||
}
|
||||
|
||||
this.dialog.fields_dict.entries.grid.refresh();
|
||||
});
|
||||
|
||||
this.$scan_btn = this.dialog.$wrapper.find(".link-btn");
|
||||
this.$scan_btn.css("display", "inline");
|
||||
|
||||
let qty = this.item.stock_qty || this.item.transfer_qty || this.item.qty;
|
||||
|
||||
if (this.item?.is_rejected) {
|
||||
qty = this.item.rejected_qty;
|
||||
}
|
||||
|
||||
qty = Math.abs(qty);
|
||||
if (qty > 0) {
|
||||
this.dialog.set_value("qty", qty).then(() => {
|
||||
if (this.item.serial_no && !this.item.serial_and_batch_bundle) {
|
||||
let serial_nos = this.item.serial_no.split('\n');
|
||||
if (serial_nos.length > 1) {
|
||||
serial_nos.forEach(serial_no => {
|
||||
this.dialog.fields_dict.entries.df.data.push({
|
||||
serial_no: serial_no,
|
||||
batch_no: this.item.batch_no
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.dialog.set_value("scan_serial_no", this.item.serial_no);
|
||||
}
|
||||
frappe.model.set_value(this.item.doctype, this.item.name, 'serial_no', '');
|
||||
} else if (this.item.batch_no && !this.item.serial_and_batch_bundle) {
|
||||
this.dialog.set_value("scan_batch_no", this.item.batch_no);
|
||||
frappe.model.set_value(this.item.doctype, this.item.name, 'batch_no', '');
|
||||
}
|
||||
|
||||
this.dialog.fields_dict.entries.grid.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get_serial_no_filters() {
|
||||
@@ -467,13 +484,13 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
||||
}
|
||||
|
||||
render_data() {
|
||||
if (!this.frm.is_new() && this.bundle) {
|
||||
if (this.bundle) {
|
||||
frappe.call({
|
||||
method: 'erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.get_serial_batch_ledgers',
|
||||
args: {
|
||||
item_code: this.item.item_code,
|
||||
name: this.bundle,
|
||||
voucher_no: this.item.parent,
|
||||
voucher_no: !this.frm.is_new() ? this.item.parent : "",
|
||||
}
|
||||
}).then(r => {
|
||||
if (r.message) {
|
||||
|
||||
Reference in New Issue
Block a user