fix: auto increment qty if item table has no items
This commit is contained in:
parent
e1f9ba78e5
commit
e5b19e3f70
@ -341,6 +341,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
this.set_dynamic_labels();
|
this.set_dynamic_labels();
|
||||||
this.setup_sms();
|
this.setup_sms();
|
||||||
this.setup_quality_inspection();
|
this.setup_quality_inspection();
|
||||||
|
this.validate_has_items();
|
||||||
}
|
}
|
||||||
|
|
||||||
scan_barcode() {
|
scan_barcode() {
|
||||||
@ -348,6 +349,12 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
barcode_scanner.process_scan();
|
barcode_scanner.process_scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validate_has_items () {
|
||||||
|
let table = this.frm.doc.items;
|
||||||
|
this.frm.has_items = (table && table.length
|
||||||
|
&& table[0].qty && table[0].item_code);
|
||||||
|
}
|
||||||
|
|
||||||
apply_default_taxes() {
|
apply_default_taxes() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var taxes_and_charges_field = frappe.meta.get_docfield(me.frm.doc.doctype, "taxes_and_charges",
|
var taxes_and_charges_field = frappe.meta.get_docfield(me.frm.doc.doctype, "taxes_and_charges",
|
||||||
|
|||||||
@ -103,6 +103,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
row = frappe.model.add_child(this.frm.doc, cur_grid.doctype, this.items_table_name);
|
row = frappe.model.add_child(this.frm.doc, cur_grid.doctype, this.items_table_name);
|
||||||
// trigger any row add triggers defined on child table.
|
// trigger any row add triggers defined on child table.
|
||||||
this.frm.script_manager.trigger(`${this.items_table_name}_add`, row.doctype, row.name);
|
this.frm.script_manager.trigger(`${this.items_table_name}_add`, row.doctype, row.name);
|
||||||
|
this.frm.has_items = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.is_duplicate_serial_no(row, serial_no)) {
|
if (this.is_duplicate_serial_no(row, serial_no)) {
|
||||||
@ -157,8 +158,10 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
frappe.prompt(__("Please enter quantity for item {0}", [item_code]), ({value}) => {
|
frappe.prompt(__("Please enter quantity for item {0}", [item_code]), ({value}) => {
|
||||||
increment(value).then((value) => resolve(value));
|
increment(value).then((value) => resolve(value));
|
||||||
});
|
});
|
||||||
} else {
|
} else if (this.frm.has_items) {
|
||||||
this.prepare_item_for_scan(row, item_code, barcode, batch_no, serial_no);
|
this.prepare_item_for_scan(row, item_code, barcode, batch_no, serial_no);
|
||||||
|
} else {
|
||||||
|
increment().then((value) => resolve(value));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -207,7 +210,6 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
debugger
|
|
||||||
if (e.target.value) {
|
if (e.target.value) {
|
||||||
this.scan_api_call(e.target.value, (r) => {
|
this.scan_api_call(e.target.value, (r) => {
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
@ -280,7 +282,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_dialog_values(scanned_item, r) {
|
update_dialog_values(scanned_item, r) {
|
||||||
const {item_code, barcode, batch_no, serial_no, uom} = r.message;
|
const {item_code, barcode, batch_no, serial_no} = r.message;
|
||||||
|
|
||||||
this.dialog.set_value("barcode_scanner", "");
|
this.dialog.set_value("barcode_scanner", "");
|
||||||
if (item_code === scanned_item &&
|
if (item_code === scanned_item &&
|
||||||
@ -357,7 +359,6 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async set_batch_no(row, batch_no) {
|
async set_batch_no(row, batch_no) {
|
||||||
debugger
|
|
||||||
if (batch_no && frappe.meta.has_field(row.doctype, this.batch_no_field)) {
|
if (batch_no && frappe.meta.has_field(row.doctype, this.batch_no_field)) {
|
||||||
await frappe.model.set_value(row.doctype, row.name, this.batch_no_field, batch_no);
|
await frappe.model.set_value(row.doctype, row.name, this.batch_no_field, batch_no);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user