fix: auto increment qty if item table has no items

This commit is contained in:
Rohit Waghchaure 2022-11-02 20:38:07 +05:30
parent e1f9ba78e5
commit e5b19e3f70
2 changed files with 12 additions and 4 deletions

View File

@ -341,6 +341,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
this.set_dynamic_labels();
this.setup_sms();
this.setup_quality_inspection();
this.validate_has_items();
}
scan_barcode() {
@ -348,6 +349,12 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
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() {
var me = this;
var taxes_and_charges_field = frappe.meta.get_docfield(me.frm.doc.doctype, "taxes_and_charges",

View File

@ -103,6 +103,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
row = frappe.model.add_child(this.frm.doc, cur_grid.doctype, this.items_table_name);
// 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.has_items = false;
}
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}) => {
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);
} else {
increment().then((value) => resolve(value));
}
});
}
@ -207,7 +210,6 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
return;
}
debugger
if (e.target.value) {
this.scan_api_call(e.target.value, (r) => {
if (r.message) {
@ -280,7 +282,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
}
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", "");
if (item_code === scanned_item &&
@ -357,7 +359,6 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
}
async set_batch_no(row, batch_no) {
debugger
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);
}