Apps that work together
Work with another app when it is installed, extend ERP's postings, and let Eden read your records and propose your RPCs.
An app can add behaviour for another app without requiring it. CRM works alone, and adds ERP features on sites that have ERP.
Check what is installed
def installed?(ctx), do: Cardinal.App.installed?(ctx, :erp)Cardinal.App.installed(ctx) returns every installed app module, in hook order.
Hooks and fields for an absent app
A rec_events entry with when_installed runs only on sites that have that app:
rec_events: [{"Sales Order", Crm.Controllers.ErpEvents, when_installed: :erp}]A fixture record with when_installed: erp is written only on those sites, also when ERP is installed later:
- {parent_rectype: Customer, fieldname: crm_deal, fieldtype: Data, label: Frappe CRM Deal, read_only: true, insert_after: prospect_name, when_installed: erp}The named app is not a requirement. app install does not pull it in. Uninstalling it removes those fields, and installing it again writes them back.
Extension modules found by name
A host app can look for a module with a fixed name in every installed app. The guest app defines it without depending on the host, so it compiles alone.
ERP looks for <App>.ErpExtension and calls the callbacks each one exports, in app order. CRM names the customer on a Quotation made from a deal:
defmodule Crm.ErpExtension do
def quotation_party(ctx, "CRM Deal", deal),
do: Crm.Controllers.CRMDeal.quotation_party(ctx, deal)
def quotation_party(_ctx, _party_type, _party), do: nil
endOther callbacks change GL lines before posting and let an app such as HRMS pay its own vouchers through Payment Entry. ERP's Erp.Extension module lists the callbacks.
Make records readable by Eden
Eden's assistant reads the AI catalog: the RecTypes and fields the user may read, and the Code Reports they may run.
| YAML | Effect |
|---|---|
description: on a RecType or field | Tells the model what the records are |
ai: false on a RecType | Leaves it out of the catalog |
ai: false on a field | Leaves the field out |
Password fields and layout breaks are always left out. An installed app's RecTypes and reports show up on the next call, with no restart.
Let Eden propose your RPCs
Define <App>.EdenActions with actions/0. Eve may then offer a card that calls the RPC as the user when they click Confirm.
defmodule Crm.EdenActions do
def actions do
[
%{
rpc: "crm.crm_lead.convert_to_deal",
title: "Convert to deal",
description: "Turn a lead into a deal. Returns the new deal's ID.",
rectypes: ["CRM Lead"],
record: "lead",
result_rectype: "CRM Deal",
input_schema: %{
"type" => "object",
"properties" => %{"lead" => %{"type" => "string"}}
}
}
]
end
end| Key | Meaning |
|---|---|
rpc | One of this app's @rpc paths. Another app's is ignored |
title, description | What the model and the card show |
input_schema | The RPC's arguments as a JSON schema object |
rectypes | The RecTypes it acts on |
record | The argument that names the record |
rectype_arg | The argument that names its RecType, when there are several |
result_rectype | The RecType the result names, for the card's link |
The RPC's requires: and argument checks still apply. Eden is optional: without it nothing reads this module.