mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-26 05:15:20 +00:00
Merge branch 'develop' into feat/employee-creation-and-lifecycle
This commit is contained in:
@@ -32,8 +32,7 @@ class Department(NestedSet):
|
||||
nsm_parent_field = "parent_department"
|
||||
|
||||
def autoname(self):
|
||||
root = get_root_of("Department")
|
||||
if root and self.department_name != root:
|
||||
if self.company:
|
||||
self.name = get_abbreviated_name(self.department_name, self.company)
|
||||
else:
|
||||
self.name = self.department_name
|
||||
|
||||
@@ -563,3 +563,59 @@ def has_upload_permission(doc, ptype="read", user=None):
|
||||
if get_doc_permissions(doc, user=user, ptype=ptype).get(ptype):
|
||||
return True
|
||||
return doc.user_id == user
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_contact_details(employee: str) -> dict:
|
||||
"""
|
||||
Returns basic contact details for the given employee.
|
||||
|
||||
Email is selected based on the following priority:
|
||||
1. Prefered Email
|
||||
2. Company Email
|
||||
3. Personal Email
|
||||
4. User ID
|
||||
"""
|
||||
if not employee:
|
||||
frappe.throw(msg=_("Employee is required"), title=_("Missing Parameter"))
|
||||
|
||||
frappe.has_permission("Employee", "read", employee, throw=True)
|
||||
|
||||
return _get_contact_details(employee)
|
||||
|
||||
|
||||
def _get_contact_details(employee: str) -> dict:
|
||||
contact_data = frappe.db.get_value(
|
||||
"Employee",
|
||||
employee,
|
||||
[
|
||||
"employee_name",
|
||||
"prefered_email",
|
||||
"company_email",
|
||||
"personal_email",
|
||||
"user_id",
|
||||
"cell_number",
|
||||
"designation",
|
||||
"department",
|
||||
],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
if not contact_data:
|
||||
frappe.throw(msg=_("Employee {0} not found").format(employee), title=_("Not Found"))
|
||||
|
||||
# Email with priority
|
||||
employee_email = (
|
||||
contact_data.get("prefered_email")
|
||||
or contact_data.get("company_email")
|
||||
or contact_data.get("personal_email")
|
||||
or contact_data.get("user_id")
|
||||
)
|
||||
|
||||
return {
|
||||
"contact_display": contact_data.get("employee_name"),
|
||||
"contact_email": employee_email,
|
||||
"contact_mobile": contact_data.get("cell_number"),
|
||||
"contact_designation": contact_data.get("designation"),
|
||||
"contact_department": contact_data.get("department"),
|
||||
}
|
||||
|
||||
@@ -165,6 +165,8 @@ class TransactionDeletionRecord(Document):
|
||||
|
||||
def validate(self):
|
||||
frappe.only_for("System Manager")
|
||||
if not self.doctypes_to_be_ignored:
|
||||
self.populate_doctypes_to_be_ignored_table()
|
||||
self.validate_to_delete_list()
|
||||
|
||||
def validate_to_delete_list(self):
|
||||
|
||||
@@ -23,7 +23,7 @@ def after_install():
|
||||
|
||||
set_single_defaults()
|
||||
create_print_setting_custom_fields()
|
||||
create_marketgin_campagin_custom_fields()
|
||||
create_marketing_campaign_custom_fields()
|
||||
create_custom_company_links()
|
||||
add_all_roles_to("Administrator")
|
||||
create_default_success_action()
|
||||
@@ -35,6 +35,7 @@ def after_install():
|
||||
update_roles()
|
||||
make_default_operations()
|
||||
update_pegged_currencies()
|
||||
set_default_print_formats()
|
||||
create_letter_head()
|
||||
frappe.db.commit()
|
||||
|
||||
@@ -119,16 +120,16 @@ def create_print_setting_custom_fields():
|
||||
)
|
||||
|
||||
|
||||
def create_marketgin_campagin_custom_fields():
|
||||
def create_marketing_campaign_custom_fields():
|
||||
create_custom_fields(
|
||||
{
|
||||
"UTM Campaign": [
|
||||
{
|
||||
"label": _("Messaging CRM Campagin"),
|
||||
"label": _("Messaging CRM Campaign"),
|
||||
"fieldname": "crm_campaign",
|
||||
"fieldtype": "Link",
|
||||
"options": "Campaign",
|
||||
"insert_after": "campaign_decription",
|
||||
"insert_after": "campaign_description",
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -301,6 +302,35 @@ def update_pegged_currencies():
|
||||
doc.save()
|
||||
|
||||
|
||||
def set_default_print_formats():
|
||||
default_map = {
|
||||
"Sales Order": "Sales Order with Item Image",
|
||||
"Sales Invoice": "Sales Invoice with Item Image",
|
||||
"Delivery Note": "Delivery Note with Item Image",
|
||||
"Purchase Order": "Purchase Order with Item Image",
|
||||
"Purchase Invoice": "Purchase Invoice with Item Image",
|
||||
"POS Invoice": "POS Invoice with Item Image",
|
||||
}
|
||||
|
||||
for doctype, print_format in default_map.items():
|
||||
if frappe.get_meta(doctype).default_print_format:
|
||||
continue
|
||||
|
||||
if not frappe.db.exists("Print Format", print_format):
|
||||
continue
|
||||
|
||||
frappe.make_property_setter(
|
||||
{
|
||||
"doctype": doctype,
|
||||
"doctype_or_field": "DocType",
|
||||
"property": "default_print_format",
|
||||
"value": print_format,
|
||||
"property_type": "Link",
|
||||
},
|
||||
validate_fields_for_doctype=False,
|
||||
)
|
||||
|
||||
|
||||
def create_letter_head():
|
||||
base_path = frappe.get_app_path("erpnext", "accounts", "letterhead")
|
||||
|
||||
@@ -318,6 +348,7 @@ def create_letter_head():
|
||||
"letter_head_name": name,
|
||||
"source": "HTML",
|
||||
"content": content,
|
||||
"is_default": 1 if name == "Company Letterhead - Grey" else 0,
|
||||
}
|
||||
)
|
||||
doc.insert(ignore_permissions=True)
|
||||
|
||||
Reference in New Issue
Block a user