clients : Manage clients and client contacts

The lino_xl.lib.clients plugin adds the notions of clients and client contacts.

This is a tested document. The following instructions are used for initialization:

>>> import lino
>>> lino.startup('lino_book.projects.avanti1.settings')
>>> from lino.api.doctest import *
>>> from django.db.models import Q

Database structure

class lino_xl.lib.clients.ClientContactBase

Also used by aids.RefundPartner.

class lino_xl.lib.clients.ClientBase

Base class for a client. The model specified as client_model must implement this.


Pointer to ClientStates

class lino_xl.lib.clients.ClientStates

The list of client states.

======= ========== ============ =============
 value   name       text         Button text
------- ---------- ------------ -------------
 05      incoming   Incoming
 07      informed   Informed
 10      newcomer   Newcomer
 15      equal      Equal
 20      coached    Registered
 25      inactive   Inactive
 30      former     Ended
 40      refused    Abandoned
======= ========== ============ =============
class lino_xl.lib.clients.ClientEvents

The list of observable client events.

========== ========== ==========
 value      name       text
---------- ---------- ----------
 created    created    Created
 modified   modified   Modified
 note       note       Note
========== ========== ==========

Select clients whose record has been created during the observed period.


The choice for ClientEvents which selects clients whose main record has been modified during the observed period.

class lino_xl.lib.clients.ClientContacts
class lino_xl.lib.clients.ClientContact

A client contact is when a given partner has a given role for a given client.


The Client.


The type of contact. Pointer to ClientContactType.


The organization.


The contact person in the organization.


The role of the contact person in the organization.

class lino_xl.lib.clients.ClientContactTypes
class lino_xl.lib.clients.ClientContactType

A client contact type is the type or "role" which must be specified for a given ClientContact.


Whether persons of this type can be used as doctor of a refund confirmation. Injected by lino_welfare.modlib.aids.

class lino_xl.lib.clients.PartnersByClientContactType

Known contact types

class lino_xl.lib.clients.KnownContactType
class lino_xl.lib.clients.KnownContactTypes

The clients plugin also adds a choicelist of known contact types.

======= ================== ================================== ==================================
 value   name               text                               Client Contact type
------- ------------------ ---------------------------------- ----------------------------------
 10      health_insurance   Health insurance                   Health insurance
 20      school             School                             School
 30      pharmacy           Pharmacy                           Pharmacy
 40      social_center      Public Center for Social Welfare   Public Center for Social Welfare
 60      work_consultant    Work consultant                    Work consultant
======= ================== ================================== ==================================

A known contact type is a named pointer to a corresponding client contact type object in the database. The database object itself may exist or not. This enables us to programmatically work with a given client contact type. Since contact types are database objects, it can be anything or nothing for a given site. By using known contact type we can access them.

For example here are the partners having the client contact type "school":

>>> obj =
>>>, obj)
================== ===== ================================
 Name               ID    See as
------------------ ----- --------------------------------
 Best School        184   **Partner**, Person, Household
 Favourite School   183   **Partner**, Person, Household
================== ===== ================================

Here are the actual client contacts of that type:

>>> rt.login('robin').show(clients.ClientContactsByType, obj)
================== ================ ================================= =========
 Organization       Contact person   Client                            Remarks
------------------ ---------------- --------------------------------- ---------
 Favourite School                    ABDALLA Aádil (120/rolf)
 Best School                         ABED Abdul Báári (159/nathalie)
 Favourite School                    ARSHUN Aloyoshenká (135/romain)
 Best School                         BERENDT Antoshá (165/robin)
 Favourite School                    FALL Dembe (145/nelly)
================== ================ ================================= =========


See lino_xl.lib.clients.Plugin


The lino_xl.lib.clients plugin injects the following fields into models of other plugins.

class contacts.Partner

Setting this field on a partner makes this partner available as a client contact.