[IMP]: crm(meeting): Improvement for Editing Recurrent events

bzr revid: rpa@openerp.co.in-20100304140209-5wbu7wd3xx3ah4j8
This commit is contained in:
rpa (Open ERP)
2010-03-04 19:32:09 +05:30
parent c8c3ba54dc
commit 2b71d51681
4 changed files with 34 additions and 22 deletions
+23 -2
View File
@@ -806,12 +806,13 @@ rule or repeating pattern for anexception to a recurrence set"),
_defaults = {
'class': lambda *a: 'public',
'show_as': lambda *a: 'busy',
'freq': lambda *x: 'daily',
'freq': lambda *x: 'None',
'select1': lambda *x: 'date',
'interval': lambda *x: 1,
}
def modify_this(self, cr, uid, ids, defaults, context=None, *args):
ids = map(lambda x: base_calendar_id2real_id(x), ids)
datas = self.read(cr, uid, ids[0], context=context)
defaults.update({
'recurrent_uid': base_calendar_id2real_id(datas['id']),
@@ -820,11 +821,27 @@ rule or repeating pattern for anexception to a recurrence set"),
'rrule': ''
})
exdate = datas['exdate'] and datas['exdate'].split(',') or []
exdate.append(defaults.get('date'))
if defaults.get('date'):
exdate.append(defaults.get('date'))
self.write(cr, uid, ids, {'exdate': ','.join(exdate)}, context=context)
new_id = self.copy(cr, uid, ids[0], default=defaults, context=context)
return new_id
def modify_all(self, cr, uid, ids, defaults, context=None, *args):
ids = map(lambda x: base_calendar_id2real_id(x), ids)
defaults.pop('id')
defaults.update({'table': self._table})
qry = "UPDATE %(table)s set name='%(name)s', \
date='%(date)s', date_deadline='%(date_deadline)s'"
if defaults.get('alarm_id'):
qry += ", alarm_id=%(alarm_id)s"
if defaults.get('location'):
qry += ", location='%(location)s'"
qry += "WHERE id=%s" % (ids[0])
cr.execute(qry % (defaults))
return True
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100):
if not limit:
limit = 100
@@ -968,6 +985,10 @@ rule or repeating pattern for anexception to a recurrence set"),
select = ids
new_ids = []
for id in select:
if len(str(id).split('-')) > 1:
data = self.read(cr, uid, id, ['date', 'date_deadline'])
self.modify_this(cr, uid, [id], vals, context)
continue
id = base_calendar_id2real_id(id)
if not id in new_ids:
new_ids.append(id)
@@ -22,9 +22,9 @@
import wizard
import pooler
class event_edit_this(wizard.interface):
class event_edit_all(wizard.interface):
event_form = """<?xml version="1.0"?>
<form string="Edit this Occurence">
<form string="Edit all Occurrences">
<separator string="" colspan="4" />
<newline />
<field name='name' colspan="4" />
@@ -38,9 +38,9 @@ class event_edit_this(wizard.interface):
</form>"""
event_fields = {
'name': {'string': 'Title', 'type': 'char', 'size': 64},
'date': {'string': 'Start Date', 'type': 'datetime'},
'date_deadline': {'string': 'End Date', 'type': 'datetime'},
'name': {'string': 'Title', 'type': 'char', 'size': 64, 'required': True},
'date': {'string': 'Start Date', 'type': 'datetime', 'required': True},
'date_deadline': {'string': 'End Date', 'type': 'datetime', 'required': True},
'location': {'string': 'Location', 'type': 'char', 'size': 124},
'alarm_id': {'string': 'Reminder', 'type': 'many2one', 'relation': 'res.alarm'},
}
@@ -58,17 +58,8 @@ class event_edit_this(wizard.interface):
def _modify_this(self, cr, uid, datas, context=None):
model = datas.get('model')
model_obj = pooler.get_pool(cr.dbname).get(model)
new_id = model_obj.modify_this(cr, uid, [datas['id']], datas['form'], context)
value = {
'name': 'New event',
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': model,
'res_id': new_id,
'view_id': False,
'type': 'ir.actions.act_window',
}
return value
model_obj.modify_all(cr, uid, [datas['id']], datas['form'], context)
return {}
states = {
'init': {
@@ -82,6 +73,6 @@ class event_edit_this(wizard.interface):
}
}
event_edit_this('calendar.event.edit.this')
event_edit_all('calendar.event.edit.all')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1 -1
View File
@@ -38,7 +38,7 @@
<field name="rrule_type" string="Recurrency"
colspan="1" attrs="{'readonly':[('recurrent_uid','!=',False)]}"/>
<button string="Edit All" help="Edit all Ourrences of recurrent Meeting" attrs="{'invisible':[('rrule_type','in', ('none', False))]}"
name="%(wizard_edit_this_event)d" icon="gtk-edit"
name="%(wizard_edit_all_events)d" icon="gtk-edit"
type="action" context="{'model' : 'crm.meeting', 'date': date, 'date_deadline': date_deadline}" />
</group>
+2 -2
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard string="Edit this event" model="crm.meeting"
name="calendar.event.edit.this" id="wizard_edit_this_event"
<wizard string="Edit all events" model="crm.meeting"
name="calendar.event.edit.all" id="wizard_edit_all_events"
menu="False" />
</data>
</openerp>