fix: use default supplier currency if default supplier is enabled

This commit is contained in:
ruthra kumar 2022-09-16 16:20:35 +05:30
parent 8f787c08a2
commit 77fdc37cb7

View File

@ -880,6 +880,9 @@ def get_events(start, end, filters=None):
@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 make_purchase_order_for_default_supplier(source_name, selected_items=None, t
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