fix: get_all replace by sql
This commit is contained in:
parent
2d226be3c4
commit
f72d5506de
@ -4,7 +4,7 @@ from frappe.utils import add_months, cstr, today
|
|||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
for doctype in ("Lead", "Opportunity", "Prospect", "Prospect Lead"):
|
for doctype in ("CRM Note", "Lead", "Opportunity", "Prospect", "Prospect Lead"):
|
||||||
frappe.reload_doc("crm", "doctype", doctype)
|
frappe.reload_doc("crm", "doctype", doctype)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -28,11 +28,16 @@ def execute():
|
|||||||
|
|
||||||
def add_calendar_event_for_leads():
|
def add_calendar_event_for_leads():
|
||||||
# create events based on next contact date
|
# create events based on next contact date
|
||||||
leads = frappe.get_all(
|
leads = frappe.db.sql(
|
||||||
"Lead",
|
"""
|
||||||
{"contact_date": [">=", add_months(today(), -1)]},
|
select name, contact_date, contact_by, ends_on, lead_name, lead_owner
|
||||||
["name", "contact_date", "contact_by", "ends_on", "lead_name", "lead_owner"],
|
from tabLead
|
||||||
|
where contact_date >= %s
|
||||||
|
""",
|
||||||
|
add_months(today(), -1),
|
||||||
|
as_dict=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
for d in leads:
|
for d in leads:
|
||||||
event = frappe.get_doc(
|
event = frappe.get_doc(
|
||||||
{
|
{
|
||||||
@ -55,19 +60,17 @@ def add_calendar_event_for_leads():
|
|||||||
|
|
||||||
def add_calendar_event_for_opportunities():
|
def add_calendar_event_for_opportunities():
|
||||||
# create events based on next contact date
|
# create events based on next contact date
|
||||||
opportunities = frappe.get_all(
|
opportunities = frappe.db.sql(
|
||||||
"Opportunity",
|
"""
|
||||||
{"contact_date": [">=", add_months(today(), -1)]},
|
select name, contact_date, contact_by, to_discuss,
|
||||||
[
|
party_name, opportunity_owner, contact_person
|
||||||
"name",
|
from tabOpportunity
|
||||||
"contact_date",
|
where contact_date >= %s
|
||||||
"contact_by",
|
""",
|
||||||
"to_discuss",
|
add_months(today(), -1),
|
||||||
"party_name",
|
as_dict=1,
|
||||||
"opportunity_owner",
|
|
||||||
"contact_person",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for d in opportunities:
|
for d in opportunities:
|
||||||
event = frappe.get_doc(
|
event = frappe.get_doc(
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user