mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-17 22:12:12 +00:00
fix: Accepted and Rejected warehouse cannot be same (#43568)
(cherry picked from commit 5130f7d411)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -392,7 +392,7 @@ erpnext.buying = {
|
|||||||
item[field] = r.message[field];
|
item[field] = r.message[field];
|
||||||
});
|
});
|
||||||
|
|
||||||
item.type_of_transaction = item.rejected_qty > 0 ? "Inward" : "Outward";
|
item.type_of_transaction = !doc.is_return > 0 ? "Inward" : "Outward";
|
||||||
item.is_rejected = true;
|
item.is_rejected = true;
|
||||||
|
|
||||||
new erpnext.SerialBatchPackageSelector(
|
new erpnext.SerialBatchPackageSelector(
|
||||||
@@ -404,7 +404,7 @@ erpnext.buying = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let update_values = {
|
let update_values = {
|
||||||
"serial_and_batch_bundle": r.name,
|
"rejected_serial_and_batch_bundle": r.name,
|
||||||
"use_serial_batch_fields": 0,
|
"use_serial_batch_fields": 0,
|
||||||
"rejected_qty": qty / flt(item.conversion_factor || 1, precision("conversion_factor", item))
|
"rejected_qty": qty / flt(item.conversion_factor || 1, precision("conversion_factor", item))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,12 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
|||||||
options: "Warehouse",
|
options: "Warehouse",
|
||||||
default: this.get_warehouse(),
|
default: this.get_warehouse(),
|
||||||
onchange: () => {
|
onchange: () => {
|
||||||
this.item.warehouse = this.dialog.get_value("warehouse");
|
if (this.item?.is_rejected) {
|
||||||
|
this.item.rejected_warehouse = this.dialog.get_value("warehouse");
|
||||||
|
} else {
|
||||||
|
this.item.warehouse = this.dialog.get_value("warehouse");
|
||||||
|
}
|
||||||
|
|
||||||
this.get_auto_data();
|
this.get_auto_data();
|
||||||
},
|
},
|
||||||
get_query: () => {
|
get_query: () => {
|
||||||
@@ -282,10 +287,6 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
|||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_serial_nos_from_series() {}
|
|
||||||
|
|
||||||
set_batch_nos_from_series() {}
|
|
||||||
|
|
||||||
set_serial_nos_from_range() {
|
set_serial_nos_from_range() {
|
||||||
const serial_no_range = this.dialog.get_value("serial_no_range");
|
const serial_no_range = this.dialog.get_value("serial_no_range");
|
||||||
|
|
||||||
@@ -508,12 +509,17 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
|||||||
based_on = "FIFO";
|
based_on = "FIFO";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let warehouse = this.item.warehouse || this.item.s_warehouse;
|
||||||
|
if (this.item?.is_rejected) {
|
||||||
|
warehouse = this.item.rejected_warehouse;
|
||||||
|
}
|
||||||
|
|
||||||
if (qty) {
|
if (qty) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.get_auto_data",
|
method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.get_auto_data",
|
||||||
args: {
|
args: {
|
||||||
item_code: this.item.item_code,
|
item_code: this.item.item_code,
|
||||||
warehouse: this.item.warehouse || this.item.s_warehouse,
|
warehouse: warehouse,
|
||||||
has_serial_no: this.item.has_serial_no,
|
has_serial_no: this.item.has_serial_no,
|
||||||
has_batch_no: this.item.has_batch_no,
|
has_batch_no: this.item.has_batch_no,
|
||||||
qty: qty,
|
qty: qty,
|
||||||
@@ -627,6 +633,10 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
|||||||
frappe.throw(__("Please select a Warehouse"));
|
frappe.throw(__("Please select a Warehouse"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.item?.is_rejected && this.item.rejected_warehouse === this.item.warehouse) {
|
||||||
|
frappe.throw(__("Rejected Warehouse and Accepted Warehouse cannot be same."));
|
||||||
|
}
|
||||||
|
|
||||||
frappe
|
frappe
|
||||||
.call({
|
.call({
|
||||||
method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.add_serial_batch_ledgers",
|
method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.add_serial_batch_ledgers",
|
||||||
@@ -701,5 +711,8 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.dialog.fields_dict.entries.grid.refresh();
|
this.dialog.fields_dict.entries.grid.refresh();
|
||||||
|
if (this.dialog.fields_dict.entries.df.data?.length) {
|
||||||
|
this.dialog.set_value("enter_manually", 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1308,8 +1308,12 @@ def add_serial_batch_ledgers(entries, child_row, doc, warehouse, do_not_save=Fal
|
|||||||
if parent_doc and isinstance(parent_doc, str):
|
if parent_doc and isinstance(parent_doc, str):
|
||||||
parent_doc = parse_json(parent_doc)
|
parent_doc = parse_json(parent_doc)
|
||||||
|
|
||||||
if frappe.db.exists("Serial and Batch Bundle", child_row.serial_and_batch_bundle):
|
bundle = child_row.serial_and_batch_bundle
|
||||||
sb_doc = update_serial_batch_no_ledgers(entries, child_row, parent_doc, warehouse)
|
if child_row.get("is_rejected"):
|
||||||
|
bundle = child_row.rejected_serial_and_batch_bundle
|
||||||
|
|
||||||
|
if frappe.db.exists("Serial and Batch Bundle", bundle):
|
||||||
|
sb_doc = update_serial_batch_no_ledgers(bundle, entries, child_row, parent_doc, warehouse)
|
||||||
else:
|
else:
|
||||||
sb_doc = create_serial_batch_no_ledgers(
|
sb_doc = create_serial_batch_no_ledgers(
|
||||||
entries, child_row, parent_doc, warehouse, do_not_save=do_not_save
|
entries, child_row, parent_doc, warehouse, do_not_save=do_not_save
|
||||||
@@ -1412,8 +1416,8 @@ def get_type_of_transaction(parent_doc, child_row):
|
|||||||
return type_of_transaction
|
return type_of_transaction
|
||||||
|
|
||||||
|
|
||||||
def update_serial_batch_no_ledgers(entries, child_row, parent_doc, warehouse=None) -> object:
|
def update_serial_batch_no_ledgers(bundle, entries, child_row, parent_doc, warehouse=None) -> object:
|
||||||
doc = frappe.get_doc("Serial and Batch Bundle", child_row.serial_and_batch_bundle)
|
doc = frappe.get_doc("Serial and Batch Bundle", bundle)
|
||||||
doc.voucher_detail_no = child_row.name
|
doc.voucher_detail_no = child_row.name
|
||||||
doc.posting_date = parent_doc.posting_date
|
doc.posting_date = parent_doc.posting_date
|
||||||
doc.posting_time = parent_doc.posting_time
|
doc.posting_time = parent_doc.posting_time
|
||||||
|
|||||||
Reference in New Issue
Block a user