EMS

Technical Reference: Expected Withdrawal

Overview

When a tutor knows a student won’t come back, they ask for the withdrawal, which the secretariat takes a while to register. Meanwhile the student would keep appearing in every roll-call and piling up absences. An expected withdrawal (issue #644) bridges that gap:

Module files: models/contacts/withdrawal_expected.py (res.partner, ems.withdrawal_expected_wizard), models/attendance/attendance_session.py (line creation, not_expected_reason), views/community/contact/form.xml, views/community/contact/withdrawal_expected_wizard.xml, static/src/js/backend/schedule_grid_readonly_field.js.


Data Model

res.partner (inherited)

Field Type Description
withdrawal_expected Boolean, readonly, tracked The mark.
withdrawal_expected_date Datetime, readonly When it was marked: roll-calls of classes starting from then leave the student off.
withdrawal_expected_by_id Many2one res.users, readonly Who marked it.
withdrawal_expected_note Text, readonly Why, as written in the wizard.
can_mark_withdrawal_expected Boolean, computed (uid) Whether the current user may mark or revert it (see Access Control). Re-checked server-side.
not_expected_subject_ids / not_expected_legend computed For the Schedule tab: the subjects drawn dashed and the legend explaining why (every subject, for an expected withdrawal).

The ribbon reuses archived_reason_label/_color (the archived student’s Alumni/Withdrawal/Expelled ribbon): on an active student with the mark it reads “Expected withdrawal”, in amber, on the form and on the students’ kanban card (both views show it when not archived_reason_label or (active and not withdrawal_expected) is false, #757). The shared ribbon widget now shrinks long texts like the native one (o_medium/o_small).

ems.attendance_session_line (inherited)

not_expected_reason (Selection): why the system took the student off the roll-call (withdrawal, or convalidation with convalidation_line_id, see convalidation.md); empty when the teacher did, or when the student is on it. Only lines with a reason are restored when the reason is undone, by res.partner._ems_restore_not_expected_lines(domain), shared by both.


Flows

flowchart TD
    A["Tutor: Actions > Mark expected withdrawal\n(wizard: note)"] --> B["_ems_mark_withdrawal_expected()"]
    B --> C["withdrawal_expected = True, date = now"]
    B --> D["Lines of sessions already created from now on,\nstill attended or plain miss: archived, reason = withdrawal"]
    B --> E["Informative notice queued for the student's\nteachers and tutor (daily summary)"]
    F["Roll-call created\n_auto_populate_lines()"] --> G{"_ems_not_expected_reasons():\nmarked before the class starts?"}
    G -- yes --> H["Line created archived, reason = withdrawal"]
    G -- no --> I["Line as usual"]
    J["Actions > Revert expected withdrawal"] --> K["_ems_restore_not_expected_lines():\neach line active again, miss\n(justified ones keep their status)"]
    K --> L["Context ems_skip_family_notification:\nissue recorded for the tutor's summary,\nno family email"]
    J --> M["Notice queued: back on the roll-calls"]
    N["Withdrawal or other exit registered\n(_ems_leave_centre)"] --> O["_ems_clear_withdrawal_expected():\nmark cleared, lines stay archived"]

Schedule tab

readonly_schedule_grid reads not_expected_subject_ids/not_expected_legend (invisible fields on the student form, the same “smuggled helper field” pattern as shift): blocks of those subjects get o_schedule_grid_entry_not_expected (faded, dashed outline, light stripes) and the legend shows below the grid. Absent on every other model using the widget.


Access Control

Who Mark / revert
The student’s tutor and everyone above them (tutor scope: Department/Seminar Chief, JE/JEA, Director) Yes (ems.base.user_acts_as_tutor)
Secretary, JE/JEA and the Director (ems.group_head_of_studies), the academic administrator (_ems_user_can_register_exits) Yes
The administrator (base.group_system), always at the top of the permission pyramid Yes
Any other teacher, a Department Chief of another branch No (button hidden, UserError server-side)

The writes are done with sudo() once the check passes. ems.withdrawal_expected_wizard has ACL rows for ems.group_tutor (implied by every role above the tutor), ems.group_secretary, ems.group_academic_admin and base.group_system.