Weekday-Only Task Due Dates (Security Group)

Weekday-Only Task Due Dates (Security Group)


Technical brief

Tasks (mail.activity) assigned to members of the new Weekday-Only Task Deadlines group can no longer be due on a Saturday or Sunday. The rule keys off the activity's assignee (user_id), not the creator. Users outside the group keep standard Odoo behavior.

Security group

  • XML ID: bista_menmd_customization.group_weekday_task_deadlines, added to the module's existing security XML.
  • Category: base.module_category_hidden, so it is managed from Settings > Users & Companies > Groups in developer mode, not from the user form checkboxes.
  • Shared helpers in models/mail_activity.py: _next_weekday(d) rolls a date forward to Monday; _weekday_rule_applies(user) returns user.has_group(WEEKDAY_GROUP).

Behavior by entry point

Entry point

Method

Group member

Non-member

Automated tasks (Rx stages, crons, automation rules, server actions)

mail.activity.create() when not manual

Weekend deadline moved to next Monday

Unchanged

Manual save on mail.activity

_check_date_deadline_weekday constraint on date_deadline, user_id

ValidationError

Saves

Schedule Activity popup

mail.activity.schedule onchange warning + constraint on date_deadline, activity_user_id

Instant warning, then ValidationError

Saves, no warning

Rx "Create Tasks" action

action_create_activities, context manual_activity_deadline=True

Blocked by the constraints above

Saves

Pre-filled date, popup

_compute_date_deadline override (depends on activity_type_id only)

Shifted to Monday

Unchanged

Pre-filled date, activity form

default_get, _onchange_activity_type_id override, _onchange_weekday_prefill on user_id

Shifted to Monday

Unchanged

Manual vs automated is decided by _is_manual_activity_entry(): true when the context carries manual_activity_deadline, or when the request is a web_save creating a new mail.activity from the form. Everything else is treated as automated.

Files changed

  • bista_menmd_customization/models/mail_activity.py: group helpers, scoped create, default_get, onchanges and constraint.
  • bista_menmd_customization/models/mail_activity_schedule.py: imports the helpers; scoped _compute_date_deadline, onchange warning and constraint.
  • bista_menmd_customization/security/<existing security XML>: new res.groups record.
  • bista_menmd_website/views/shop_payment.xml: suggested_products_list_inherit commented out.

Known behavior and limits

  • Reassigning an existing weekend task to a group member raises the weekday error until the date changes.
  • In the popup, the pre-fill is computed when the activity type is chosen, using the assignee at that moment. Changing the assignee afterward does not recompute the date, by design, so user-picked dates are never overwritten.
  • Existing open weekend tasks are untouched unless edited.
  • Only Saturday and Sunday are skipped; company holidays are not.

Easy to Follow Summary for the team

Tasks assigned to anyone in the new Weekday-Only Task Deadlines group can no longer be due on a Saturday or Sunday. Everyone else works exactly as before.

What changed for group members

  • Automatic tasks (from Rx status changes, follow-up cycles, account status alerts, check-ins, and every other automated source) that would have been due on a weekend are now due the following Monday.
  • Tasks created by hand can't be saved with a weekend due date. As soon as you pick a Saturday or Sunday in the Schedule Activity popup or the Rx "Create Tasks" action, a warning appears, and the task won't save until you choose a weekday.
  • Pre-filled due dates never land on a weekend. If an activity type's default delay would fall on a Saturday or Sunday, the popup suggests the following Monday instead.

Good to know

  • The rule follows the person the task is assigned to, not the person creating it. Anyone scheduling a task for a group member gets the weekday rule; a group member scheduling a task for someone outside the group does not.
  • Nobody is affected until users are added to the group.
  • To reassign a weekend task to a group member, change its date to a weekday first.
  • This applies going forward only. Open tasks already due on a weekend stay as they are unless someone edits them.
  • Company holidays are not skipped, only Saturdays and Sundays.
  • In the Schedule Activity popup, selecting a Status no longer throws away the due date you picked.


Setup and testing

Testing needs two users: User A in the group and User B not in it. You can be User A.

Setup

  1. Turn on developer mode (Settings > Activate the developer mode).
  2. Go to Settings > Users & Companies > Groups and search for Weekday-Only Task Deadlines.
  3. Open it, add User A on the Users tab, and save. Leave User B out.
  4. Work out the Saturday number: the number of days from today until the coming Saturday. Monday = 5, Tuesday = 4, Wednesday = 3, Thursday = 2, Friday = 1.

Test 1: Automatic tasks move to Monday, for group members only

  1. Open Rx Stages and pick a stage with Task to Generate checked.
  2. Note its Due Days, then change it to the Saturday number.
  3. Move a test Rx whose owner for that stage (MSC Owner or Account Owner) is User A into the stage. The task should be due the following Monday.
  4. Repeat with an Rx owned by User B. The task should be due on Saturday.
  5. Set Due Days back to its original value.

Test 2: Scheduling from an Rx

  1. On any Rx, click Activities and assign to User A.
  2. Pick a Saturday. A warning should appear right away.
  3. Click Schedule anyway. You should get an error saying due dates must fall on a weekday, and the Schedule button should still be there after closing it.
  4. Change the assignee to User B and click Schedule. It should save with the Saturday date.
  5. Open Activities again, assign to User B, pick a Saturday, then switch to User A. The warning should appear as soon as you switch.

Test 3: Rx "Create Tasks" action

  1. On an Rx, open the Actions (gear) menu and choose Create Tasks.
  2. Assign to User A and pick a Saturday or Sunday. You should see the warning and be unable to save.
  3. Change the assignee to User B. It should save with the weekend date.

Test 4: Pre-filled dates

  1. Go to Settings > Technical > Discuss > Activity Types, open To-Do, note its default delay, and change it to the Saturday number.
  2. On an Rx, click Activities, make sure User A is the assignee, then choose To-Do. The date should pre-fill with the following Monday.
  3. Close it, click Activities again, set the assignee to User B first, then choose To-Do. The date should pre-fill with Saturday.
  4. Set the To-Do delay back to its original value.

Pick the assignee before the activity type: the pre-filled date is set when the type is chosen, and changing the assignee afterward won't change a date that's already filled in.

Test 5: Reassigning a weekend task

  1. Create a task for User B due on a Saturday (as in Test 2, step 4).
  2. Open it and change the assignee to User A.
  3. You should get the weekday error. Change the date to a weekday and it should save.