Skip to content

Commit

Permalink
Merge pull request #25238 from frappe/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
ankush committed Mar 5, 2024
2 parents e5e4540 + d733fc2 commit 34a6909
Show file tree
Hide file tree
Showing 73 changed files with 518 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: 'Setup Environment'
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.10'
- uses: actions/checkout@v4

- name: Validate Docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/server-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.10"

- name: Check for valid Python & Merge Conflicts
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.10'

- name: Check for valid Python & Merge Conflicts
run: |
Expand Down
62 changes: 42 additions & 20 deletions frappe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,18 @@ def throw(
is_minimizable: bool = False,
wide: bool = False,
as_list: bool = False,
primary_action=None,
) -> None:
"""Throw execption and show message (`msgprint`).
:param msg: Message.
:param exc: Exception class. Default `frappe.ValidationError`"""
:param exc: Exception class. Default `frappe.ValidationError`
:param title: [optional] Message title. Default: "Message".
:param is_minimizable: [optional] Allow users to minimize the modal
:param wide: [optional] Show wide modal
:param as_list: [optional] If `msg` is a list, render as un-ordered list.
:param primary_action: [optional] Bind a primary server/client side action.
"""
msgprint(
msg,
raise_exception=exc,
Expand All @@ -598,6 +605,7 @@ def throw(
is_minimizable=is_minimizable,
wide=wide,
as_list=as_list,
primary_action=primary_action,
)


Expand Down Expand Up @@ -1611,11 +1619,19 @@ def append_hook(target, key, value):
target[key].extend(value)


def setup_module_map(include_all_apps=True):
"""Rebuild map of all modules (internal)."""
if conf.db_name:
def setup_module_map(include_all_apps: bool = True) -> None:
"""
Function to rebuild map of all modules
:param: include_all_apps: Include all apps on bench, or just apps installed on the site.
:return: Nothing
"""
if include_all_apps:
local.app_modules = cache.get_value("app_modules")
local.module_app = cache.get_value("module_app")
else:
local.app_modules = cache.get_value("installed_app_modules")
local.module_app = cache.get_value("module_installed_app")

if not (local.app_modules and local.module_app):
local.module_app, local.app_modules = {}, {}
Expand All @@ -1634,9 +1650,12 @@ def setup_module_map(include_all_apps=True):
local.module_app[module] = app
local.app_modules[app].append(module)

if conf.db_name:
if include_all_apps:
cache.set_value("app_modules", local.app_modules)
cache.set_value("module_app", local.module_app)
else:
cache.set_value("installed_app_modules", local.app_modules)
cache.set_value("module_installed_app", local.module_app)


def get_file_items(path, raise_not_found=False, ignore_empty_lines=True):
Expand Down Expand Up @@ -2089,24 +2108,27 @@ def get_print(
:param as_pdf: Return as PDF. Default False.
:param password: Password to encrypt the pdf with. Default None"""
from frappe.utils.pdf import get_pdf
from frappe.website.serve import get_response_content
from frappe.website.serve import get_response_without_exception_handling

original_form_dict = copy.deepcopy(local.form_dict)
try:
local.form_dict.doctype = doctype
local.form_dict.name = name
local.form_dict.format = print_format
local.form_dict.style = style
local.form_dict.doc = doc
local.form_dict.no_letterhead = no_letterhead
local.form_dict.letterhead = letterhead

pdf_options = pdf_options or {}
if password:
pdf_options["password"] = password

response = get_response_without_exception_handling("printview", 200)
html = str(response.data, "utf-8")
finally:
local.form_dict = original_form_dict

local.form_dict.doctype = doctype
local.form_dict.name = name
local.form_dict.format = print_format
local.form_dict.style = style
local.form_dict.doc = doc
local.form_dict.no_letterhead = no_letterhead
local.form_dict.letterhead = letterhead

pdf_options = pdf_options or {}
if password:
pdf_options["password"] = password

html = get_response_content("printview")
local.form_dict = original_form_dict
return get_pdf(html, options=pdf_options, output=output) if as_pdf else html


Expand Down
4 changes: 2 additions & 2 deletions frappe/automation/doctype/assignment_rule/assignment_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class AssignmentRule(Document):
description: DF.SmallText
disabled: DF.Check
document_type: DF.Link
due_date_based_on: DF.Literal
field: DF.Literal
due_date_based_on: DF.Literal[None]
field: DF.Literal[None]
last_user: DF.Link | None
priority: DF.Int
rule: DF.Literal["Round Robin", "Load Balancing", "Based on Field"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class MilestoneTracker(Document):

disabled: DF.Check
document_type: DF.Link
track_field: DF.Literal

track_field: DF.Literal[None]
# end: auto-generated types

def on_update(self):
frappe.cache_manager.clear_doctype_map("Milestone Tracker", self.document_type)

Expand Down
2 changes: 2 additions & 0 deletions frappe/cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def get_doctype_map_key(doctype):
"installed_apps",
"all_apps",
"app_modules",
"installed_app_modules",
"module_app",
"module_installed_app",
"system_settings",
"scheduler_events",
"time_zone",
Expand Down
4 changes: 4 additions & 0 deletions frappe/core/doctype/communication/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def make(
email_template=None,
communication_type=None,
send_after=None,
print_language=None,
**kwargs,
) -> dict[str, str]:
"""Make a new communication. Checks for email permissions for specified Document.
Expand Down Expand Up @@ -102,6 +103,7 @@ def make(
communication_type=communication_type,
add_signature=False,
send_after=send_after,
print_language=print_language,
)


Expand All @@ -128,6 +130,7 @@ def _make(
communication_type=None,
add_signature=True,
send_after=None,
print_language=None,
) -> dict[str, str]:
"""Internal method to make a new communication that ignores Permission checks."""

Expand Down Expand Up @@ -181,6 +184,7 @@ def _make(
print_format=print_format,
send_me_a_copy=send_me_a_copy,
print_letterhead=print_letterhead,
print_language=print_language,
)

emails_not_sent_to = comm.exclude_emails_list(include_sender=send_me_a_copy)
Expand Down
10 changes: 8 additions & 2 deletions frappe/core/doctype/communication/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def get_incoming_email_account(self):
)
return self._incoming_email_account

def mail_attachments(self, print_format=None, print_html=None):
def mail_attachments(self, print_format=None, print_html=None, print_language=None):
final_attachments = []

if print_format or print_html:
Expand All @@ -194,6 +194,7 @@ def mail_attachments(self, print_format=None, print_html=None):
"print_format_attachment": 1,
"doctype": self.reference_doctype,
"name": self.reference_name,
"lang": print_language or frappe.local.lang,
}
final_attachments.append(d)

Expand Down Expand Up @@ -256,6 +257,7 @@ def sendmail_input_dict(
send_me_a_copy=None,
print_letterhead=None,
is_inbound_mail_communcation=None,
print_language=None,
) -> dict:
outgoing_email_account = self.get_outgoing_email_account()
if not outgoing_email_account:
Expand All @@ -272,7 +274,9 @@ def sendmail_input_dict(
if not (recipients or cc):
return {}

final_attachments = self.mail_attachments(print_format=print_format, print_html=print_html)
final_attachments = self.mail_attachments(
print_format=print_format, print_html=print_html, print_language=print_language
)
incoming_email_account = self.get_incoming_email_account()
return {
"recipients": recipients,
Expand Down Expand Up @@ -303,12 +307,14 @@ def send_email(
send_me_a_copy=None,
print_letterhead=None,
is_inbound_mail_communcation=None,
print_language=None,
):
if input_dict := self.sendmail_input_dict(
print_html=print_html,
print_format=print_format,
send_me_a_copy=send_me_a_copy,
print_letterhead=print_letterhead,
is_inbound_mail_communcation=is_inbound_mail_communcation,
print_language=print_language,
):
frappe.sendmail(**input_dict)
2 changes: 1 addition & 1 deletion frappe/core/doctype/doctype/doctype.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class DocType(Document):
custom: DF.Check
default_email_template: DF.Link | None
default_print_format: DF.Data | None
default_view: DF.Literal
default_view: DF.Literal[None]
description: DF.SmallText | None
document_type: DF.Literal["", "Document", "Setup", "System", "Other"]
documentation: DF.Data | None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DocumentNamingRuleCondition(Document):
from frappe.types import DF

condition: DF.Literal["=", "!=", ">", "<", ">=", "<="]
field: DF.Literal
field: DF.Literal[None]
parent: DF.Data
parentfield: DF.Data
parenttype: DF.Data
Expand Down
2 changes: 1 addition & 1 deletion frappe/core/doctype/module_def/module_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ModuleDef(Document):
if TYPE_CHECKING:
from frappe.types import DF

app_name: DF.Literal
app_name: DF.Literal[None]
custom: DF.Check
module_name: DF.Data
package: DF.Link | None
Expand Down
5 changes: 3 additions & 2 deletions frappe/core/doctype/rq_worker/rq_worker.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"in_create": 1,
"is_virtual": 1,
"links": [],
"modified": "2024-01-13 10:36:13.034784",
"modified": "2024-02-29 19:31:08.502527",
"modified_by": "Administrator",
"module": "Core",
"name": "RQ Worker",
Expand All @@ -141,5 +141,6 @@
"color": "Yellow",
"title": "busy"
}
]
],
"title_field": "pid"
}
4 changes: 2 additions & 2 deletions frappe/core/doctype/rq_worker/rq_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class RQWorker(Document):

def load_from_db(self):
all_workers = get_workers()
workers = [w for w in all_workers if w.pid == cint(self.name)]
workers = [w for w in all_workers if w.name == self.name]
if not workers:
raise frappe.DoesNotExistError
d = serialize_worker(workers[0])
Expand Down Expand Up @@ -84,7 +84,7 @@ def serialize_worker(worker: Worker) -> frappe._dict:
current_job = None

return frappe._dict(
name=worker.pid,
name=worker.name,
queue=queue,
queue_type=queue_types,
worker_name=worker.name,
Expand Down
2 changes: 1 addition & 1 deletion frappe/core/doctype/rq_worker/test_rq_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def test_get_worker_list(self):

def test_worker_serialization(self):
workers = RQWorker.get_list({})
frappe.get_doc("RQ Worker", workers[0].pid)
frappe.get_doc("RQ Worker", workers[0].name)
12 changes: 7 additions & 5 deletions frappe/core/doctype/server_script/server_script.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Reference Document Type",
"options": "DocType"
"options": "DocType",
"search_index": 1
},
{
"depends_on": "eval:doc.script_type==='DocType Event'",
"fieldname": "doctype_event",
"fieldtype": "Select",
"label": "DocType Event",
"options": "Before Insert\nBefore Validate\nBefore Save\nAfter Insert\nAfter Save\nBefore Submit\nAfter Submit\nBefore Cancel\nAfter Cancel\nBefore Delete\nAfter Delete\nBefore Save (Submitted Document)\nAfter Save (Submitted Document)\nOn Payment Authorization"
"options": "Before Insert\nBefore Validate\nBefore Save\nAfter Insert\nAfter Save\nBefore Rename\nAfter Rename\nBefore Submit\nAfter Submit\nBefore Cancel\nAfter Cancel\nBefore Delete\nAfter Delete\nBefore Save (Submitted Document)\nAfter Save (Submitted Document)\nOn Payment Authorization"
},
{
"depends_on": "eval:doc.script_type==='API'",
Expand Down Expand Up @@ -106,7 +107,8 @@
"fieldname": "module",
"fieldtype": "Link",
"label": "Module (for export)",
"options": "Module Def"
"options": "Module Def",
"search_index": 1
},
{
"depends_on": "eval:doc.script_type==='API'",
Expand Down Expand Up @@ -149,7 +151,7 @@
"link_fieldname": "server_script"
}
],
"modified": "2023-10-14 11:24:46.478533",
"modified": "2024-02-27 11:44:46.397495",
"modified_by": "Administrator",
"module": "Core",
"name": "Server Script",
Expand All @@ -173,4 +175,4 @@
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
}
2 changes: 2 additions & 0 deletions frappe/core/doctype/server_script/server_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class ServerScript(Document):
"Before Save",
"After Insert",
"After Save",
"Before Rename",
"After Rename",
"Before Submit",
"After Submit",
"Before Cancel",
Expand Down
2 changes: 2 additions & 0 deletions frappe/core/doctype/server_script/server_script_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"before_validate": "Before Validate",
"validate": "Before Save",
"on_update": "After Save",
"before_rename": "Before Rename",
"after_rename": "After Rename",
"before_submit": "Before Submit",
"on_submit": "After Submit",
"before_cancel": "Before Cancel",
Expand Down

0 comments on commit 34a6909

Please sign in to comment.