[IMP] calendar: delete recurrent event
This PR change the delete button in the attendee calendar if the event is recurrent. If the event is recurrent, a wizard pop up to ask if you wish to remove : - The selected event - The selected event and the following - All the event in the recurrence task-id : 3148011 closes odoo/odoo#113024 Signed-off-by: Arnaud Joset <arj@odoo.com>
This commit is contained in:
@@ -34,7 +34,8 @@ If you need to manage your meetings, you should install the CRM module.
|
||||
'views/calendar_templates.xml',
|
||||
'views/calendar_views.xml',
|
||||
'views/res_partner_views.xml',
|
||||
'wizard/calendar_provider_config.xml'
|
||||
'wizard/calendar_provider_config.xml',
|
||||
'wizard/calendar_popover_delete_wizard.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': True,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_calendar_attendee_portal,calendar.attendee_portal,model_calendar_attendee,base.group_portal,0,0,0,0
|
||||
access_calendar_attendee_employee,calendar.attendee_employee,model_calendar_attendee,base.group_user,1,1,1,1
|
||||
access_calendar_attendee_employee_delete_wizard,calendar.attendee_employee_delete_wizard,model_calendar_popover_delete_wizard,base.group_user,1,1,1,1
|
||||
access_calendar_alarm,calendar.alarm,model_calendar_alarm,base.group_user,1,1,1,1
|
||||
access_calendar_event_all_user,calendar.event_all_user,model_calendar_event,base.group_portal,1,0,0,0
|
||||
access_calendar_event_all_employee,calendar.event_all_employee,model_calendar_event,base.group_user,1,1,1,1
|
||||
|
||||
|
@@ -32,7 +32,11 @@ export class AttendeeCalendarController extends CalendarController {
|
||||
*/
|
||||
deleteRecord(record) {
|
||||
if (this.user.partnerId === record.attendeeId && this.user.partnerId === record.rawRecord.partner_id[0]) {
|
||||
super.deleteRecord(...arguments);
|
||||
if (record.rawRecord.recurrency) {
|
||||
this.openRecurringDeletionWizard(record);
|
||||
} else {
|
||||
super.deleteRecord(...arguments);
|
||||
}
|
||||
} else {
|
||||
// Decline event
|
||||
this.orm.call(
|
||||
@@ -43,6 +47,22 @@ export class AttendeeCalendarController extends CalendarController {
|
||||
}
|
||||
}
|
||||
|
||||
openRecurringDeletionWizard(record) {
|
||||
this.actionService.doAction({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'calendar.popover.delete.wizard',
|
||||
views: [[false, 'form']],
|
||||
view_mode: "form",
|
||||
name: 'Delete Recurring Event',
|
||||
context: {'default_record': record.id},
|
||||
target: 'new'
|
||||
}, {
|
||||
onClose: () => {
|
||||
location.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
configureCalendarProviderSync(providerName) {
|
||||
this.actionService.doAction({
|
||||
name: this.env._t('Connect your Calendar'),
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.exceptions import UserError
|
||||
import pytz
|
||||
from datetime import datetime, date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.tests.common import TransactionCase, Form
|
||||
|
||||
|
||||
class TestRecurrentEvents(TransactionCase):
|
||||
@@ -580,6 +579,26 @@ class TestUpdateRecurrentEvents(TestRecurrentEvents):
|
||||
self.assertTrue(self.recurrence)
|
||||
self.assertEqual(self.events.exists(), self.events[0])
|
||||
|
||||
def test_unlink_recurrence_wizard_next(self):
|
||||
event = self.events[1]
|
||||
wizard = self.env['calendar.popover.delete.wizard'].create({'record': event.id})
|
||||
form = Form(wizard)
|
||||
form.delete = 'next'
|
||||
form.save()
|
||||
wizard.close()
|
||||
self.assertTrue(self.recurrence)
|
||||
self.assertEqual(self.events.exists(), self.events[0])
|
||||
|
||||
def test_unlink_recurrence_wizard_all(self):
|
||||
event = self.events[1]
|
||||
wizard = self.env['calendar.popover.delete.wizard'].create({'record': event.id})
|
||||
form = Form(wizard)
|
||||
form.delete = 'all'
|
||||
form.save()
|
||||
wizard.close()
|
||||
self.assertFalse(self.recurrence.exists())
|
||||
self.assertFalse(self.events.exists())
|
||||
|
||||
|
||||
class TestUpdateMultiDayWeeklyRecurrentEvents(TestRecurrentEvents):
|
||||
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
|
||||
|
||||
from . import calendar_provider_config
|
||||
from . import calendar_popover_delete_wizard
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class CalendarProviderConfig(models.TransientModel):
|
||||
_name = 'calendar.popover.delete.wizard'
|
||||
_description = 'Calendar Popover Delete Wizard'
|
||||
|
||||
|
||||
record = fields.Many2one('calendar.event', 'Calendar Event')
|
||||
delete = fields.Selection([('one', 'Delete this event'), ('next', 'Delete this and following events'), ('all', 'Delete all the events')], default='one')
|
||||
|
||||
def close(self):
|
||||
if not self.record or not self.delete:
|
||||
pass
|
||||
elif self.delete == 'one':
|
||||
self.record.unlink()
|
||||
else:
|
||||
switch = {
|
||||
'next': 'future_events',
|
||||
'all': 'all_events'
|
||||
}
|
||||
self.record.action_mass_deletion(switch.get(self.delete, ''))
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="calendar_popover_delete_view" model="ir.ui.view">
|
||||
<field name="name">calendar.popover.delete.wizard.view.form</field>
|
||||
<field name="model">calendar.popover.delete.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Delete Event">
|
||||
<field name="delete" widget="radio"/>
|
||||
<footer>
|
||||
<button name="close" string="Submit" type="object" class="btn-primary" data-hotkey="q"/>
|
||||
<button string="Cancel" class="btn-secondary" special="cancel" data-hotkey="z"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user