mirror of
https://github.com/frappe/erpnext.git
synced 2026-10-29 22:57:42 +00:00
fix: do not translate default record lookup keys (backport #57389)
Default records are looked up by their untranslated names.
(cherry picked from commit 9b7c36f3d9)
This commit is contained in:
@@ -515,11 +515,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")
|
||||
if source.tax_withholding_category:
|
||||
doc.set_onload("supplier_tds", source.tax_withholding_category)
|
||||
elif doctype == "Delivery Note":
|
||||
|
||||
@@ -21,7 +21,7 @@ from frappe.utils import (
|
||||
get_timestamp,
|
||||
today,
|
||||
)
|
||||
from frappe.utils.nestedset import NestedSet, rebuild_tree
|
||||
from frappe.utils.nestedset import NestedSet, get_root_of, rebuild_tree
|
||||
|
||||
from erpnext.accounts.doctype.account.account import get_account_currency
|
||||
from erpnext.setup.setup_wizard.operations.taxes_setup import setup_taxes_and_charges
|
||||
@@ -371,91 +371,92 @@ class Company(NestedSet):
|
||||
)
|
||||
|
||||
def create_default_departments(self):
|
||||
root = get_root_of("Department") or "All Departments"
|
||||
records = [
|
||||
# Department
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("All Departments"),
|
||||
"department_name": root,
|
||||
"is_group": 1,
|
||||
"parent_department": "",
|
||||
"__condition": lambda: not frappe.db.exists("Department", _("All Departments")),
|
||||
"__condition": lambda: not frappe.db.exists("Department", root),
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Accounts"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Marketing"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Sales"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Purchase"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Operations"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Production"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Dispatch"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Customer Service"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Human Resources"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Management"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Quality Management"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Research & Development"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
{
|
||||
"doctype": "Department",
|
||||
"department_name": _("Legal"),
|
||||
"parent_department": _("All Departments"),
|
||||
"parent_department": root,
|
||||
"company": self.name,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
|
||||
import json
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import random_string
|
||||
from frappe.utils.nestedset import get_root_of
|
||||
|
||||
from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import (
|
||||
get_charts_for_country,
|
||||
@@ -182,6 +184,31 @@ class TestCompany(unittest.TestCase):
|
||||
|
||||
return get_no_of_children([company], 0)
|
||||
|
||||
def test_default_departments_ignore_session_translations(self):
|
||||
self.assertEqual(get_root_of("Department"), "All Departments")
|
||||
|
||||
translations = {"All Departments": "Alle Abteilungen", "Accounts": "Buchhaltung"}
|
||||
with patch("frappe.translate.get_all_translations", return_value=translations):
|
||||
company = frappe.new_doc("Company")
|
||||
company.company_name = "Dept Translation Test Co"
|
||||
company.abbr = "DTTC"
|
||||
company.default_currency = "INR"
|
||||
company.country = "India"
|
||||
company.insert()
|
||||
|
||||
self.assertFalse(frappe.db.exists("Department", "Alle Abteilungen"))
|
||||
self.assertEqual(
|
||||
frappe.get_all("Department", filters={"parent_department": ("is", "not set")}, pluck="name"),
|
||||
["All Departments"],
|
||||
)
|
||||
|
||||
departments = frappe.get_all(
|
||||
"Department", filters={"company": company.name}, fields=["name", "parent_department"]
|
||||
)
|
||||
self.assertTrue(departments)
|
||||
self.assertEqual({d.parent_department for d in departments}, {"All Departments"})
|
||||
self.assertIn("Buchhaltung - DTTC", [d.name for d in departments])
|
||||
|
||||
def test_change_parent_company(self):
|
||||
child_company = frappe.get_doc("Company", "_Test Company 5")
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ class Item(Document):
|
||||
if not price_list:
|
||||
price_list = frappe.db.get_single_value(
|
||||
"Selling Settings", "selling_price_list"
|
||||
) or frappe.db.get_value("Price List", _("Standard Selling"))
|
||||
) or frappe.db.get_value("Price List", "Standard Selling")
|
||||
if price_list:
|
||||
item_price = frappe.get_doc(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user