fix: use default supplier currency if default supplier is enabled
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 09a9652..25806d6 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -880,6 +880,9 @@
@frappe.whitelist()
def make_purchase_order_for_default_supplier(source_name, selected_items=None, target_doc=None):
"""Creates Purchase Order for each Supplier. Returns a list of doc objects."""
+
+ from erpnext.setup.utils import get_exchange_rate
+
if not selected_items:
return
@@ -888,6 +891,15 @@
def set_missing_values(source, target):
target.supplier = supplier
+ target.currency = frappe.db.get_value(
+ "Supplier", filters={"name": supplier}, fieldname=["default_currency"]
+ )
+ company_currency = frappe.db.get_value(
+ "Company", filters={"name": target.company}, fieldname=["default_currency"]
+ )
+
+ target.conversion_rate = get_exchange_rate(target.currency, company_currency, args="for_buying")
+
target.apply_discount_on = ""
target.additional_discount_percentage = 0.0
target.discount_amount = 0.0