[fix] values update in items in invoices
This commit is contained in:
parent
577e4c4e28
commit
5f389c999a
@ -30,7 +30,6 @@
|
||||
"public/js/payment/payment_details.html",
|
||||
"public/js/templates/item_selector.html",
|
||||
"public/js/utils/item_selector.js",
|
||||
"public/js/utils/serial_no_batch_selector.js",
|
||||
"public/js/help_links.js",
|
||||
"public/js/schools/student_button.html",
|
||||
"public/js/schools/assessment_result_tool.html"
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js");
|
||||
|
||||
erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
setup: function() {
|
||||
this._super();
|
||||
@ -265,13 +267,12 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
item_code: function(doc, cdt, cdn, from_barcode) {
|
||||
var me = this;
|
||||
var item = frappe.get_doc(cdt, cdn);
|
||||
var update_stock = 0, show_batch_dialog = 1;
|
||||
var update_stock = 0, show_batch_dialog = 0;
|
||||
|
||||
if(['Sales Invoice', 'Purchase Invoice'].includes(me.frm.doc.doctype)) {
|
||||
if(['Sales Invoice', 'Purchase Invoice'].includes(this.frm.doc.doctype)) {
|
||||
update_stock = cint(me.frm.doc.update_stock);
|
||||
show_batch_dialog = update_stock;
|
||||
} else {
|
||||
update_stock = 0;
|
||||
} else if(this.frm.doc.doctype === 'Delivery Note') {
|
||||
show_batch_dialog = 1;
|
||||
}
|
||||
|
||||
@ -320,7 +321,12 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
|
||||
me.toggle_conversion_factor(item);
|
||||
if(show_batch_dialog) {
|
||||
let d = r.message;
|
||||
var d = locals[cdt][cdn];
|
||||
$.each(r.message, function(k, v) {
|
||||
if(!d[k]) {
|
||||
d[k] = v;
|
||||
}
|
||||
});
|
||||
let serial_no_batch_selector = new erpnext.SerialNoBatchSelector({
|
||||
frm: me.frm,
|
||||
item: d,
|
||||
|
@ -5,6 +5,10 @@ erpnext.SerialNoBatchSelector = Class.extend({
|
||||
// frm, item, warehouse_details, has_batch, oldest
|
||||
let d = this.item;
|
||||
|
||||
if(frappe.flags.autofill_item_code) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't show dialog if batch no or serial no already set
|
||||
if(d && d.has_batch_no && !d.batch_no) {
|
||||
this.has_batch = 1;
|
||||
@ -110,29 +114,29 @@ erpnext.SerialNoBatchSelector = Class.extend({
|
||||
set_items: function() {
|
||||
var me = this;
|
||||
|
||||
function get_row_fields(index) {
|
||||
index += me.item.idx - 1;
|
||||
console.log(index, me.frm.fields_dict.items.grid.grid_rows);
|
||||
return me.frm.fields_dict.items.grid
|
||||
.grid_rows[index].on_grid_fields_dict;
|
||||
}
|
||||
|
||||
if(this.has_batch) {
|
||||
this.values.batches.map((batch, i) => {
|
||||
let row = (i !== 0) ? this.frm.add_child("items") : this.item;
|
||||
refresh_field("items");
|
||||
let fields = (i !== 0) ? get_row_fields(i) : null;
|
||||
this.map_row_values(fields, row, batch, 'batch_no',
|
||||
if(i !== 0) {
|
||||
// let index = i + me.item.idx - 1;
|
||||
// let grid_row = me.frm.fields_dict.items.grid.grid_rows[index];
|
||||
// grid_row.toggle_editable_row();
|
||||
// grid_row.on_grid_fields_dict.item_code.set_value(this.item_code);
|
||||
row.item_code = this.item_code;
|
||||
}
|
||||
this.map_row_values(row, batch, 'batch_no',
|
||||
'selected_qty', this.values.warehouse);
|
||||
});
|
||||
} else {
|
||||
this.map_row_values(null, this.item, this.values, 'serial_no', 'qty');
|
||||
this.map_row_values(this.item, this.values, 'serial_no', 'qty');
|
||||
}
|
||||
refresh_field("items");
|
||||
},
|
||||
|
||||
map_row_values: function(row_fields, row, values, number, qty_field, warehouse) {
|
||||
map_row_values: function(row, values, number, qty_field, warehouse) {
|
||||
row.qty = values[qty_field];
|
||||
|
||||
row[number] = values[number];
|
||||
if(this.warehouse_details.type === 'Source Warehouse') {
|
||||
row.s_warehouse = values.warehouse || warehouse;
|
||||
} else if(this.warehouse_details.type === 'Target Warehouse') {
|
||||
@ -141,14 +145,6 @@ erpnext.SerialNoBatchSelector = Class.extend({
|
||||
row.warehouse = values.warehouse || warehouse;
|
||||
}
|
||||
|
||||
row[number] = values[number];
|
||||
refresh_field("items");
|
||||
|
||||
// Set item_code after setting batch
|
||||
// so that dialog does not fire for inserted rows
|
||||
if(row_fields) {
|
||||
row_fields.item_code.set_value(this.item_code);
|
||||
}
|
||||
},
|
||||
|
||||
bind_qty: function() {
|
||||
@ -230,7 +226,6 @@ erpnext.SerialNoBatchSelector = Class.extend({
|
||||
return {filters: {item: me.item_code }};
|
||||
},
|
||||
onchange: function(e) {
|
||||
console.log(this);
|
||||
if(this.get_value().length === 0) {
|
||||
this.grid_row.on_grid_fields_dict
|
||||
.available_qty.set_value(0);
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.provide("erpnext.stock");
|
||||
frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js");
|
||||
|
||||
frappe.ui.form.on('Stock Entry', {
|
||||
setup: function(frm) {
|
||||
@ -176,7 +177,6 @@ frappe.ui.form.on('Stock Entry Detail', {
|
||||
d[k] = v;
|
||||
});
|
||||
erpnext.stock.select_batch_and_serial_no(frm, d);
|
||||
refresh_field("items");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user