From 77e57870363c3e1b45b8e2fc428b940cb6aaa72b Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Aug 2024 01:57:44 +0200 Subject: [PATCH 1/6] fix: use pseudo-translation while creating fixtures --- .../setup/setup_wizard/operations/install_fixtures.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 1d2530cfdf0..ba5d0772ceb 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -7,7 +7,6 @@ import os from pathlib import Path import frappe -from frappe import _ from frappe.desk.doctype.global_search_settings.global_search_settings import ( update_global_search_doctypes, ) @@ -18,6 +17,14 @@ from erpnext.accounts.doctype.account.account import RootNotEditable from erpnext.regional.address_template.setup import set_up_address_templates +def _(x, *args, **kwargs): + """Redefine the translation function to return the string as is. + + We want to create english records but still mark the strings as translatable. + The respective DocTypes have 'Translate Link Fields' enabled.""" + return x + + def read_lines(filename: str) -> list[str]: """Return a list of lines from a file in the data directory.""" return (Path(__file__).parent.parent / "data" / filename).read_text().splitlines() From 11f6e570a5079ccef21ec172e3640cc8884657d2 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Aug 2024 01:58:27 +0200 Subject: [PATCH 2/6] fix: add pseudo-translation for Stock Entry Type --- .../setup_wizard/operations/install_fixtures.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index ba5d0772ceb..476d0325f2c 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -73,28 +73,28 @@ def install(country=None): "parent_item_group": _("All Item Groups"), }, # Stock Entry Type - {"doctype": "Stock Entry Type", "name": "Material Issue", "purpose": "Material Issue"}, - {"doctype": "Stock Entry Type", "name": "Material Receipt", "purpose": "Material Receipt"}, + {"doctype": "Stock Entry Type", "name": _("Material Issue"), "purpose": "Material Issue"}, + {"doctype": "Stock Entry Type", "name": _("Material Receipt"), "purpose": "Material Receipt"}, { "doctype": "Stock Entry Type", - "name": "Material Transfer", + "name": _("Material Transfer"), "purpose": "Material Transfer", }, - {"doctype": "Stock Entry Type", "name": "Manufacture", "purpose": "Manufacture"}, - {"doctype": "Stock Entry Type", "name": "Repack", "purpose": "Repack"}, + {"doctype": "Stock Entry Type", "name": _("Manufacture"), "purpose": "Manufacture"}, + {"doctype": "Stock Entry Type", "name": _("Repack"), "purpose": "Repack"}, { "doctype": "Stock Entry Type", - "name": "Send to Subcontractor", + "name": _("Send to Subcontractor"), "purpose": "Send to Subcontractor", }, { "doctype": "Stock Entry Type", - "name": "Material Transfer for Manufacture", + "name": _("Material Transfer for Manufacture"), "purpose": "Material Transfer for Manufacture", }, { "doctype": "Stock Entry Type", - "name": "Material Consumption for Manufacture", + "name": _("Material Consumption for Manufacture"), "purpose": "Material Consumption for Manufacture", }, # territory: with two default territories, one for home country and one named Rest of the World From c08cd938bc29220813e67875776650b9371b8afe Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Aug 2024 01:58:48 +0200 Subject: [PATCH 3/6] fix: add pseudo-translation for Project Type --- erpnext/setup/setup_wizard/operations/install_fixtures.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 476d0325f2c..0e4e77e38fe 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -257,9 +257,9 @@ def install(country=None): {"doctype": "Opportunity Type", "name": _("Sales")}, {"doctype": "Opportunity Type", "name": _("Support")}, {"doctype": "Opportunity Type", "name": _("Maintenance")}, - {"doctype": "Project Type", "project_type": "Internal"}, - {"doctype": "Project Type", "project_type": "External"}, - {"doctype": "Project Type", "project_type": "Other"}, + {"doctype": "Project Type", "project_type": _("Internal")}, + {"doctype": "Project Type", "project_type": _("External")}, + {"doctype": "Project Type", "project_type": _("Other")}, {"doctype": "Print Heading", "print_heading": _("Credit Note")}, {"doctype": "Print Heading", "print_heading": _("Debit Note")}, # Share Management From 505cd9515095cd62a457a92fa54f6c2059e77c61 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Aug 2024 02:00:34 +0200 Subject: [PATCH 4/6] fix: remove pseudo-translation for UOM Category variable Has no effect and even if it had, it's not really needed. --- erpnext/setup/setup_wizard/operations/install_fixtures.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 0e4e77e38fe..4ef87a29ac6 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -353,8 +353,8 @@ def add_uom_data(): ).read() ) for d in uom_conversions: - if not frappe.db.exists("UOM Category", _(d.get("category"))): - frappe.get_doc({"doctype": "UOM Category", "category_name": _(d.get("category"))}).db_insert() + if not frappe.db.exists("UOM Category", d.get("category")): + frappe.get_doc({"doctype": "UOM Category", "category_name": d.get("category")}).db_insert() if not frappe.db.exists( "UOM Conversion Factor", @@ -363,7 +363,7 @@ def add_uom_data(): frappe.get_doc( { "doctype": "UOM Conversion Factor", - "category": _(d.get("category")), + "category": d.get("category"), "from_uom": d.get("from_uom"), "to_uom": d.get("to_uom"), "value": d.get("value"), From 48513b10875eff2a01da1f22a48310e8ce755f21 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Aug 2024 02:01:35 +0200 Subject: [PATCH 5/6] refactor: remove useless line --- erpnext/setup/setup_wizard/operations/install_fixtures.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 4ef87a29ac6..d3c6ca20345 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -477,7 +477,6 @@ def update_stock_settings(): stock_settings.item_naming_by = "Item Code" stock_settings.valuation_method = "FIFO" stock_settings.default_warehouse = frappe.db.get_value("Warehouse", {"warehouse_name": _("Stores")}) - stock_settings.stock_uom = _("Nos") stock_settings.stock_uom = "Nos" stock_settings.auto_indent = 1 stock_settings.auto_insert_price_list_rate_if_missing = 1 From 97c28534972bed5dcd71a71351207a2afe637ae1 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Aug 2024 02:02:20 +0200 Subject: [PATCH 6/6] feat: enable "Translate Link Fields" for fixture doctypes --- .../accounts/doctype/mode_of_payment/mode_of_payment.json | 5 +++-- erpnext/crm/doctype/market_segment/market_segment.json | 5 +++-- erpnext/projects/doctype/activity_type/activity_type.json | 5 +++-- erpnext/projects/doctype/project_type/project_type.json | 5 +++-- erpnext/setup/doctype/customer_group/customer_group.json | 5 +++-- erpnext/setup/doctype/customer_group/customer_group.py | 4 +--- erpnext/setup/doctype/item_group/item_group.json | 5 +++-- erpnext/setup/doctype/supplier_group/supplier_group.json | 5 +++-- erpnext/setup/doctype/territory/territory.json | 5 +++-- erpnext/stock/doctype/price_list/price_list.json | 5 +++-- erpnext/stock/doctype/stock_entry_type/stock_entry_type.json | 5 +++-- erpnext/support/doctype/issue_priority/issue_priority.json | 5 +++-- 12 files changed, 34 insertions(+), 25 deletions(-) diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json index 75022fd25cb..f7e7fc414bd 100644 --- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json +++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json @@ -48,7 +48,7 @@ "idx": 1, "index_web_pages_for_search": 1, "links": [], - "modified": "2024-03-27 13:10:05.597711", + "modified": "2024-08-16 19:22:42.942264", "modified_by": "Administrator", "module": "Accounts", "name": "Mode of Payment", @@ -74,5 +74,6 @@ "show_name_in_global_search": 1, "sort_field": "creation", "sort_order": "ASC", - "states": [] + "states": [], + "translated_doctype": 1 } \ No newline at end of file diff --git a/erpnext/crm/doctype/market_segment/market_segment.json b/erpnext/crm/doctype/market_segment/market_segment.json index f493664af8f..0ad3d0e4b59 100644 --- a/erpnext/crm/doctype/market_segment/market_segment.json +++ b/erpnext/crm/doctype/market_segment/market_segment.json @@ -17,7 +17,7 @@ } ], "links": [], - "modified": "2024-03-27 13:10:04.846687", + "modified": "2024-08-16 19:24:55.811760", "modified_by": "Administrator", "module": "CRM", "name": "Market Segment", @@ -40,5 +40,6 @@ "sort_field": "creation", "sort_order": "DESC", "states": [], - "track_changes": 1 + "track_changes": 1, + "translated_doctype": 1 } \ No newline at end of file diff --git a/erpnext/projects/doctype/activity_type/activity_type.json b/erpnext/projects/doctype/activity_type/activity_type.json index 4da88b463eb..ccca292ba77 100644 --- a/erpnext/projects/doctype/activity_type/activity_type.json +++ b/erpnext/projects/doctype/activity_type/activity_type.json @@ -47,7 +47,7 @@ "icon": "icon-flag", "idx": 1, "links": [], - "modified": "2024-03-27 13:05:57.956050", + "modified": "2024-08-16 19:22:57.706521", "modified_by": "Administrator", "module": "Projects", "name": "Activity Type", @@ -84,5 +84,6 @@ "quick_entry": 1, "sort_field": "creation", "sort_order": "ASC", - "states": [] + "states": [], + "translated_doctype": 1 } \ No newline at end of file diff --git a/erpnext/projects/doctype/project_type/project_type.json b/erpnext/projects/doctype/project_type/project_type.json index e8577b36631..2487ffa9554 100644 --- a/erpnext/projects/doctype/project_type/project_type.json +++ b/erpnext/projects/doctype/project_type/project_type.json @@ -26,7 +26,7 @@ } ], "links": [], - "modified": "2024-03-27 13:10:21.571554", + "modified": "2024-08-16 19:24:29.480229", "modified_by": "Administrator", "module": "Projects", "name": "Project Type", @@ -70,5 +70,6 @@ "sort_field": "creation", "sort_order": "DESC", "states": [], - "track_changes": 1 + "track_changes": 1, + "translated_doctype": 1 } \ No newline at end of file diff --git a/erpnext/setup/doctype/customer_group/customer_group.json b/erpnext/setup/doctype/customer_group/customer_group.json index f2db724bae1..e1876bbd1ca 100644 --- a/erpnext/setup/doctype/customer_group/customer_group.json +++ b/erpnext/setup/doctype/customer_group/customer_group.json @@ -139,7 +139,7 @@ "idx": 1, "is_tree": 1, "links": [], - "modified": "2024-03-27 13:06:48.550415", + "modified": "2024-08-16 19:21:41.880111", "modified_by": "Administrator", "module": "Setup", "name": "Customer Group", @@ -212,5 +212,6 @@ "show_name_in_global_search": 1, "sort_field": "creation", "sort_order": "DESC", - "states": [] + "states": [], + "translated_doctype": 1 } \ No newline at end of file diff --git a/erpnext/setup/doctype/customer_group/customer_group.py b/erpnext/setup/doctype/customer_group/customer_group.py index 5dd0fd02011..9a05760ec29 100644 --- a/erpnext/setup/doctype/customer_group/customer_group.py +++ b/erpnext/setup/doctype/customer_group/customer_group.py @@ -17,9 +17,7 @@ class CustomerGroup(NestedSet): from frappe.types import DF from erpnext.accounts.doctype.party_account.party_account import PartyAccount - from erpnext.selling.doctype.customer_credit_limit.customer_credit_limit import ( - CustomerCreditLimit, - ) + from erpnext.selling.doctype.customer_credit_limit.customer_credit_limit import CustomerCreditLimit accounts: DF.Table[PartyAccount] credit_limits: DF.Table[CustomerCreditLimit] diff --git a/erpnext/setup/doctype/item_group/item_group.json b/erpnext/setup/doctype/item_group/item_group.json index 06468f22cc3..34135507b13 100644 --- a/erpnext/setup/doctype/item_group/item_group.json +++ b/erpnext/setup/doctype/item_group/item_group.json @@ -135,7 +135,7 @@ "is_tree": 1, "links": [], "max_attachments": 3, - "modified": "2024-03-27 13:09:54.588785", + "modified": "2024-08-16 19:20:36.401913", "modified_by": "Administrator", "module": "Setup", "name": "Item Group", @@ -206,5 +206,6 @@ "show_name_in_global_search": 1, "sort_field": "creation", "sort_order": "DESC", - "states": [] + "states": [], + "translated_doctype": 1 } \ No newline at end of file diff --git a/erpnext/setup/doctype/supplier_group/supplier_group.json b/erpnext/setup/doctype/supplier_group/supplier_group.json index cf1dcc8cd68..bc4f40ca2c4 100644 --- a/erpnext/setup/doctype/supplier_group/supplier_group.json +++ b/erpnext/setup/doctype/supplier_group/supplier_group.json @@ -107,7 +107,7 @@ "idx": 1, "is_tree": 1, "links": [], - "modified": "2024-03-27 13:10:48.734325", + "modified": "2024-08-16 19:22:02.022181", "modified_by": "Administrator", "module": "Setup", "name": "Supplier Group", @@ -170,5 +170,6 @@ "show_name_in_global_search": 1, "sort_field": "creation", "sort_order": "ASC", - "states": [] + "states": [], + "translated_doctype": 1 } \ No newline at end of file diff --git a/erpnext/setup/doctype/territory/territory.json b/erpnext/setup/doctype/territory/territory.json index 9ee8b6d42ee..0b07f72e469 100644 --- a/erpnext/setup/doctype/territory/territory.json +++ b/erpnext/setup/doctype/territory/territory.json @@ -123,7 +123,7 @@ "idx": 1, "is_tree": 1, "links": [], - "modified": "2024-03-27 13:10:53.240951", + "modified": "2024-08-16 19:21:19.161490", "modified_by": "Administrator", "module": "Setup", "name": "Territory", @@ -188,5 +188,6 @@ "show_name_in_global_search": 1, "sort_field": "creation", "sort_order": "DESC", - "states": [] + "states": [], + "translated_doctype": 1 } \ No newline at end of file diff --git a/erpnext/stock/doctype/price_list/price_list.json b/erpnext/stock/doctype/price_list/price_list.json index e0d00cae8a8..e3da9d78fc9 100644 --- a/erpnext/stock/doctype/price_list/price_list.json +++ b/erpnext/stock/doctype/price_list/price_list.json @@ -84,7 +84,7 @@ "idx": 1, "links": [], "max_attachments": 1, - "modified": "2024-03-27 13:10:17.226079", + "modified": "2024-08-16 19:41:19.591111", "modified_by": "Administrator", "module": "Stock", "name": "Price List", @@ -130,5 +130,6 @@ "show_name_in_global_search": 1, "sort_field": "creation", "sort_order": "ASC", - "states": [] + "states": [], + "translated_doctype": 1 } \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry_type/stock_entry_type.json b/erpnext/stock/doctype/stock_entry_type/stock_entry_type.json index 7944f0ed5af..3a49ce495a3 100644 --- a/erpnext/stock/doctype/stock_entry_type/stock_entry_type.json +++ b/erpnext/stock/doctype/stock_entry_type/stock_entry_type.json @@ -29,7 +29,7 @@ } ], "links": [], - "modified": "2024-07-08 08:41:19.385020", + "modified": "2024-08-16 19:20:56.741511", "modified_by": "Administrator", "module": "Stock", "name": "Stock Entry Type", @@ -80,5 +80,6 @@ "sort_field": "creation", "sort_order": "ASC", "states": [], - "track_changes": 1 + "track_changes": 1, + "translated_doctype": 1 } \ No newline at end of file diff --git a/erpnext/support/doctype/issue_priority/issue_priority.json b/erpnext/support/doctype/issue_priority/issue_priority.json index 6f131c9eb48..7b3afb8b5e0 100644 --- a/erpnext/support/doctype/issue_priority/issue_priority.json +++ b/erpnext/support/doctype/issue_priority/issue_priority.json @@ -15,7 +15,7 @@ } ], "links": [], - "modified": "2024-03-27 13:09:53.126034", + "modified": "2024-08-16 19:23:40.697426", "modified_by": "Administrator", "module": "Support", "name": "Issue Priority", @@ -38,5 +38,6 @@ "sort_field": "creation", "sort_order": "ASC", "states": [], - "track_changes": 1 + "track_changes": 1, + "translated_doctype": 1 } \ No newline at end of file