Merge pull request #35618 from s-aga-r/FIX-SBB-SERIAL-NO-QTY
fix: reset entries qty to `1` for serial item
This commit is contained in:
commit
e3802d1c3f
@ -127,6 +127,14 @@ frappe.ui.form.on('Serial and Batch Bundle', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggle_fields(frm) {
|
toggle_fields(frm) {
|
||||||
|
if (frm.doc.has_serial_no) {
|
||||||
|
frm.doc.entries.forEach(row => {
|
||||||
|
if (Math.abs(row.qty) !== 1) {
|
||||||
|
frappe.model.set_value(row.doctype, row.name, "qty", 1);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
frm.fields_dict.entries.grid.update_docfield_property(
|
frm.fields_dict.entries.grid.update_docfield_property(
|
||||||
'serial_no', 'read_only', !frm.doc.has_serial_no
|
'serial_no', 'read_only', !frm.doc.has_serial_no
|
||||||
);
|
);
|
||||||
@ -134,6 +142,10 @@ frappe.ui.form.on('Serial and Batch Bundle', {
|
|||||||
frm.fields_dict.entries.grid.update_docfield_property(
|
frm.fields_dict.entries.grid.update_docfield_property(
|
||||||
'batch_no', 'read_only', !frm.doc.has_batch_no
|
'batch_no', 'read_only', !frm.doc.has_batch_no
|
||||||
);
|
);
|
||||||
|
|
||||||
|
frm.fields_dict.entries.grid.update_docfield_property(
|
||||||
|
'qty', 'read_only', frm.doc.has_serial_no
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
set_queries(frm) {
|
set_queries(frm) {
|
||||||
@ -198,9 +210,9 @@ frappe.ui.form.on('Serial and Batch Bundle', {
|
|||||||
|
|
||||||
|
|
||||||
frappe.ui.form.on("Serial and Batch Entry", {
|
frappe.ui.form.on("Serial and Batch Entry", {
|
||||||
ledgers_add(frm, cdt, cdn) {
|
entries_add(frm, cdt, cdn) {
|
||||||
if (frm.doc.warehouse) {
|
if (frm.doc.warehouse) {
|
||||||
locals[cdt][cdn].warehouse = frm.doc.warehouse;
|
frappe.model.set_value(cdt, cdn, 'warehouse', frm.doc.warehouse);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
@ -133,7 +133,7 @@ class SerialandBatchBundle(Document):
|
|||||||
def calculate_total_qty(self, save=True):
|
def calculate_total_qty(self, save=True):
|
||||||
self.total_qty = 0.0
|
self.total_qty = 0.0
|
||||||
for d in self.entries:
|
for d in self.entries:
|
||||||
d.qty = abs(d.qty) if d.qty else 0
|
d.qty = 1 if self.has_serial_no and abs(d.qty) > 1 else abs(d.qty) if d.qty else 0
|
||||||
d.stock_value_difference = abs(d.stock_value_difference) if d.stock_value_difference else 0
|
d.stock_value_difference = abs(d.stock_value_difference) if d.stock_value_difference else 0
|
||||||
if self.type_of_transaction == "Outward":
|
if self.type_of_transaction == "Outward":
|
||||||
d.qty *= -1
|
d.qty *= -1
|
||||||
|
Loading…
Reference in New Issue
Block a user