Automation reference
Scheduled actions, server actions, email templates, reports, public routes and the methods the schedule calls, with their XML ids, for developers and administrators.
This page is a reference for developers and administrators. For the meaning of each option, see Configuration.
Scheduled actions#
All are ir.cron records in noupdate data, active when installed, with numbercall -1, and run as code on the model.
| XML id | Name | Model and code | Interval |
|---|---|---|---|
smarterp_planning.ir_cron_generate_recurring_shifts | Planning: generate recurring shifts | smarterp.planning.recurrency _cron_schedule_next() | 1 day |
smarterp_planning.ir_cron_shift_reminders | Planning: send shift reminders | smarterp.planning.shift _cron_send_reminders() | 15 minutes |
smarterp_planning.ir_cron_rebuild_capacity | Planning: rebuild utilisation figures | smarterp.planning.capacity _cron_rebuild() | 1 day |
smarterp_planning_attendance.ir_cron_planning_attendance | Planning: compare shifts with attendances | smarterp.planning.shift _cron_planning_attendance() | 15 minutes |
smarterp_planning_timesheet.ir_cron_draft_timesheets | Planning: propose draft timesheets from finished shifts | smarterp.planning.shift _cron_create_draft_timesheets() | 1 hour |
What each one selects:
- Recurring shifts. Series with type
forever, oruntilwith a date in the future, whoselast_generated_end_datetimeis empty or before the horizon (now plus Recurring Shift Horizon months). Series of typex_timesare never selected. - Reminders. For each company with reminders on: shifts that are
published, of typeplanning, with a resource, starting after now and within Remind Before (hours), and whosereminder_sent_startdiffers fromstart_datetime. After sending,reminder_sent_startis set to the start. - Utilisation. All resources, from 62 days back to 184 days ahead; rows older than the window are removed.
- Attendance. Published shifts of type
planningwith a resource that started and ended less than two days ago: refresh the attendance fields, then send missed-start alerts. - Draft timesheets. Up to 500 shifts that ended in the last 31 days, of type
planning, with a resource, on a project that allows timesheets, not yet markedtimesheet_draft_generated.
Autovacuum jobs: smarterp.planning.recurrency._gc_empty_recurrences (removes series with no shifts) and smarterp.planning.broadcast._gc_old_broadcasts (older than 30 days).
Utilisation is also refreshed at commit through a pre-commit hook: create, write and unlink of shifts, and of calendar leaves, call smarterp.planning.capacity._mark_dirty, which queues the affected resource and dates; _flush_dirty merges them and refreshes once per transaction, with one day of margin.
Server actions#
| XML id | Name | Notes |
|---|---|---|
smarterp_planning.action_server_shift_publish | Publish | Bound to the shift list and kanban views; group Planning / Administrator; runs records.action_publish(). |
smarterp_planning_timesheet.action_server_unconfirmed_timesheets | Timesheets to Confirm | Opens the draft timesheets older than the company's number of days, grouped by employee. |
Email templates#
| XML id | Name | Model | Subject | Sent by |
|---|---|---|---|---|
smarterp_planning.email_template_shift_assigned | Planning: shift published | shift | Your shift on date has been published | _send_shift_notification, from _planning_publish |
smarterp_planning.email_template_planning_schedule | Planning: schedule sent | sent schedule | Your planning for period | smarterp.planning.planning._send_to_employees, from Publish and Send |
smarterp_planning.email_template_shift_reminder | Planning: shift reminder | shift | Reminder: your shift day, time | _planning_send_reminder |
smarterp_planning.email_template_open_shift_broadcast | Planning: open shift available | shift | Open shift available: day, time | _planning_broadcast_open_shift |
The schedule and broadcast templates read the context key planning_employee_id to build the employee's link. All four use the layout mail.mail_notification_light, delete the mail after sending (auto_delete), and are noupdate.
Report#
smarterp_planning.action_report_planning_rota (QWeb PDF, model smarterp.planning.print, template report_planning_rota, paper format paperformat_planning_rota: A4 landscape, 90 dpi). The file name is Rota followed by the start date.
Public routes#
All routes use auth="public", are excluded from the sitemap, and answer 404 when a lookup fails.
| Route | Method | CSRF | What it does |
|---|---|---|---|
/planning/<planning_token>/<employee_token> | GET | The employee's week. Optional week=YYYY-MM-DD (any date; the page shows its Monday), message, error. | |
/planning/<planning_token>/<employee_token>/assign/<int:shift_id> | POST | Yes | Take an open shift (_planning_take). |
.../unassign/<int:shift_id> | POST | Yes | Hand a shift back (_planning_release). |
.../switch/<int:shift_id> | POST | Yes | Ask to switch (sets request_to_switch). |
.../cancel_switch/<int:shift_id> | POST | Yes | Cancel a switch request. |
.../take/<int:shift_id> | POST | Yes | Take over a colleague's shift (_planning_take(taking_switch=True)). |
/planning/shift/<shift_token>/<employee_token> | GET | The open shift page. | |
/planning/shift/<shift_token>/<employee_token>/take | POST | Yes | Take that shift. |
Known issue in 17.0.3
The routes have no website=True. When the Website module is installed, rendering portal.frontend_layout raises KeyError: 'website' and the pages answer HTTP 500. See Troubleshooting.
After each action the browser is redirected to the week page with message or error in the query string. Pages set the language from the employee's user, or the contact, when installed. Templates: portal_planning_schedule, portal_planning_expired, portal_planning_broadcast_shift, with styles in portal_planning_styles.
Methods called by the front end#
These public methods are called with orm.call from the schedule and dashboard (see Data model):
planning_user_can_plan, get_planning_header_actions, get_planning_schedule_data, get_planning_card, get_planning_quick_create_defaults, get_planning_to_plan_items, planning_drop_item, planning_check_drop, planning_eligibility_map, planning_snapshot, planning_restore, action_planning_copy_to, action_planning_bulk_move, action_planning_bulk_assign, action_planning_bulk_unassign, action_planning_bulk_publish, action_publish, and get_planning_dashboard. Card buttons call the method named in the card's actions list.
Menus and window actions#
| Menu (XML id suffix) | Action | Groups |
|---|---|---|
menu_planning_root Planning | Internal User | |
menu_planning_dashboard | action_planning_dashboard (client action smarterp_planning.dashboard) | Administrator |
menu_planning_schedule Schedule | ..._by_resource, ..._by_role, ..._by_department, ..._by_department_role (smarterp_planning_project: ..._by_project; smarterp_planning_sale: ..._by_sale_order) | Planning / User |
menu_planning_my My Planning | action_planning_shift_my | everyone |
menu_planning_open Open Shifts | action_planning_shift_open | Planning / User |
menu_planning_reporting Reporting | Administrator, Employees officer | |
menu_planning_analysis; menu_planning_capacity; menu_planning_labour_cost | action_planning_shift_analysis; action_planning_capacity; action_planning_labour_cost | Administrator; (parent); Administrator |
menu_planning_attendance_report | smarterp_planning_attendance.action_planning_attendance_report | Administrator, attendance Officer |
menu_planning_unconfirmed_timesheets | server action above | Administrator, timesheet approver |
menu_planning_configuration | Administrator | |
menu_planning_settings; menu_planning_roles; menu_planning_templates; menu_planning_employees; menu_planning_materials | action_planning_config_settings; action_planning_role; action_planning_template; hr.open_view_employee_list_my; action_planning_materials | Settings admin; Administrator; Administrator; Employees officer; Administrator |
smarterp_planning_project.menu_project_planning (under Project) | action_planning_my_projects | project.group_project_user |
The wizards are window actions with target new: action_planning_send, action_planning_copy_previous_week, action_planning_auto_plan, action_planning_template_apply, action_planning_print, action_planning_split, action_planning_duplicate, and smarterp_planning_sale.action_planning_plan_orders.
First-use tour#
smarterp_planning_tour (web_tour.tours, sequence 90) walks a planner through creating a role and opening the schedule.