fix: `set_missing_values` in SE and re-use the same on all SE mappings
- `set_missing_values` in SE will set actual qty, transfer qty and calculate rate/amount
- Re-use `set_missing_values` wherever SE is doc is being mapped
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 5860c4c..9189f18 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -637,6 +637,8 @@
}
}
stock_entry.add_to_stock_entry_detail(items_dict)
+
+ stock_entry.set_missing_values()
return stock_entry.as_dict()
else:
frappe.throw(_("No Items selected for transfer"))
@@ -724,7 +726,7 @@
add_items_in_ste(ste_doc, value, value.qty, po_details)
ste_doc.set_stock_entry_type()
- ste_doc.calculate_rate_and_amount()
+ ste_doc.set_missing_values()
return ste_doc
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py
index bf4f82f..a98fc94 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.py
+++ b/erpnext/manufacturing/doctype/job_card/job_card.py
@@ -764,8 +764,6 @@
pending_fg_qty = flt(source.get("for_quantity", 0)) - flt(source.get("transferred_qty", 0))
target.fg_completed_qty = pending_fg_qty if pending_fg_qty > 0 else 0
- target.set_transfer_qty()
- target.calculate_rate_and_amount()
target.set_missing_values()
target.set_stock_entry_type()
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 920254c..c3812f3 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -1384,7 +1384,7 @@
var me = this;
var args = this._get_args(item);
if (!(args.items && args.items.length)) {
- if(calculate_taxes_and_totals) me.calculate_taxes_and_totals();
+ if (calculate_taxes_and_totals) me.calculate_taxes_and_totals();
return;
}
@@ -1392,7 +1392,7 @@
if (this.frm.doc.__onload && this.frm.doc.__onload.ignore_price_list) {
// Calculate totals even though pricing rule is not applied.
// `apply_pricing_rule` is triggered due to change in data which most likely contributes to Total.
- if(calculate_taxes_and_totals) me.calculate_taxes_and_totals();
+ if (calculate_taxes_and_totals) me.calculate_taxes_and_totals();
return;
}
diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py
index aac6cd3..77640db 100644
--- a/erpnext/stock/doctype/batch/batch.py
+++ b/erpnext/stock/doctype/batch/batch.py
@@ -244,6 +244,7 @@
)
)
stock_entry.set_stock_entry_type()
+ stock_entry.set_missing_values()
stock_entry.insert()
stock_entry.submit()
diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py
index a70ff17..c998629 100644
--- a/erpnext/stock/doctype/material_request/material_request.py
+++ b/erpnext/stock/doctype/material_request/material_request.py
@@ -597,7 +597,7 @@
if source.material_request_type == "Customer Provided":
target.purpose = "Material Receipt"
- target.run_method("calculate_rate_and_amount")
+ target.set_missing_values()
target.set_stock_entry_type()
target.set_job_card_data()
diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py
index 70d2f23..d552c09 100644
--- a/erpnext/stock/doctype/pick_list/pick_list.py
+++ b/erpnext/stock/doctype/pick_list/pick_list.py
@@ -672,8 +672,7 @@
else:
stock_entry = update_stock_entry_items_with_no_reference(pick_list, stock_entry)
- stock_entry.set_actual_qty()
- stock_entry.calculate_rate_and_amount()
+ stock_entry.set_missing_values()
return stock_entry.as_dict()
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index ec0e809..fcf0cd1 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -1036,6 +1036,7 @@
def set_missing_values(source, target):
target.stock_entry_type = "Material Transfer"
target.purpose = "Material Transfer"
+ target.set_missing_values()
doclist = get_mapped_doc(
"Purchase Receipt",
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 27a6eaf..2a7354d 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -2197,6 +2197,12 @@
return sorted(list(set(get_serial_nos(self.pro_doc.serial_no)) - set(used_serial_nos)))
+ def set_missing_values(self):
+ "Updates rate and availability of all the items of mapped doc."
+ self.set_transfer_qty()
+ self.set_actual_qty()
+ self.calculate_rate_and_amount()
+
@frappe.whitelist()
def move_sample_to_retention_warehouse(company, items):
@@ -2246,6 +2252,7 @@
def make_stock_in_entry(source_name, target_doc=None):
def set_missing_values(source, target):
target.set_stock_entry_type()
+ target.set_missing_values()
def update_item(source_doc, target_doc, source_parent):
target_doc.t_warehouse = ""
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry_utils.py b/erpnext/stock/doctype/stock_entry/stock_entry_utils.py
index b3df728..cf1032c 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry_utils.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry_utils.py
@@ -132,6 +132,8 @@
)
s.set_stock_entry_type()
+ s.set_missing_values()
+
if not args.do_not_save:
s.insert()
if not args.do_not_submit: