feat(fusion_clock): Publish & Notify range + portal Schedule fold-in [A6-A7]
Generalise post_week into fclk_publish_range/fclk_email_posted_range + planner Publish… panel + publish_range endpoint. Fold the /my/clock/schedule controller+template+css from fusion_planning into fusion_clock (native schedule only, role colour); inline Schedule nav across all portal pages. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -166,23 +166,7 @@ class FusionClockShiftPlanner(http.Controller):
|
||||
end = start + timedelta(days=6)
|
||||
employees = self._manager_employees()
|
||||
Schedule = request.env['fusion.clock.schedule'].sudo()
|
||||
|
||||
entries = Schedule.search([
|
||||
('employee_id', 'in', employees.ids),
|
||||
('schedule_date', '>=', start),
|
||||
('schedule_date', '<=', end),
|
||||
('state', '!=', 'posted'),
|
||||
])
|
||||
posted_count = len(entries)
|
||||
affected = entries.mapped('employee_id')
|
||||
if entries:
|
||||
entries.write({'state': 'posted', 'posted_date': fields.Datetime.now()})
|
||||
|
||||
notified = 0
|
||||
for employee in affected:
|
||||
if Schedule.fclk_email_posted_week(employee, start, end):
|
||||
notified += 1
|
||||
|
||||
posted_count, notified = Schedule.fclk_publish_range(employees, start, end)
|
||||
return {
|
||||
'success': True,
|
||||
'posted': posted_count,
|
||||
@@ -190,6 +174,30 @@ class FusionClockShiftPlanner(http.Controller):
|
||||
'data': self._load_week_data(start),
|
||||
}
|
||||
|
||||
@http.route('/fusion_clock/shift_planner/publish_range', type='jsonrpc', auth='user', methods=['POST'])
|
||||
def publish_range(self, date_from=None, date_to=None, employee_ids=None, message=None,
|
||||
week_start=None, **kw):
|
||||
"""Publish & Notify over an arbitrary date range, optionally limited to a
|
||||
subset of employees, with an optional custom message in the email."""
|
||||
if not self._check_manager():
|
||||
return {'error': 'Access denied.'}
|
||||
start = fields.Date.to_date(date_from) or self._week_start(week_start)
|
||||
end = fields.Date.to_date(date_to) or (start + timedelta(days=6))
|
||||
if end < start:
|
||||
return {'success': False, 'message': 'End date must be on or after the start date.'}
|
||||
employees = self._manager_employees()
|
||||
if employee_ids:
|
||||
wanted = {int(eid) for eid in employee_ids}
|
||||
employees = employees.filtered(lambda e: e.id in wanted)
|
||||
Schedule = request.env['fusion.clock.schedule'].sudo()
|
||||
posted_count, notified = Schedule.fclk_publish_range(employees, start, end, message=message)
|
||||
return {
|
||||
'success': True,
|
||||
'posted': posted_count,
|
||||
'notified': notified,
|
||||
'data': self._load_week_data(week_start),
|
||||
}
|
||||
|
||||
@http.route('/fusion_clock/shift_planner/copy_previous_week', type='jsonrpc', auth='user', methods=['POST'])
|
||||
def copy_previous_week(self, week_start=None, **kw):
|
||||
if not self._check_manager():
|
||||
|
||||
Reference in New Issue
Block a user