fix: do not translate default record lookup keys

Company.create_default_departments named and looked up the root
Department via _("All Departments"), which resolves in the session
language. A site set up in a non-English language stores the root
translated, and a company created later from a session in another
language misses it and inserts a second root, corrupting the tree.
Resolve the root once with get_root_of (falling back to the canonical
English name on fresh installs) and reuse it for the root record, the
exists-guard and the child departments' parent.

Also stop translating lookups of records install_fixtures stores under
English names: Price List "Standard Selling" and Print Headings
"Credit Note" / "Debit Note".

Same class as the root Item Group fix (#57386, issue #57345).
This commit is contained in:
Mihir Kandoi
2026-07-23 12:51:30 +05:30
parent 92b62402be
commit 9b7c36f3d9
4 changed files with 47 additions and 19 deletions

View File

@@ -459,11 +459,11 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None, return_agai
# look for Print Heading "Credit Note"
if not doc.select_print_heading:
doc.select_print_heading = frappe.get_cached_value("Print Heading", _("Credit Note"))
doc.select_print_heading = frappe.get_cached_value("Print Heading", "Credit Note")
elif doctype == "Purchase Invoice":
# look for Print Heading "Debit Note"
doc.select_print_heading = frappe.get_cached_value("Print Heading", _("Debit Note"))
doc.select_print_heading = frappe.get_cached_value("Print Heading", "Debit Note")
elif doctype == "Delivery Note":
# manual additions to the return should hit the return warehous, too
doc.set_warehouse = default_warehouse_for_sales_return