CRM

CRM

Frappe CRM <> ERPNext

Frappe CRM, while a standalone application, offers seamless integration with ERPNext to streamline your business processes. This integration allows you to create quotations and customers directly from deals within Frappe CRM, enhancing efficiency and reducing manual data entry.

ERPNext Setup

ERPNext on the same site

When Frappe CRM and ERPNext are installed on the same site:

  1. Navigate to Settings -> ERPNext -> Enable.
  2. Under Company Name, select the ERPNext company to connect with.
  3. Click Update.

ERPNext Settings ERPNext Settings

ERPNext on a different site

When ERPNext runs on another site:

  1. Navigate to Settings -> ERPNext -> Enable.
  2. Enter the Site URL of your ERPNext site, and the API Key and API Secret of a user on that site.
  3. Click Verify Connection, then select the ERPNext company to connect with.

Frappe CRM then adds the fields it needs to your ERPNext site. If that fails, enable Frappe CRM Data Synchronization in CRM Settings on your ERPNext site.

Product sync and the Logs tab work only when both apps are on the same site.

Settings

The General Settings tab has:

  • Company Name: the ERPNext company that customers and quotations are created in.
  • Bidirectional Product Sync: ERPNext Items always sync into CRM Products. Turn this on to also send CRM Product changes back to ERPNext Items.
  • Manual Sync: click Sync Now to sync Items and Products right away.
  • Auto Create Customer: creates a Customer in ERPNext when a deal moves to a status you choose in Deal Status, for example "Won".

The Logs tab lists your CRM Products and ERPNext Items, and any syncs that failed.

ERPNext sync logs Logs

What gets synced

Once the integration is enabled, data flows between Frappe CRM and ERPNext as described below. Most syncing runs only when both apps are on the same site; differences for separate-site setups are called out where they apply.

Customers

  • The Customer is named after the Deal's organization (Customer Type Company) or after the primary contact / lead name when there is no organization (Customer Type Individual).
  • The Deal's contacts and organization address are carried over to the new Customer.
  • Territory, currency, industry and website are copied from the Deal. Territory and industry are dropped automatically if they don't exist in ERPNext.

A Customer is created in two ways:

  1. When a Deal is marked as "Won" (or the status set in Auto Create Customer). The Deal's contacts and organization address are linked to the new Customer.
    Screenshot 2024-09-18 at 8.45.09 PM
    Screenshot 2024-09-18 at 9.07.32 PM
  2. When a Sales Order is created in ERPNext from a Deal's Quotation.

Once the customer is created, you'll find a "View Customer" button on the deal header, allowing you to easily access the customer from deal page.

Screenshot 2024-09-18 at 8.43.34 PM

Quotations

The Create Quotation button on a Deal opens a new Quotation in ERPNext with the Deal's data pre-filled:

  • The quotation is raised against the Customer if one already exists, otherwise against the CRM Deal itself. (ERPNext's Quotation To field is extended to allow Customer, Lead, Prospect and CRM Deal.) When ERPNext is on a different site, it is raised against a Prospect created from the Deal.
  • The Deal's primary contact and organization address are attached.
  • Quotation line items are pre-filled from the Deal's products, i.e. item code, quantity, rate and discount for every Deal product that is linked to an ERPNext Item.

The typical Deal to Sales Order flow looks like:

Create Quotation

Quotation line items are pre-filled from the deal's products

New Quotation

Quotations tab

Every quotation linked to a Deal shows in the Deal's Quotations tab, with its status, amount and date. Click a quotation to open it in ERPNext.

The tab is built into the CRM, so it doesn't depend on the form script below. It shows to users who can read Quotations in ERPNext.

Quotations tab on a deal Quotations tab

CRM Product and ERPNext Item

ERPNext Items and CRM Products are kept in sync with ERPNext as the source of truth. This sync runs on the same site only.

  • Creating an Item in ERPNext automatically creates a matching CRM Product and links the two records.
  • Updating an Item auto updates its CRM Product. The synced fields are: item name, rate, image, disabled status and description.
  • Renaming an Item renames its CRM Product, keeping both sides aligned.
  • Deleting an Item deletes its linked CRM Product.
  • User permissions and shares on an Item are copied to its CRM Product, so people see the same products in the CRM as in ERPNext.

With Bidirectional Product Sync turned on, changes also go the other way: creating, updating, renaming or deleting a CRM Product does the same to its ERPNext Item.

Pricing

Product rates shown in the CRM follow ERPNext's pricing rather than a static value:

  • A CRM Product's rate is taken from its ERPNext Item Price in the selling price list, falling back to the Item's standard rate when no Item Price exists.
  • On a Deal, each product line is priced the way ERPNext prices a quotation line: the price list is derived from the Deal's customer (or the default selling price list when there is none), and the rate is looked up for the item's UOM. If no Item Price is found, the CRM Product's standard rate is used as a fallback.

This means a customer specific price list configured in ERPNext surfaces its negotiated rates directly on the Deal.

Customizations

The Create Quotation and View Customer buttons on the Deal page are rendered by a standard CRM Form Script named Create Quotation from CRM Deal. It is created automatically when you enable the integration and is bound to the CRM Deal form view.

How the script works

On load, the script checks whether the integration is enabled and if so, it adds the actions to the Deal header:

  • Create Quotation calls the backend to build the pre-filled quotation URL and opens it in a new tab. It is shown only to users who can create Quotations in ERPNext.
  • View Customer is shown only when the Deal already has a linked ERPNext Customer. It opens the Customer record in a new tab.

Form Script

Editing the script

Because it is a standard script, Create Quotation from CRM Deal is read-only and cannot be edited in place. This protects it from being overwritten.

To customize the behavior:

  1. Go to Desk → CRM Form Script.
  2. Disable the Create Quotation from CRM Deal script.
  3. Duplicate it (or create a new script on the CRM Deal form view) and make your changes there. For example: change the conditions under which the buttons appear, add new actions or adjust labels.
  4. Enable your copy.

Your custom script then renders the buttons in place of the standard one.

Example Script:

class CRMDeal {
        onLoad() {
                if (this.doc.__newDocument) return
                call(
                        "frappe.client.get_single_value",
                        {
                                doctype: "ERPNext CRM Settings",
                                field: "enabled"
                        }
                ).then((enabled) => {
                        if (enabled) this.doc.trigger('setActions')
                })
        }
        setActions() {
                // Only offer quotation creation for qualified-or-later deals
                const allowed = ["Qualification", "Proposal/Quotation", "Negotiation"]
                if (allowed.includes(this.doc.status)) {
                        this.actions.push({
                                label: __("Create Quotation"),
                                onClick: () => {
                                        call(
                                                "crm.fcrm.doctype.erpnext_crm_settings.erpnext_crm_settings.get_quotation_url",
                                                {
                                                        crm_deal: this.doc.name,
                                                        organization: this.doc.organization
                                                }
                                        ).then((quotation_url) => {
                                                if (quotation_url) {
                                                        window.open(quotation_url, '_blank')
                                                } else {
                                                        toast.error("Error while creating quotation")
                                                }
                                        }).catch((e) => {
                                                toast.error(e.messages[0] || "Error while creating")
                                        });
                                }
                        })
                }
                // A custom action unrelated to the integration
                this.actions.push({
                        label: __("Copy Deal Link"),
                        onClick: () => {
                                navigator.clipboard.writeText(window.location.href);
                                toast.success(__("Deal link copied"));
                        }
                })
        }
}
Last updated 6 days ago
Was this helpful?
Thanks!