fix: changed is_erpnext_in_same_site to is_erpnext_in_different site

This commit is contained in:
Shariq Ansari 2024-09-16 14:30:33 +05:30
parent 2e49844ea0
commit 16a8671744
3 changed files with 27 additions and 22 deletions

View File

@ -6,7 +6,7 @@
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"enabled", "enabled",
"is_erpnext_in_the_current_site", "is_erpnext_in_different_site",
"column_break_vfru", "column_break_vfru",
"erpnext_company", "erpnext_company",
"section_break_oubd", "section_break_oubd",
@ -17,18 +17,18 @@
], ],
"fields": [ "fields": [
{ {
"depends_on": "eval:doc.enabled && !doc.is_erpnext_in_the_current_site", "depends_on": "eval:doc.enabled && doc.is_erpnext_in_different_site",
"fieldname": "api_key", "fieldname": "api_key",
"fieldtype": "Data", "fieldtype": "Data",
"label": "API Key", "label": "API Key",
"mandatory_depends_on": "eval:!doc.is_erpnext_in_the_current_site" "mandatory_depends_on": "eval:!doc.is_erpnext_in_different_site"
}, },
{ {
"depends_on": "eval:doc.enabled && !doc.is_erpnext_in_the_current_site", "depends_on": "eval:doc.enabled && doc.is_erpnext_in_different_site",
"fieldname": "api_secret", "fieldname": "api_secret",
"fieldtype": "Data", "fieldtype": "Data",
"label": "API Secret", "label": "API Secret",
"mandatory_depends_on": "eval:!doc.is_erpnext_in_the_current_site" "mandatory_depends_on": "eval:!doc.is_erpnext_in_different_site"
}, },
{ {
"depends_on": "enabled", "depends_on": "enabled",
@ -40,11 +40,11 @@
"fieldtype": "Column Break" "fieldtype": "Column Break"
}, },
{ {
"depends_on": "eval:doc.enabled && !doc.is_erpnext_in_the_current_site", "depends_on": "eval:doc.enabled && doc.is_erpnext_in_different_site",
"fieldname": "erpnext_site_url", "fieldname": "erpnext_site_url",
"fieldtype": "Data", "fieldtype": "Data",
"label": "ERPNext Site URL", "label": "ERPNext Site URL",
"mandatory_depends_on": "eval:!doc.is_erpnext_in_the_current_site" "mandatory_depends_on": "eval:!doc.is_erpnext_in_different_site"
}, },
{ {
"depends_on": "enabled", "depends_on": "enabled",
@ -57,24 +57,24 @@
"fieldname": "column_break_vfru", "fieldname": "column_break_vfru",
"fieldtype": "Column Break" "fieldtype": "Column Break"
}, },
{
"default": "0",
"depends_on": "enabled",
"fieldname": "is_erpnext_in_the_current_site",
"fieldtype": "Check",
"label": "Is ERPNext in the current site?"
},
{ {
"default": "0", "default": "0",
"fieldname": "enabled", "fieldname": "enabled",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Enabled" "label": "Enabled"
},
{
"default": "0",
"depends_on": "enabled",
"fieldname": "is_erpnext_in_different_site",
"fieldtype": "Check",
"label": "Is ERPNext installed on a different site?"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"issingle": 1, "issingle": 1,
"links": [], "links": [],
"modified": "2024-09-13 15:06:23.317262", "modified": "2024-09-16 13:51:35.141503",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "FCRM", "module": "FCRM",
"name": "ERPNext CRM Settings", "name": "ERPNext CRM Settings",

View File

@ -18,12 +18,12 @@ class ERPNextCRMSettings(Document):
self.create_crm_form_script() self.create_crm_form_script()
def validate_if_erpnext_installed(self): def validate_if_erpnext_installed(self):
if self.is_erpnext_in_the_current_site: if not self.is_erpnext_in_different_site:
if "erpnext" not in frappe.get_installed_apps(): if "erpnext" not in frappe.get_installed_apps():
frappe.throw(_("ERPNext is not installed in the current site")) frappe.throw(_("ERPNext is not installed in the current site"))
def add_quotation_to_option(self): def add_quotation_to_option(self):
if self.is_erpnext_in_the_current_site: if not self.is_erpnext_in_different_site:
if not frappe.db.exists("Property Setter", {"name": "Quotation-quotation_to-link_filters"}): if not frappe.db.exists("Property Setter", {"name": "Quotation-quotation_to-link_filters"}):
make_property_setter( make_property_setter(
doctype="Quotation", doctype="Quotation",
@ -35,7 +35,7 @@ class ERPNextCRMSettings(Document):
) )
def create_custom_fields(self): def create_custom_fields(self):
if self.is_erpnext_in_the_current_site: if not self.is_erpnext_in_different_site:
from erpnext.crm.frappe_crm_api import create_custom_fields_for_frappe_crm from erpnext.crm.frappe_crm_api import create_custom_fields_for_frappe_crm
create_custom_fields_for_frappe_crm() create_custom_fields_for_frappe_crm()
else: else:
@ -80,7 +80,7 @@ def get_quotation_url(crm_deal, organization):
if not erpnext_crm_settings.enabled: if not erpnext_crm_settings.enabled:
frappe.throw(_("ERPNext is not integrated with the CRM")) frappe.throw(_("ERPNext is not integrated with the CRM"))
if erpnext_crm_settings.is_erpnext_in_the_current_site: if not erpnext_crm_settings.is_erpnext_in_different_site:
quotation_url = get_url_to_form("Quotation") quotation_url = get_url_to_form("Quotation")
return f"{quotation_url}/new?quotation_to=CRM Deal&crm_deal={crm_deal}&party_name={crm_deal}" return f"{quotation_url}/new?quotation_to=CRM Deal&crm_deal={crm_deal}&party_name={crm_deal}"
else: else:
@ -147,7 +147,7 @@ def create_customer_in_erpnext(doc, method):
"crm_deal": doc.name, "crm_deal": doc.name,
"contacts": json.dumps(contacts), "contacts": json.dumps(contacts),
} }
if erpnext_crm_settings.is_erpnext_in_the_current_site: if not erpnext_crm_settings.is_erpnext_in_different_site:
from erpnext.crm.frappe_crm_api import create_customer from erpnext.crm.frappe_crm_api import create_customer
create_customer(customer) create_customer(customer)
else: else:

View File

@ -1,6 +1,11 @@
<template> <template>
<SettingsPage doctype="ERPNext CRM Settings" :title="__('ERPNext Settings')" class="p-8" /> <SettingsPage
doctype="ERPNext CRM Settings"
:title="__('ERPNext Settings')"
:successMessage="__('ERPNext Settings updated')"
class="p-8"
/>
</template> </template>
<script setup> <script setup>
import SettingsPage from '@/components/Settings/SettingsPage.vue' import SettingsPage from '@/components/Settings/SettingsPage.vue'
</script> </script>