mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-24 09:08:30 +00:00
fix: add permission validation when prompting company details for incomplete letterhead data
(cherry picked from commit 256a258b38)
This commit is contained in:
@@ -4357,6 +4357,15 @@ def get_missing_company_details(doctype, docname):
|
|||||||
|
|
||||||
address_display_list = get_address_display_list("Company", company)
|
address_display_list = get_address_display_list("Company", company)
|
||||||
address_line = address_display_list[0].get("address_line1") if address_display_list else ""
|
address_line = address_display_list[0].get("address_line1") if address_display_list else ""
|
||||||
|
needs_new_company_address = not address_line
|
||||||
|
|
||||||
|
if needs_new_company_address and not frappe.has_permission("Address", "create", throw=False):
|
||||||
|
frappe.msgprint(
|
||||||
|
_(
|
||||||
|
"Company Address is missing. You don't have permission to create an Address. Please contact your System Manager."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
required_fields.append(company_address)
|
required_fields.append(company_address)
|
||||||
required_fields.append(address_line)
|
required_fields.append(address_line)
|
||||||
@@ -4379,6 +4388,18 @@ def get_missing_company_details(doctype, docname):
|
|||||||
def update_company_master_and_address(current_doctype, name, company, details):
|
def update_company_master_and_address(current_doctype, name, company, details):
|
||||||
from frappe.utils import validate_email_address
|
from frappe.utils import validate_email_address
|
||||||
|
|
||||||
|
if not frappe.has_permission(current_doctype, "write", doc=name, throw=False):
|
||||||
|
frappe.throw(
|
||||||
|
_("You don't have permission to update this document. Please contact your System Manager."),
|
||||||
|
title=_("Insufficient Permissions"),
|
||||||
|
)
|
||||||
|
|
||||||
|
if not frappe.has_permission("Company", "write", doc=company, throw=False):
|
||||||
|
frappe.throw(
|
||||||
|
_("You don't have permission to update Company details. Please contact your System Manager."),
|
||||||
|
title=_("Insufficient Permissions"),
|
||||||
|
)
|
||||||
|
|
||||||
if isinstance(details, str):
|
if isinstance(details, str):
|
||||||
details = frappe.parse_json(details)
|
details = frappe.parse_json(details)
|
||||||
|
|
||||||
@@ -4393,6 +4414,13 @@ def update_company_master_and_address(current_doctype, name, company, details):
|
|||||||
|
|
||||||
company_address = details.get("company_address")
|
company_address = details.get("company_address")
|
||||||
if details.get("address_line1"):
|
if details.get("address_line1"):
|
||||||
|
if not frappe.has_permission("Address", "create", throw=False):
|
||||||
|
frappe.throw(
|
||||||
|
_(
|
||||||
|
"You don't have permission to create a Company Address. Please contact your System Manager."
|
||||||
|
),
|
||||||
|
title=_("Insufficient Permissions"),
|
||||||
|
)
|
||||||
address_doc = frappe.get_doc(
|
address_doc = frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "Address",
|
"doctype": "Address",
|
||||||
|
|||||||
Reference in New Issue
Block a user