Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use default supplier currency if default supplier is enabled #32251

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down