Skip to content

Commit

Permalink
Merge branch 'version-14' of https://github.com/frappe/frappe into ve…
Browse files Browse the repository at this point in the history
…rsion-14
  • Loading branch information
aliriocastro committed Nov 5, 2024
2 parents 468f3a9 + a44ecb2 commit 5855e2f
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 45 deletions.
28 changes: 7 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,19 @@
</div>

<div align="center">
<a href="https://github.com/frappe/frappe/actions/workflows/server-mariadb-tests.yml">
<img src="https://github.com/frappe/frappe/actions/workflows/server-mariadb-tests.yml/badge.svg">
</a>
<a href="https://github.com/frappe/frappe/actions/workflows/ui-tests.yml">
<img src="https://github.com/frappe/frappe/actions/workflows/ui-tests.yml/badge.svg?branch=develop">
</a>
<a href='https://frappeframework.com/docs'>
<img src='https://img.shields.io/badge/docs-📖-7575FF.svg?style=flat-square'/>
</a>
<a href='https://www.codetriage.com/frappe/frappe'>
<img src='https://www.codetriage.com/frappe/frappe/badges/users.svg'>
</a>
<a href="https://codecov.io/gh/frappe/frappe">
<img src="https://codecov.io/gh/frappe/frappe/branch/develop/graph/badge.svg?token=XoTa679hIj"/>
</a>
<a href="https://github.com/frappe/frappe/actions/workflows/server-mariadb-tests.yml"><img src="https://github.com/frappe/frappe/actions/workflows/server-mariadb-tests.yml/badge.svg"></a>
<a href="https://github.com/frappe/frappe/actions/workflows/ui-tests.yml"><img src="https://github.com/frappe/frappe/actions/workflows/ui-tests.yml/badge.svg?branch=develop"></a>
<a href='https://frappeframework.com/docs'><img src='https://img.shields.io/badge/docs-📖-7575FF.svg?style=flat-square'/></a>
<a href='https://www.codetriage.com/frappe/frappe'><img src='https://www.codetriage.com/frappe/frappe/badges/users.svg'></a>
<a href="https://codecov.io/gh/frappe/frappe"><img src="https://codecov.io/gh/frappe/frappe/branch/develop/graph/badge.svg?token=XoTa679hIj"/></a>
</div>


Full-stack web application framework that uses Python and MariaDB on the server side and a tightly integrated client side library. Built for [ERPNext](https://erpnext.com)

<div align="center" style="max-height: 40px;">
<a href="https://frappecloud.com/frappe/signup">
<img src=".github/try-on-f-cloud-button.svg" height="40">
</a>
<a href="https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/gavindsouza/install-scripts/main/frappe/pwd.yml">
<img src="https://raw.githubusercontent.com/play-with-docker/stacks/master/assets/images/button.png" alt="Try in PWD" height="37"/>
</a>
<a href="https://frappecloud.com/frappe/signup"><img src=".github/try-on-f-cloud-button.svg" height="40"></a>
<a href="https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/gavindsouza/install-scripts/main/frappe/pwd.yml"><img src="https://raw.githubusercontent.com/play-with-docker/stacks/master/assets/images/button.png" alt="Try in PWD" height="37"/></a>
</div>

> Login for the PWD site: (username: Administrator, password: admin)
Expand Down
2 changes: 1 addition & 1 deletion frappe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
)
from .utils.lazy_loader import lazy_import

__version__ = "14.82.1"
__version__ = "14.84.0"
__title__ = "Frappe Framework"

controllers = {}
Expand Down
10 changes: 7 additions & 3 deletions frappe/contacts/doctype/contact/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,13 @@ def get_contact_with_phone_number(number):
return contacts[0].parent if contacts else None


def get_contact_name(email_id):
contact = frappe.get_all("Contact Email", filters={"email_id": email_id}, fields=["parent"], limit=1)
return contact[0].parent if contact else None
def get_contact_name(email_id: str) -> str | None:
"""Return the contact ID for the given email ID."""
for contact_id in frappe.get_all(
"Contact Email", filters={"email_id": email_id, "parenttype": "Contact"}, pluck="parent"
):
if frappe.db.exists("Contact", contact_id):
return contact_id


def get_contacts_linking_to(doctype, docname, fields=None):
Expand Down
2 changes: 1 addition & 1 deletion frappe/core/doctype/sms_settings/sms_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def send_via_gateway(arg):
args.update(arg)
create_sms_log(args, success_list)
if arg.get("success_msg"):
frappe.msgprint(_("SMS sent to following numbers: {0}").format("\n" + "\n".join(success_list)))
frappe.msgprint(_("SMS sent successfully"))


def get_headers(sms_settings=None):
Expand Down
2 changes: 2 additions & 0 deletions frappe/core/doctype/success_action/success_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ frappe.ui.form.on("Success Action", {
fieldname: "next_actions_multicheck",
fieldtype: "MultiCheck",
options: action_multicheck_options,
select_all: true,
},
render_input: true,
});
},
});
Expand Down
6 changes: 2 additions & 4 deletions frappe/database/mariadb/setup_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,8 @@ def bootstrap_database(db_name, verbose, source_sql=None):

secho(
"Table 'tabDefaultValue' missing in the restored site. "
"Database not installed correctly, this can due to lack of "
"permission, or that the database name exists. Check your mysql"
" root password, validity of the backup file or use --force to"
" reinstall",
"This happens when the backup fails to restore. Please check that the file is valid\n"
"Do go through the above output to check the exact error message from MariaDB",
fg="red",
)
sys.exit(1)
Expand Down
4 changes: 2 additions & 2 deletions frappe/database/postgres/setup_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def bootstrap_database(db_name, verbose, source_sql=None):

secho(
"Table 'tabDefaultValue' missing in the restored site. "
"This may be due to incorrect permissions or the result of a restore from a bad backup file. "
"Database not installed correctly.",
"This happens when the backup fails to restore. Please check that the file is valid\n"
"Do go through the above output to check the exact error message from MariaDB",
fg="red",
)
sys.exit(1)
Expand Down
12 changes: 10 additions & 2 deletions frappe/desk/doctype/list_view_settings/list_view_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"disable_count",
"disable_sidebar_stats",
"disable_auto_refresh",
"allow_edit",
"total_fields",
"fields_html",
"fields"
Expand Down Expand Up @@ -49,10 +50,17 @@
"hidden": 1,
"label": "Fields",
"read_only": 1
},
{
"default": "0",
"description": "Allow editing even if the doctype has a workflow set up.\n\nDoes nothing if a workflow isn't set up.",
"fieldname": "allow_edit",
"fieldtype": "Check",
"label": "Allow Bulk Editing"
}
],
"links": [],
"modified": "2020-05-12 18:27:15.568199",
"modified": "2024-08-21 18:17:24.889783",
"modified_by": "Administrator",
"module": "Desk",
"name": "List View Settings",
Expand All @@ -73,4 +81,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
}
5 changes: 5 additions & 0 deletions frappe/desk/query_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,11 @@ def add_total_row(result, columns, meta=None, is_tree=False, parent_field=None):
if i >= len(row):
continue
cell = row.get(fieldname) if isinstance(row, dict) else row[i]
if fieldtype is None:
if isinstance(cell, int):
fieldtype = "Int"
elif isinstance(cell, float):
fieldtype = "Float"
if fieldtype in ["Currency", "Int", "Float", "Percent", "Duration"] and flt(cell):
if not (is_tree and row.get(parent_field)):
total_row[i] = flt(total_row[i]) + flt(cell)
Expand Down
1 change: 1 addition & 0 deletions frappe/integrations/doctype/webhook/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def get_context(doc):


def enqueue_webhook(doc, webhook) -> None:
headers = data = None
try:
webhook: Webhook = frappe.get_doc("Webhook", webhook.get("name"))
headers = get_webhook_headers(doc, webhook)
Expand Down
2 changes: 1 addition & 1 deletion frappe/integrations/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def authorize(**kwargs):
resp_html = frappe.render_template(
"templates/includes/oauth_confirmation.html", response_html_params
)
frappe.respond_as_web_page("Confirm Access", resp_html, primary_action=None)
frappe.respond_as_web_page(frappe._("Confirm Access"), resp_html, primary_action=None)
except (FatalClientError, OAuth2Error) as e:
return generate_json_error_response(e)

Expand Down
4 changes: 2 additions & 2 deletions frappe/model/rename_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def update_document_title(
title_updated = updated_title and (title_field != "name") and (updated_title != doc.get(title_field))
name_updated = updated_name and (updated_name != doc.name)

queue = kwargs.get("queue") or "default"
queue = kwargs.get("queue") or "long"

if name_updated:
if enqueue and not is_scheduler_inactive():
Expand All @@ -85,7 +85,7 @@ def update_document_title(
save_point=True,
)

doc.queue_action("rename", name=transformed_name, merge=merge, queue=queue)
doc.queue_action("rename", name=transformed_name, merge=merge, queue=queue, timeout=36000)
else:
doc.rename(updated_name, merge=merge)

Expand Down
4 changes: 3 additions & 1 deletion frappe/model/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def render_include(content):
if path.endswith(".html"):
include = html_to_js_template(path, include)

content = re.sub(rf"""{{% include\s['"]{path}['"]\s%}}""", include, content)
content = re.sub(
rf"""{{% include\s['"]{path}['"]\s%}}""", include.replace("\\", "\\\\"), content
)

else:
break
Expand Down
2 changes: 1 addition & 1 deletion frappe/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def check_user_permission_on_link_fields(d):
# get the list of all allowed values for this link
allowed_docs = get_allowed_docs_for_doctype(user_permissions.get(field.options, []), doctype)

if allowed_docs and d.get(field.fieldname) not in allowed_docs:
if allowed_docs and str(d.get(field.fieldname)) not in allowed_docs:
# restricted for this link field, and no matching values found
# make the right message and exit
if d.get("parentfield"):
Expand Down
5 changes: 3 additions & 2 deletions frappe/public/js/frappe/form/controls/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlDat
me.$link.toggle(true);
me.$link_open.attr("href", frappe.utils.get_form_link(doctype, name));
me.$link_clear.on("click", function () {
me.$input.val("").trigger("input");
me.$link.toggle(false);
me.set_value("");
me.validate();
});
}

Expand Down Expand Up @@ -327,7 +328,7 @@ frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlDat
me.$input.cache[doctype][term] = r.results;
me.awesomplete.list = me.$input.cache[doctype][term];
me.toggle_href(doctype);
r.message.forEach((item) => {
r.results.forEach((item) => {
frappe.utils.add_link_title(doctype, item.value, item.label);
});
},
Expand Down
3 changes: 2 additions & 1 deletion frappe/public/js/frappe/form/controls/phone.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ frappe.ui.form.ControlPhone = class ControlPhone extends frappe.ui.form.ControlD
refresh() {
super.refresh();
// Previously opened doc values showing up on a new doc
// Previously opened doc values showing up on other docs where phone fields is empty

if (this.frm && this.frm.doc.__islocal && !this.get_value()) {
if (!this.get_value()) {
this.reset_input();
}
}
Expand Down
10 changes: 9 additions & 1 deletion frappe/public/js/frappe/list/list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,14 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
return frappe.perm.has_perm(doctype, 0, "submit");
};

const is_bulk_edit_allowed = (doctype) => {
// Check settings if there is a workflow defined, otherwise directly allow
if (frappe.model.has_workflow(doctype)) {
return !!this.list_view_settings?.allow_edit;
}
return true;
};

// utility
const bulk_assignment = () => {
return {
Expand Down Expand Up @@ -1970,7 +1978,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
};

// bulk edit
if (has_editable_fields(doctype) && !frappe.model.has_workflow(doctype)) {
if (has_editable_fields(doctype) && is_bulk_edit_allowed(doctype)) {
actions_menu_items.push(bulk_edit());
}

Expand Down
27 changes: 27 additions & 0 deletions frappe/public/js/frappe/ui/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup {
this.get_close_btn().hide();
}

if (!this.size) this.set_modal_size();

this.wrapper = this.$wrapper.find(".modal-dialog").get(0);
if (this.size == "small") $(this.wrapper).addClass("modal-sm");
else if (this.size == "large") $(this.wrapper).addClass("modal-lg");
Expand Down Expand Up @@ -123,6 +125,31 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup {
});
}

set_modal_size() {
if (!this.fields) {
this.size = "";
return;
}

let col_brk = 0;
let cur_col_brk = 0;

// if fields have more than 2 Column Breaks before encountering Section Break, make it large
this.fields.forEach((field) => {
if (field.fieldtype == "Column Break") {
cur_col_brk++;

if (cur_col_brk > col_brk) {
col_brk = cur_col_brk;
}
} else if (field.fieldtype == "Section Break") {
cur_col_brk = 0;
}
});

this.size = col_brk >= 4 ? "extra-large" : col_brk >= 2 ? "large" : "";
}

get_primary_btn() {
return this.standard_actions.find(".btn-primary");
}
Expand Down
2 changes: 1 addition & 1 deletion frappe/public/js/frappe/utils/number_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function get_currency_symbol(currency) {
function get_number_format(currency) {
let sysdefaults = frappe?.boot?.sysdefaults;
return (
(sysdefaults.use_number_format_from_currency &&
(cint(sysdefaults?.use_number_format_from_currency) &&
currency &&
frappe.model.get_value(":Currency", currency, "number_format")) ||
sysdefaults.number_format ||
Expand Down
6 changes: 6 additions & 0 deletions frappe/public/js/frappe/widgets/quick_list_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ export default class QuickListWidget extends Widget {
workflow_fieldname && fields.push(workflow_fieldname);
fields.push("modified");

let add_fields = frappe.listview_settings?.[this.document_type]?.add_fields;
if (Array.isArray(add_fields)) {
fields.push(...add_fields);
fields = [...new Set(fields)];
}

let quick_list_filter = frappe.utils.process_filter_expression(this.quick_list_filter);

let args = {
Expand Down
2 changes: 1 addition & 1 deletion frappe/templates/includes/oauth_confirmation.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="panel-body">
<ul>
{% for dtl in details %}
<li>{{ dtl.title() }}</li>
<li>{{ _(dtl.title()) }}</li>
{% endfor %}
</ul>
<div class="action-buttons d-flex">
Expand Down

0 comments on commit 5855e2f

Please sign in to comment.