1
0
forked from test/crm

fix: create standard forecasting script on install and added in patch

(cherry picked from commit b3acff8cba6fd30e15ce2d579287cbd02d9c8282)
This commit is contained in:
Shariq Ansari 2025-06-13 14:42:09 +05:30 committed by Mergify
parent e9362a50eb
commit 232f982786
3 changed files with 40 additions and 1 deletions

View File

@ -76,3 +76,40 @@ def sync_table(key, hook):
crm_settings.set(key, items)
crm_settings.save()
def create_forecasting_script():
if not frappe.db.exists("CRM Form Script", "Forecasting Script"):
script = get_forecasting_script()
frappe.get_doc(
{
"doctype": "CRM Form Script",
"name": "Forecasting Script",
"dt": "CRM Deal",
"view": "Form",
"script": script,
"enabled": 1,
"is_standard": 1,
}
).insert()
def get_forecasting_script():
return (
"""
class CRMDeal {
async status() {
await this.doc.trigger('updateProbability')
}
async updateProbability() {
let status = await call("frappe.client.get_value", {
doctype: "CRM Deal Status",
fieldname: "probability",
filters: { name: this.doc.status },
})
this.doc.probability = status.probability
}
}
"""
)

View File

@ -5,6 +5,7 @@ import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from crm.fcrm.doctype.crm_products.crm_products import create_product_details_script
from crm.fcrm.doctype.fcrm_settings.fcrm_settings import create_forecasting_script
def before_install():
@ -361,3 +362,4 @@ def add_standard_dropdown_items():
def add_default_scripts():
for doctype in ["CRM Lead", "CRM Deal"]:
create_product_details_script(doctype)
create_forecasting_script()

View File

@ -12,4 +12,4 @@ crm.patches.v1_0.create_default_sidebar_fields_layout
crm.patches.v1_0.update_deal_quick_entry_layout
crm.patches.v1_0.update_layouts_to_new_format
crm.patches.v1_0.move_twilio_agent_to_telephony_agent
crm.patches.v1_0.create_default_scripts
crm.patches.v1_0.create_default_scripts # 13-06-2025