fix: test case and removed outward field

This commit is contained in:
Rohit Waghchaure
2023-06-15 12:54:43 +05:30
parent f968f0f257
commit 1c2fe085b5
9 changed files with 66 additions and 31 deletions

View File

@@ -2340,14 +2340,11 @@ erpnext.show_serial_batch_selector = function (frm, item_row, callback, on_close
frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js", function() {
if (in_list(["Sales Invoice", "Delivery Note"], frm.doc.doctype)) {
item_row.outward = frm.doc.is_return ? 0 : 1;
item_row.type_of_transaction = frm.doc.is_return ? "Inward" : "Outward";
} else {
item_row.outward = frm.doc.is_return ? 1 : 0;
item_row.type_of_transaction = frm.doc.is_return ? "Outward" : "Inward";
}
item_row.type_of_transaction = (item_row.outward === 1
? "Outward":"Inward");
new erpnext.SerialBatchPackageSelector(frm, item_row, (r) => {
if (r) {
let update_values = {

View File

@@ -350,6 +350,38 @@ $.extend(erpnext.utils, {
}
},
pick_serial_and_batch_bundle(frm, cdt, cdn, type_of_transaction, warehouse_field) {
let item_row = frappe.get_doc(cdt, cdn);
item_row.type_of_transaction = type_of_transaction;
frappe.db.get_value("Item", item_row.item_code, ["has_batch_no", "has_serial_no"])
.then((r) => {
item_row.has_batch_no = r.message.has_batch_no;
item_row.has_serial_no = r.message.has_serial_no;
frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js", function() {
new erpnext.SerialBatchPackageSelector(frm, item_row, (r) => {
if (r) {
let update_values = {
"serial_and_batch_bundle": r.name,
"qty": Math.abs(r.total_qty)
}
if (!warehouse_field) {
warehouse_field = "warehouse";
}
if (r.warehouse) {
update_values[warehouse_field] = r.warehouse;
}
frappe.model.set_value(item_row.doctype, item_row.name, update_values);
}
});
});
});
}
});
erpnext.utils.select_alternate_items = function(opts) {

View File

@@ -26,7 +26,7 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
title: this.item?.title || primary_label,
fields: this.get_dialog_fields(),
primary_action_label: primary_label,
primary_action: () => this.update_ledgers(),
primary_action: () => this.update_bundle_entries(),
secondary_action_label: __('Edit Full Form'),
secondary_action: () => this.edit_full_form(),
});
@@ -36,7 +36,7 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
}
get_serial_no_filters() {
let warehouse = this.item?.outward ?
let warehouse = this.item?.type_of_transaction === "Outward" ?
(this.item.warehouse || this.item.s_warehouse) : "";
return {
@@ -121,7 +121,7 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
});
}
if (this.item?.outward) {
if (this.item?.type_of_transaction === "Outward") {
fields = [...this.get_filter_fields(), ...fields];
} else {
fields = [...fields, ...this.get_attach_field()];
@@ -267,7 +267,7 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
label: __('Batch No'),
in_list_view: 1,
get_query: () => {
if (!this.item.outward) {
if (this.item.type_of_transaction !== "Outward") {
return {
filters: {
'item': this.item.item_code,
@@ -356,7 +356,7 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
this.dialog.fields_dict.entries.grid.refresh();
}
update_ledgers() {
update_bundle_entries() {
let entries = this.dialog.get_values().entries;
let warehouse = this.dialog.get_value('warehouse');
@@ -390,7 +390,7 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
_new.warehouse = this.get_warehouse();
_new.has_serial_no = this.item.has_serial_no;
_new.has_batch_no = this.item.has_batch_no;
_new.type_of_transaction = this.get_type_of_transaction();
_new.type_of_transaction = this.item.type_of_transaction;
_new.company = this.frm.doc.company;
_new.voucher_type = this.frm.doc.doctype;
bundle_id = _new.name;
@@ -401,15 +401,11 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
}
get_warehouse() {
return (this.item?.outward ?
return (this.item?.type_of_transaction === "Outward" ?
(this.item.warehouse || this.item.s_warehouse)
: (this.item.warehouse || this.item.t_warehouse));
}
get_type_of_transaction() {
return (this.item?.outward ? 'Outward' : 'Inward');
}
render_data() {
if (!this.frm.is_new() && this.bundle) {
frappe.call({