Merge branch 'develop' into demo_data_on_install

This commit is contained in:
Ankush Menat
2023-08-10 15:22:52 +05:30
182 changed files with 5050 additions and 1299 deletions

View File

@@ -18,6 +18,7 @@ frappe.ui.form.on("Company", {
});
},
setup: function(frm) {
frm.__rename_queue = "long";
erpnext.company.setup_queries(frm);
frm.set_query("parent_company", function() {

View File

@@ -6,12 +6,9 @@ import json
from datetime import date
import frappe
from babel import Locale
from frappe import _, throw
from frappe.model.document import Document
from frappe.utils import formatdate, getdate, today
from holidays import country_holidays
from holidays.utils import list_supported_countries
class OverlapError(frappe.ValidationError):
@@ -40,6 +37,8 @@ class HolidayList(Document):
@frappe.whitelist()
def get_supported_countries(self):
from holidays.utils import list_supported_countries
subdivisions_by_country = list_supported_countries()
countries = [
{"value": country, "label": local_country_name(country)}
@@ -52,6 +51,8 @@ class HolidayList(Document):
@frappe.whitelist()
def get_local_holidays(self):
from holidays import country_holidays
if not self.country:
throw(_("Please select a country"))
@@ -169,4 +170,6 @@ def is_holiday(holiday_list, date=None):
def local_country_name(country_code: str) -> str:
"""Return the localized country name for the given country code."""
return Locale.parse(frappe.local.lang).territories.get(country_code, country_code)
from babel import Locale
return Locale.parse(frappe.local.lang, sep="-").territories.get(country_code, country_code)

View File

@@ -8,6 +8,8 @@ from datetime import date, timedelta
import frappe
from frappe.utils import getdate
from erpnext.setup.doctype.holiday_list.holiday_list import local_country_name
class TestHolidayList(unittest.TestCase):
def test_holiday_list(self):
@@ -58,6 +60,16 @@ class TestHolidayList(unittest.TestCase):
self.assertIn(date(2023, 4, 10), holidays)
self.assertNotIn(date(2023, 5, 1), holidays)
def test_localized_country_names(self):
lang = frappe.local.lang
frappe.local.lang = "en-gb"
self.assertEqual(local_country_name("IN"), "India")
self.assertEqual(local_country_name("DE"), "Germany")
frappe.local.lang = "de"
self.assertEqual(local_country_name("DE"), "Deutschland")
frappe.local.lang = lang
def make_holiday_list(
name, from_date=getdate() - timedelta(days=10), to_date=getdate(), holiday_dates=None

View File

@@ -2,7 +2,7 @@
"action": "Create Entry",
"action_label": "Create a new Item",
"creation": "2021-05-17 13:47:18.515052",
"description": "# Create an Item\n\nItem is a product, of a or service offered by your company, or something you buy as a part of your supplies or raw materials.\n\nItems are integral to everything you do in ERPNext - from billing, purchasing to managing inventory. Everything you buy or sell, whether it is a physical product or a service is an Item. Items can be stock, non-stock, variants, serialized, batched, assets etc.\n",
"description": "# Create an Item\n\nItem is a product or a service offered by your company, or something you buy as a part of your supplies or raw materials.\n\nItems are integral to everything you do in ERPNext - from billing, purchasing to managing inventory. Everything you buy or sell, whether it is a physical product or a service is an Item. Items can be stock, non-stock, variants, serialized, batched, assets, etc.\n",
"docstatus": 0,
"doctype": "Onboarding Step",
"form_tour": "Item General",
@@ -20,4 +20,4 @@
"show_full_form": 0,
"title": "Create an Item",
"validate_action": 1
}
}