ems.meeting.presence (meeting attendance by NFC tag)A presence session records who was convened to one meeting (a staff meeting, a department meeting, a training) and who confirmed their attendance. A laptop with a USB NFC reader at the door runs the kiosk, a public page, and each person passes the same tag they already use to clock in. This is not time tracking: nothing is ever written to hr.attendance.
The native attendance kiosk cannot be reused for this. Every scan there toggles check-in/check-out, so someone who clocked in on arrival would be clocked out by passing the tag at the door. What is reused is the tag’s identity (hr.employee.barcode, the tag’s UID) and the shape of the public kiosk (a token in the URL, a JSON scan route, sudo() on the server).
Module files: models/meetings/presence.py, models/meetings/presence_line.py, controllers/meeting_presence.py, static/src/js/frontend/meeting_presence_kiosk.js (+ static/src/xml/frontend/, static/src/scss/frontend/), reports/meetings/report_meeting_presence.xml, views/minutes_agreements/.
erDiagram
"ems.meeting.presence" ||--o{ "ems.meeting.presence.line" : "line_ids"
"ems.meeting.presence" }o--o| "ems.space" : "space_id"
"ems.meeting.presence" }o--o| "ems.course" : "course_id"
"ems.meeting.presence" }o--o| "hr.department" : "department_id (scope)"
"ems.meeting.presence" }o--o| "ems.workgroup" : "workgroup_id (scope)"
"ems.meeting.presence" }o--o| "ems.group" : "group_id (scope)"
"ems.meeting.presence.line" }o--|| "hr.employee.public" : "employee_id"
"ems.meeting.presence" }o--o| "hr.employee.public" : "convener_id"
"ems.meeting.presence" }o--o{ "hr.employee.public" : "manager_ids"
ems.meeting.presence (_inherit = ['ems.base']: chatter, active)| Field | Type | Description |
|---|---|---|
name |
Char |
What the meeting is, e.g. “Claustre”. Required |
date |
Datetime |
Start of the meeting. Defaults to now |
duration |
Float (hours) |
Source of truth of the length. Defaults to 2 (DEFAULT_DURATION); constraint: greater than 0 |
date_end |
Datetime (computed, stored, precompute, inverse) |
date + duration. Written by hand, its inverse turns it into the duration, so either can be set; moving date moves the whole window and keeps the length. The form’s onchange('date_end') runs the same inverse so the duration updates as the user types |
space_id |
Many2one → ems.space |
Optional room |
course_id |
Many2one → ems.course |
Defaults to the current course |
company_id |
Many2one → res.company |
Defaults to the current company; the scanned tag is only looked up among this company’s employees |
convener_id |
Many2one → hr.employee.public |
Who convenes the meeting. Defaults to the creator’s employee, editable (the secretariat may create a meeting on someone else’s behalf). Decides who can open the kiosk from the meetings page, see below |
manager_ids |
Many2many → hr.employee.public |
Other people who can also open the kiosk from the meetings page |
scope |
Selection |
Who is convened: all_teachers (default), all_staff, department, workgroup, group (a group’s teaching team), manual |
department_id / workgroup_id / group_id |
Many2one |
The target of the department / workgroup / group scope (required by a constraint for those scopes) |
state |
Selection |
draft → open → closed, tracked |
access_token |
Char |
Random, unique, copy=False; the kiosk’s only credential |
kiosk_lang |
Selection |
The language the kiosk page speaks. The visitor is anonymous (the public user is en_US), so the session decides: the language of whoever created it, editable |
kiosk_url |
Char (computed) |
<host>/ems/presence/<token>; the host is the one the request came in through, not web.base.url (a restored production database keeps production’s) |
line_ids |
One2many |
One line per person |
convened_count, present_count, pending_count, justified_count, absent_count |
Integer (computed) |
Counters shown in the form and on the kiosk |
ems.meeting.presence.line| Field | Type | Description |
|---|---|---|
presence_id |
Many2one |
ondelete='cascade' |
employee_id |
Many2one → hr.employee.public |
Same comodel the minutes’ attendee lists use, so the two can be linked without a translation step |
state |
Selection |
pending (default) / present / justified / absent |
checkin_time |
Datetime |
When the tag was passed (or when it was marked by hand) |
method |
Selection |
nfc or manual; empty unless the person is present |
is_convened |
Boolean |
False for someone who passed the tag without being convened |
notes |
Char |
e.g. why an absence is justified |
on_leave |
Boolean (readonly) |
The line was justified by EMS itself for an absence (see “Absences” below). Cleared whenever anybody else sets the state (a scan, a manager) |
UNIQUE (presence_id, employee_id): one line per person and session.
action_load_convened(), which runs on create() for every scope but manual and can be run again from the form. It only adds people who are missing: it never removes a line, so a scan is never lost when the scope is changed afterwards.
all_teachers: employee_type = 'teacher'; all_staff: every active employee; department: the department and its children; workgroup: its members; group: whoever teaches the group plus its tutor. All limited to the session’s company. The rule is _ems_convened_employees(), shared with the minutes (see below)._ems_register_scan(barcode), called by the controller with sudo()):
_ems_kiosk_status()): not_open / closed. Nothing changes.barcode in the session’s company. No match: unknown.present: already. Otherwise the line becomes present (checkin_time = now, method = 'nfc'): ok. A person with no line gets one with is_convened = False: not_convened.
open and now is between date and date_end, both included: before the start it answers not_open (the same “not started yet” a draft gives), after the end closed, whatever its own state. The session’s state is not touched: it stays open until a manager closes it, which is also what turns the pending lines into absent. The window applies to the kiosk only; a manager can mark people by hand at any time while the session is not closed._ems_sync_leaves() justifies every pending line whose person has an absence overlapping the meeting, with the note _ems_leave_note() (“Has an absence”, in the centre’s language, res.company._ems_centre_env(), since it ends up in the minute) and on_leave = True. The absences are the guard duty board’s, resolved on demand by _ems_on_leave(employees, start, end): ems.course._get_guard_duty_absence_intervals() (approved and requested hr.leaves plus the unresolved ems.absence_pendings; never the missing check-ins) and _guard_duty_absence_state() for the overlap, on the local day the meeting starts. Only the fact is written, never the absence type or its reason. It runs on create() and action_load_convened(), when date/duration/date_end change, and in action_open() and action_close() (before the pending lines become absent), so an absence filed in between still counts. A line with on_leave whose absence is gone (cancelled, refused, moved) goes back to pending. A line somebody else decided is never touched: any state written without the ems_leave_sync context clears on_leave. The sync’s own writes skip the minute update (_ems_sync_minutes); the minute gets the notes on closing. Cost: two searches (hr.leave, ems.absence_pending) per session and sync, whatever the number of people.pending line into absent and locks the lines: nothing can be created, edited or deleted in a closed session until it is reopened. A justified line stays justified.state by a manager follow the same bookkeeping as a scan: present stamps checkin_time and method = 'manual'; any other state clears both. A present line cannot be deleted (mark it pending or absent first), and only a draft session can be deleted (archive the rest).hr_attendance. The kiosk page shows, besides the person who just scanned, who is still to come and who is in, by name only (_ems_kiosk_progress()): never a photo other than the scanner’s own card, an address or anything else of a person. That is what anyone holding the link can read, so the link is to be treated as the list of names it shows: it is not published, and a session is only as private as its link.sequenceDiagram
participant R as NFC reader (USB keyboard)
participant P as Kiosk page (OWL public component)
participant C as /ems/presence/<token>/scan
participant M as ems.meeting.presence
R->>P: keydown burst: the tag UID, then Enter
P->>C: JSON-RPC {barcode}
C->>M: sudo()._ems_register_scan(barcode)
M-->>C: {status, employee_name, employee_avatar, counters, convened, attendees}
C-->>P: same payload
P->>P: card with name/photo for ~3 s, coloured by status
GET /ems/presence/<token> renders web.frontend_layout with an <owl-component name="ems.meeting_presence_kiosk"> (Odoo’s public_components registry, bundled in web.assets_frontend). An unknown token is a 404; a known one renders the page whatever the state, and the page says whether the session is open.POST /ems/presence/<token>/status returns {'status', 'present_count', 'pending_count', 'convened', 'attendees'}. convened are the people still pending, alphabetical ignoring accents and case, on the left of the page; attendees the present ones, the latest arrival first with its local time and a flag for someone who was not convened, on the right. Someone justified is in neither. Every scan’s answer carries the same two lists, so the page never waits for a poll to show who just came in. The page polls it every 5 seconds, so the kiosk switches on when the window starts and off when it ends (or when a manager closes or reopens the session) without reloading the laptop at the door. The page header shows the window (windowLabel, _ems_window_label(): local time, of the browser or else of the company, since the visitor is anonymous).POST /ems/presence/<token>/scan (type='json', auth='public') returns {'status': ..., 'employee_name', 'employee_avatar', 'present_count', 'pending_count'}; status is one of ok, already, unknown, not_convened, not_open, closed.useTagReader(), static/src/js/frontend/tag_reader.js, shared with the meetings page) collects the keys exactly as Odoo’s own barcode service does (barcodes/static/src/barcode_service.js, the one hr_attendance’s kiosk uses): only printable keys count, Enter or Tab ends a code, and so does the reader going quiet for 150 ms; a code of at least 3 keys is a tag. Somebody typing is too slow for that (each key empties the buffer before the next arrives), so typing a code by hand registers nothing. The service itself is not used, because it needs the web client’s environment and this page is a public component; the rules are copied, and the tours play both a reader (a burst of keydown events, with and without the closing Enter) and a person typing._ems_show_code_box(): ems.environment_type != 'production', an undeclared one counting as not production), as a testing aid where there is no reader. It has its own submit and the page listener ignores keys typed into it. deploy.sh always declares production, so the real kiosk never has it.kiosk_short_name(), applied by _ems_kiosk_names()), to keep the rows short; the card in the middle and the PDF keep the whole name. An employee’s name is a single string with nothing saying which words are given names and which are surnames, so the rule only drops the last word (with the particles that go with it: “Fernando del Olmo Fernández” becomes “Fernando del Olmo”, “Josep Maria Vila i Serra” becomes “Josep Maria Vila”) when that is safe, and in any doubt the whole name stays: a longer name is never a wrong one. It stays whole for a name of one or two words, when only a given name would be left (“Olga de la Morena”, “Maribel del Tío”) and for a three-word name whose second word is a common second given name (“Gerardo Jesús Nicolau”, “Josep Manel Cos”: _SECOND_GIVEN_NAMES, only names that are not also surnames). The one case it cannot tell is a three-word name whose second word is an uncommon given name. If two people of the company’s staff would end up with the same short name, both keep their whole names; the comparison is against the whole staff, not against the meeting, so a name never changes on screen when somebody else comes in.fitLists() gives each list the biggest font (9 to 36 px) and the number of columns (1 to 6) with which every name shows without scrolling, measuring the widest row with the page’s own font (canvas measureText) against the room the list has, and does it again whenever the lists change, the window is resized or the fonts arrive. A handful of names get one big column, a staff meeting’s hundred get several small ones; only past the 9 px floor does a list scroll, as a last resort. The width goes to the lists: the card in the middle is narrow on purpose./status only while its tab is visible (document.hidden), and once more as soon as it becomes visible again: a kiosk left open in a background tab costs the server nothing.dbfilter, or ?db=<name> on the URL), like any other public route.A fixed public address, /ems/meetings, that the computers with a reader keep open as their home page, so nobody has to carry each meeting’s kiosk link over to them. It reads tags like the kiosk (useTagReader()), and each tag gets the list of meetings its owner can open today, each a link to its kiosk.
sequenceDiagram
participant R as Reader
participant P as /ems/meetings (OWL public component)
participant S as /ems/meetings/scan
participant K as /ems/presence/<token>?back=1
R->>P: tag UID + Enter
P->>S: {barcode}
S->>S: employee by barcode, _ems_meetings_run_by(employee)
S-->>P: {status, employee_name, meetings: [{name, url, window, room, status}]}
P->>K: click on a meeting (same tab)
K->>P: "Meetings" link in the kiosk header (backUrl)
_ems_run_by(employee) decides whether an employee can open a meeting: its convener_id, one of its manager_ids, the company’s Director (res.company.director_id, also for a meeting with no convener), or a chief above the convener in the chain of command. The chain is the tutor scope’s (hr.employee.tutor_scope_user_ids, issue #483): every ancestor through parent_id whose user holds ems.group_department_chief (Seminar Chief, Department Chief, Head of Studies, Deputy, Director). So a Department Chief opens what their department’s staff convene and a Deputy Head of Studies what their whole area convenes, but a chief of another branch does not. It resolves the real hierarchy instead of granting it by role centre-wide, as CLAUDE.md’s permission-escalation rule asks._ems_meetings_run_by(employee) lists the meetings of the employee’s company in state open (the kiosk is published only once attendance is started) whose date_end has not passed and whose date is before the end of the current local day (tz of the context or of the company, via ems.datetime_utils), earliest first, filtered by _ems_run_by(). A draft, a closed session or one that already ended is left out, since its kiosk takes no tags._ems_hub_scan(barcode) (called with sudo() from POST /ems/meetings/scan) returns {'status': 'ok' | 'none' | 'unknown', 'employee_name', 'meetings'}; each meeting carries its kiosk URL with ?back=1, its window (_ems_window_label()), room and kiosk status (open / not_open).GET /ems/meetings renders web.frontend_layout with the ems.meeting_presence_hub public component. Its words come from _ems_hub_labels() in the company partner’s language (the visitor is anonymous). The code box outside production (_ems_show_code_box()) is the same testing aid as the kiosk’s.?back=1 and then passes backUrl='/ems/meetings', shown as a “Meetings” link in the kiosk header. A kiosk opened straight from its own link has no such link.| Role | Sessions and lines |
|---|---|
Director, Head of Studies (ems.group_head_of_studies) |
Full |
Secretary (ems.group_secretary) |
Full |
Academic administrator (ems.group_academic_admin) |
Full |
Teacher (ems.group_teacher) |
Read and write (lines: also create) the sessions of the minutes they may write, until the minute is approved; no new sessions |
| The rest | None: they only pass their tag |
The convener and managers of a meeting get no backend rights from those fields: they only decide who can open the kiosk from the meetings page.
The roles above that convene sessions see them all (rule_meeting_presence_oversight, also needed because Head of Studies implies the teacher group). A teacher reaches a session only through its minute (ems.meeting.presence.minute_ids, the inverse of ems.minute.presence_id): rule_meeting_presence_minute_writer and its line twin match the minutes still not approved whose writer, approver (or their chain of command, approver_scope_user_ids) or approving post they are, in security/rules/quality.xml. That is how a tag left at home is corrected by hand: the minute’s Actions → Correct the attendance (action_correct_attendance) opens the session’s form, and the Attendance menu lists the same sessions for them. The quality administrator is deliberately left out for now: that role cannot read the courses, rooms, departments or workgroups a session points at (it implies neither ems.group_teacher nor ems.group_secretary), so opening a session would fail on them. It joins when the quality work’s minutes land (issue #497), which brings its own quality groups. The Meetings root menu and its Attendance entry are visible to the same groups.
A session can be created on its own (Head of Studies, secretariat) or by a minute: whoever sets a minute up chooses, in the form, whether attendance is written by hand or taken with the NFC tag (ems.minute.attendance_mode). With the tag, saving the minute creates its session (ems.minute.presence_id, _ems_sync_presence()):
convener_id, so the meetings page opens its kiosk with their own tag and the minute’s Open the kiosk button does the same from the form.draft), the session cannot be opened (waits_for_meeting, checked by action_open(), which also hides Start attendance on the session’s form); the minute offers Open the kiosk and Close attendance (_ems_check_meeting_held()) and Correct the attendance only from the meeting state, and refuses to go back to preparing once the session has been opened._ems_presence_scope(): department, workgroup, group, centre or by hand) and target are copied over, so Load convened people on the session finds the same people.ems.meeting.presence._ems_convened_employees(scope, company, department, workgroup, group) (@api.model) is used by both the session (_ems_scope_employees()) and the minute (_ems_preload_attendees()): a department convenes its members and those of the departments under it (child_of, so an area such as VET convenes all of its departments), a workgroup its members, a group whoever teaches it (ems.teaching) plus its tutor even without a subject in it, all_teachers/all_staff the company’s teachers or staff. Either list still takes anybody else by hand, and the minute also takes people from outside EMS (ems.minute.guest); a session does not, since they have no tag.ems.minute._ems_sync_attendance()): lines present become attendee_ids, every other line absentee_ids, and justified absences are written to absence_notes with their reason. It runs when the session is closed, from the minute’s Close attendance button or from the session’s own screen, when a line is changed by hand (ems.meeting.presence.line._ems_sync_minutes(), so a correction reaches the minute without closing the session again), and again when the minute is sent for approval. An approved minute is never touched.ems.minute)Only the meeting’s own items are stored (ems.minute.agenda_ids, the Items to discuss tab). The agenda is computed (agenda_html, from _ems_agenda_entries()): the sections the minute type marks with ems.minute.section.in_agenda, in the type’s order, where the section of kind previous_approval only counts when the minute has a previous one, agreement_followup only when agreements are still open, and the section of kind agenda unfolds into the items. The minute’s PDF prints the same thing.
action_send_call() (the form’s Send the call entry) emails it to every attendee with a work_email, in one message, together with the date, time, place, modality and a backend link to the previous minute; the body is the QWeb template ems.minute_call_email. It can be sent again until the minute is sent for approval (to_approve and approved refuse it): call_sent_datetime records the last time and makes the next one say it replaces the earlier call. It is an ordinary mail.mail, so the dev mail guard applies (see ../shared/dev_mail_guard.md) and tests mock the transport.
ems.minute.state)A meeting’s minute has one more state than the other signed records: draft (preparing: who is convened, the items, the call) → meeting (action_start_meeting) → to_approve → approved. Evidence records skip meeting. The form shows the preparation layout (the two top groups and a notebook) while draft, and from meeting on a column of blocks in the agenda’s order.
agenda_ids, body notes) and the type’s text sections (section_value_ids, body content, only the lines with is_written) use the ems_text_blocks one2many widget (static/src/js/backend/text_blocks_field.js): one block per line, its title and Odoo’s own html field underneath, fed with the line’s record.development is not written by hand when the type also has an agenda section: action_submit() builds it from each item’s notes (_ems_compose_development()), which is also what satisfies a type that requires it.ems.minute.agreement.review holds one line per agreement still open (created with the carry-over). Its note, is_closed and new_deadline_date are pushed, with sudo, to the agreement: one ems.quality.followup entry per minute, kept in step with the line (removed again if the line is emptied), and the agreement’s deadline_date.ems_record_cards one2many widget (static/src/js/backend/record_cards_field.js): a header line with the brief fields and the texts underneath at full width, each rendered by EmsOpenField, a Field that does not force a line’s fields read-only when the line is not the one “being edited”. ems_people_summary shows a many2many of people as names up to three and as a count with tooltip and link beyond.ems.quality.action.create): the card does not show the scope fields, so the web client never sends them, and the form’s default_* context would be lost.approver_employee_id is chosen while the minute is prepared, defaulted to the first of _ems_approver_candidates() (a department’s chief and seminar chief, a group’s tutor, the director; for a scope with nobody of its own, the few holders of the type’s approver_role_id). The form passes those as ems_first_ids in the field’s context and hr.employee.public.name_search puts them first, with everybody else after. On approval it becomes whoever actually approved. The record rules and the Awaiting my approval facet accept the person as well as the post.res.company.ems_lang, Catalan when installed), not in the user’s language: ems.report_minute is one of the centre’s documents (CENTRE_LANG_REPORTS in models/shared/ir_actions_report.py), which ir.actions.report._render_qweb_pdf/_render_qweb_html always render in it.