Skip to content

Writing a module

This walkthrough builds a real module, end to end: managing a library. A catalogue, the physical copies, the members, the loans and their lifecycle.

By the end it will have tables, an API, seven kinds of screen, permissions, translations, a state machine, and it will package up to be installed elsewhere.

You will write no frontend code at all.

What we are building

The loan list: copy, member, dates and state, with its semantic colours

Four entities that answer each other:

ModelWhat it is
library_titleThe work. Dune, its author, its ISBN, its genre.
library_copyThe physical object on the shelf, with its barcode and its shelf mark.
library_memberSomeone allowed to borrow.
library_loanOne copy, out with one member, for a period.

Telling the work from the copy is not modelling flourish: a library owns three copies of the same book and lends them independently. The barcode belongs to the object, the ISBN to the work.

The steps

1The moduleThe skeleton, the manifest, the entry point.
2The dataModels, fields, relations, computed values.
3The screensThe eight view kinds, and what each one does.
4Making it visibleThe step people skip, and why the module cannot be found.
5TranslatingWhy the translation file is not optional.
6The rightsWho sees what, down to the field.
7The statesA lifecycle, its transitions, and the buttons that follow.
8Artificial intelligenceCalling a model from your module, properly.
9Reading a documentA delivery note goes in, ISBNs come out.
10PDF documentsA loan receipt, printed from the screen.
11ReactingMail, notification, event, numbering.
12AutomatingThe same rule with no code, in the visual engine.
13FilesUpload, version, attach, discard.
14ShippingPackage it, sign it, install it elsewhere.

What you need

A working Kewos installation and write access to its modules/ directory. A local installation is enough to develop; the commands in this walkthrough run there as they are.