You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When create Subcontracting Order from Purchase Order, Rate on PO is using Company Currency (CNY, or IDR) but when create new Subcontracting Order from PO, it use Company Currency rate to Rate without converting or Missing rate for company currency.
I attach example when create new SO
This is from PO
This should be CNY instead of Default Currency SGD $
Module
buying
Version
ERPNext: v15.17.1
Frappe Framework: v15.17.3
Installation method
docker
Relevant log output / Stack trace / Full Error Message.
No response
The text was updated successfully, but these errors were encountered:
I also encounter this on v14 and v15 systems. Solved the issue by this dirty code on my custom app.
@frappe.whitelist()
def make_subcontracting_order(source_name, target_doc=None):
return get_mapped_subcontracting_order(source_name, target_doc)
def get_mapped_subcontracting_order(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
if target_doc and isinstance(target_doc, str):
target_doc = json.loads(target_doc)
for key in ["service_items", "items", "supplied_items"]:
if key in target_doc:
del target_doc[key]
target_doc = json.dumps(target_doc)
target_doc = get_mapped_doc(
"Purchase Order",
source_name,
{
"Purchase Order": {
"doctype": "Subcontracting Order",
"field_map": {},
"field_no_map": ["total_qty", "total", "net_total"],
"validation": {
"docstatus": ["=", 1],
},
},
"Purchase Order Item": {
"doctype": "Subcontracting Order Service Item",
"field_map": {
"material_request": "material_request",
"material_request_item": "material_request_item",
},
"field_no_map": [],
},
},
target_doc,
)
# Currency is wrong so we need to reevaluate it. https://github.com/frappe/erpnext/issues/41030
# We need to check the currency of the company and compare it with the po currency.
# If they are different we need to convert it to the company currency.
docPO = frappe.get_doc("Purchase Order", source_name)
if docPO.currency != frappe.get_cached_value("Company", docPO.company, "default_currency"):
flConversionFactor = docPO.conversion_rate
for service_item in target_doc.service_items:
service_item.rate = service_item.rate * flConversionFactor
service_item.amount = service_item.rate * service_item.fg_item_qty
target_doc.populate_items_table()
if target_doc.set_warehouse:
for item in target_doc.items:
item.warehouse = target_doc.set_warehouse
else:
source_doc = frappe.get_doc("Purchase Order", source_name)
if source_doc.set_warehouse:
for item in target_doc.items:
item.warehouse = source_doc.set_warehouse
else:
for idx, item in enumerate(target_doc.items):
item.warehouse = source_doc.items[idx].warehouse
return target_doc
Information about bug
When create Subcontracting Order from Purchase Order, Rate on PO is using Company Currency (CNY, or IDR) but when create new Subcontracting Order from PO, it use Company Currency rate to Rate without converting or Missing rate for company currency.
I attach example when create new SO

This is from PO

This should be CNY instead of Default Currency SGD $
Module
buying
Version
ERPNext: v15.17.1
Frappe Framework: v15.17.3
Installation method
docker
Relevant log output / Stack trace / Full Error Message.
No response
The text was updated successfully, but these errors were encountered: