Skip to content

Commit

Permalink
Merge pull request #491 from frappe/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik authored Dec 27, 2024
2 parents 65f7d3a + ff1c373 commit 5cbc3e3
Show file tree
Hide file tree
Showing 21 changed files with 466 additions and 118 deletions.
Empty file.
94 changes: 94 additions & 0 deletions crm/fcrm/doctype/crm_dropdown_item/crm_dropdown_item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2024-12-27 17:42:33.089685",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"name1",
"label",
"type",
"route",
"open_in_new_window",
"hidden",
"is_standard",
"column_break_mvbq",
"icon"
],
"fields": [
{
"fieldname": "label",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Label",
"mandatory_depends_on": "eval:doc.type == 'Route'"
},
{
"fieldname": "type",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Type",
"options": "Route\nSeparator",
"read_only_depends_on": "eval:doc.is_standard"
},
{
"depends_on": "eval:doc.type == 'Route'",
"fieldname": "route",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Route",
"mandatory_depends_on": "eval:doc.type == 'Route'"
},
{
"default": "0",
"fieldname": "hidden",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Hidden"
},
{
"default": "0",
"fieldname": "is_standard",
"fieldtype": "Check",
"label": "Is Standard",
"read_only": 1
},
{
"fieldname": "column_break_mvbq",
"fieldtype": "Column Break"
},
{
"description": "Add svg code or use feather icons e.g 'settings'",
"fieldname": "icon",
"fieldtype": "Code",
"label": "Icon"
},
{
"default": "1",
"depends_on": "eval:doc.type == 'Route'",
"fieldname": "open_in_new_window",
"fieldtype": "Check",
"label": "Open in new window"
},
{
"depends_on": "eval:doc.is_standard",
"fieldname": "name1",
"fieldtype": "Data",
"label": "Name",
"read_only": 1,
"unique": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-12-27 19:35:53.012508",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Dropdown Item",
"owner": "Administrator",
"permissions": [],
"sort_field": "creation",
"sort_order": "DESC",
"states": []
}
9 changes: 9 additions & 0 deletions crm/fcrm/doctype/crm_dropdown_item/crm_dropdown_item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class CRMDropdownItem(Document):
pass
48 changes: 46 additions & 2 deletions crm/fcrm/doctype/fcrm_settings/fcrm_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,63 @@
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"restore_defaults"
"defaults_tab",
"restore_defaults",
"branding_tab",
"brand_name",
"brand_logo",
"favicon",
"dropdown_items_tab",
"dropdown_items"
],
"fields": [
{
"fieldname": "restore_defaults",
"fieldtype": "Button",
"label": "Restore Defaults"
},
{
"fieldname": "dropdown_items",
"fieldtype": "Table",
"options": "CRM Dropdown Item"
},
{
"fieldname": "defaults_tab",
"fieldtype": "Tab Break",
"label": "Defaults"
},
{
"fieldname": "branding_tab",
"fieldtype": "Tab Break",
"label": "Branding"
},
{
"description": "An image with 1:1 & 2:1 ratio is preferred",
"fieldname": "brand_logo",
"fieldtype": "Attach",
"label": "Logo"
},
{
"fieldname": "dropdown_items_tab",
"fieldtype": "Tab Break",
"label": "Dropdown Items"
},
{
"fieldname": "brand_name",
"fieldtype": "Data",
"label": "Name"
},
{
"description": "An icon file with .ico extension. Should be 16 x 16 px. Generated using a favicon generator. [favicon-generator.org]",
"fieldname": "favicon",
"fieldtype": "Attach",
"label": "Favicon"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2024-09-29 13:49:07.835379",
"modified": "2024-12-27 22:17:52.337109",
"modified_by": "Administrator",
"module": "FCRM",
"name": "FCRM Settings",
Expand Down
26 changes: 26 additions & 0 deletions crm/fcrm/doctype/fcrm_settings/fcrm_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,36 @@

import frappe
from frappe.model.document import Document

from crm.install import after_install


class FCRMSettings(Document):
@frappe.whitelist()
def restore_defaults(self, force=False):
after_install(force)


def after_migrate():
sync_table("dropdown_items", "standard_dropdown_items")


def sync_table(key, hook):
crm_settings = FCRMSettings("FCRM Settings")
existing_items = {d.name1: d for d in crm_settings.get(key)}
new_standard_items = {}

# add new items
count = 0 # maintain count because list may come from seperate apps
for item in frappe.get_hooks(hook):
if item.get("name1") not in existing_items:
crm_settings.append(key, item, count)
new_standard_items[item.get("name1")] = True
count += 1

# remove unused items
items = crm_settings.get(key)
items = [item for item in items if not (item.is_standard and (item.name1 not in new_standard_items))]
crm_settings.set(key, items)

crm_settings.save()
Loading

0 comments on commit 5cbc3e3

Please sign in to comment.