Reference for customers, customer_parts, and customer_part_revisions in crm, with the customer facet of a party, part number mapping, and revision lifecycle.
This page describes three sub-modules of src/cluster_erp/modules/crm/. customers/ holds the customer facet (Customer), the customer role record of a party. customer_parts/ maps a customer's part number to one of the company's products, and customer_part_revisions/ keeps the revisions of that part. The role model of parties is described on party unification.
Defined in: models.py, services.py, routes.py, and metadata.py of the three sub-modules, and the party handlers in src/cluster_erp/modules/crm/module.py:115-138 and src/cluster_erp/modules/crm/module.py:271-297.
Count: 3 tables; 6 customer routes, 6 customer part routes, and 7 revision routes (@router. decorators); 2 ActionMeta entries on revisions.
In prose: a draft becomes active only when the part has no other active revision. An active revision can be superseded. Only a draft can be edited or deleted (src/cluster_erp/modules/crm/customer_part_revisions/services.py:84-109).
On create, a customer with a party takes legal_name and tax_no from GetPartyById. A party plays the customer role once: a second create for the same party updates the existing facet (src/cluster_erp/modules/crm/customers/services.py:75-107).
Create emits CustomerCreated and PartyRoleSet with active=True; delete sets deleted_at and emits PartyRoleSet with active=False (src/cluster_erp/modules/crm/customers/services.py:118-145, src/cluster_erp/modules/crm/customers/services.py:196-215).
PartyUpdated copies a changed display name and tax id to the live facets; PartyDeleted sets is_active to false on them (src/cluster_erp/modules/crm/module.py:115-138, src/cluster_erp/modules/crm/module.py:271-297).
A customer part number is unique per customer among live rows (src/cluster_erp/modules/crm/customer_parts/models.py:15-22, src/cluster_erp/modules/crm/customer_parts/services.py:139-155).
Personal values of a facet of an individual party are collected and anonymised by privacy_handlers.py (src/cluster_erp/modules/crm/privacy_handlers.py:1-12).