[IMP]: crm(meetings): Removed wizard for setting Recurrence, put the recurrence fields in event(Meeting)

bzr revid: rpa@openerp.co.in-20100304125913-y7hljnvk00u21fpf
This commit is contained in:
rpa (Open ERP) 2010-03-04 18:29:13 +05:30
parent b763ed02c6
commit a80207cb64
4 changed files with 157 additions and 217 deletions

View File

@ -710,15 +710,6 @@ class calendar_event(osv.osv):
def _tz_get(self, cr, uid, context={}):
return [(x.lower(), x) for x in pytz.all_timezones]
def onchange_rrule_type(self, cr, uid, ids, rtype, *args, **argv):
if rtype == 'none' or not rtype:
return {'value': {'rrule': ''}}
if rtype == 'custom':
return {}
rrule = self.pool.get('calendar.custom.rrule')
rrulestr = rrule.compute_rule_string(cr, uid, {'freq': rtype.upper(), \
'interval': 1})
return {'value': {'rrule': rrulestr}}
def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, context={}):
if not start_date:
@ -735,6 +726,22 @@ class calendar_event(osv.osv):
value['date_deadline'] = end.strftime("%Y-%m-%d %H:%M:%S")
return {'value': value}
def _get_rulestring(self, cr, uid, ids, name, arg, context=None):
result = {}
for event in ids:
datas = self.read(cr, uid, ids)[0]
if datas.get('rrule_type'):
if datas.get('rrule_type') == 'none':
result[event] = False
elif datas.get('rrule_type') == 'custom':
rrule_custom = self.compute_rule_string(cr, uid, datas)
result[event] = rrule_custom
else:
result[event] = self.compute_rule_string(cr, uid, {'freq':\
datas.get('rrule_type').upper(), \
'interval': 1}, context=context)
return result
_columns = {
'id': fields.integer('ID'),
'sequence': fields.integer('Sequence'),
@ -755,7 +762,7 @@ class calendar_event(osv.osv):
defines the list of date/time exceptions for arecurring calendar component."),
'exrule': fields.char('Exception Rule', size=352, help="defines a \
rule or repeating pattern for anexception to a recurrence set"),
'rrule': fields.char('Recurrent Rule', size=124),
'rrule': fields.function(_get_rulestring, type='char', size=124, method=True, string='Recurrent Rule', store=True),
'rrule_type': fields.selection([('none', ''), ('daily', 'Daily'), \
('weekly', 'Weekly'), ('monthly', 'Monthly'), \
('yearly', 'Yearly'), ('custom', 'Custom')], 'Recurrency'),
@ -764,12 +771,44 @@ rule or repeating pattern for anexception to a recurrence set"),
'recurrent_uid': fields.integer('Recurrent ID'),
'recurrent_id': fields.datetime('Recurrent ID date'),
'vtimezone': fields.related('user_id', 'context_tz', type='char', size=24, string='Timezone'),
'user_id': fields.many2one('res.users', 'Responsible'),
'user_id': fields.many2one('res.users', 'Responsible'),
'freq': fields.selection([('None', 'No Repeat'), \
('secondly', 'Secondly'), \
('minutely', 'Minutely'), \
('hourly', 'Hourly'), \
('daily', 'Daily'), \
('weekly', 'Weekly'), \
('monthly', 'Monthly'), \
('yearly', 'Yearly')], 'Frequency'),
'interval': fields.integer('Interval'),
'count': fields.integer('Count'),
'mo': fields.boolean('Mon'),
'tu': fields.boolean('Tue'),
'we': fields.boolean('Wed'),
'th': fields.boolean('Thu'),
'fr': fields.boolean('Fri'),
'sa': fields.boolean('Sat'),
'su': fields.boolean('Sun'),
'select1': fields.selection([('date', 'Date of month'), \
('day', 'Day of month')], 'Option'),
'day': fields.integer('Date of month'),
'week_list': fields.selection([('MO', 'Monday'), ('TU', 'Tuesday'), \
('WE', 'Wednesday'), ('TH', 'Thursday'), \
('FR', 'Friday'), ('SA', 'Saturday'), \
('SU', 'Sunday')], 'Weekday'),
'byday': fields.selection([('1', 'First'), ('2', 'Second'), \
('3', 'Third'), ('4', 'Fourth'), \
('5', 'Fifth'), ('-1', 'Last')], 'By day'),
'month_list': fields.selection(months.items(), 'Month'),
'end_date': fields.date('Repeat Until')
}
_defaults = {
'class': lambda *a: 'public',
'show_as': lambda *a: 'busy',
'freq': lambda *x: 'daily',
'select1': lambda *x: 'date',
'interval': lambda *x: 1,
}
def modify_this(self, cr, uid, ids, defaults, context=None, *args):
@ -858,6 +897,50 @@ rule or repeating pattern for anexception to a recurrence set"),
return ids and ids[0] or False
return ids
def compute_rule_string(self, cr, uid, datas, context=None, *args):
weekdays = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su']
weekstring = ''
monthstring = ''
yearstring = ''
# logic for computing rrule string
freq = datas.get('freq')
if freq == 'None':
return ''
if freq == 'weekly':
byday = map(lambda x: x.upper(), filter(lambda x: datas.get(x) and x in weekdays, datas))
if byday:
weekstring = ';BYDAY=' + ','.join(byday)
elif freq == 'monthly':
if datas.get('select1')=='date' and (datas.get('day') < 1 or datas.get('day') > 31):
raise osv.except_osv(_('Error!'), ("Please select proper Day of month"))
if datas.get('select1')=='day':
monthstring = ';BYDAY=' + datas.get('byday') + datas.get('week_list')
elif datas.get('select1')=='date':
monthstring = ';BYMONTHDAY=' + str(datas.get('day'))
elif freq == 'yearly':
if datas.get('select1')=='date' and (datas.get('day') < 1 or datas.get('day') > 31):
raise osv.except_osv(_('Error!'), ("Please select proper Day of month"))
bymonth = ';BYMONTH=' + str(datas.get('month_list'))
if datas.get('select1')=='day':
bystring = ';BYDAY=' + datas.get('byday') + datas.get('week_list')
elif datas.get('select1')=='date':
bystring = ';BYMONTHDAY=' + str(datas.get('day'))
yearstring = bymonth + bystring
if datas.get('end_date'):
datas['end_date'] = ''.join((re.compile('\d')).findall(datas.get('end_date'))) + '235959Z'
enddate = (datas.get('count') and (';COUNT=' + str(datas.get('count'))) or '') +\
((datas.get('end_date') and (';UNTIL=' + datas.get('end_date'))) or '')
rrule_string = 'FREQ=' + freq.upper() + weekstring + ';INTERVAL=' + \
str(datas.get('interval')) + enddate + monthstring + yearstring
# End logic
return rrule_string
def search(self, cr, uid, args, offset=0, limit=100, order=None,
context=None, count=False):
args_without_date = []
@ -1072,114 +1155,6 @@ class virtual_report_spool(web_services.report_spool):
virtual_report_spool()
class calendar_custom_rrule(osv.osv):
_name = "calendar.custom.rrule"
_description = "Custom Recurrency Rule"
_columns = {
'freq': fields.selection([('None', 'No Repeat'), \
('secondly', 'Secondly'), \
('minutely', 'Minutely'), \
('hourly', 'Hourly'), \
('daily', 'Daily'), \
('weekly', 'Weekly'), \
('monthly', 'Monthly'), \
('yearly', 'Yearly')], 'Frequency', required=True),
'interval': fields.integer('Interval'),
'count': fields.integer('Count'),
'mo': fields.boolean('Mon'),
'tu': fields.boolean('Tue'),
'we': fields.boolean('Wed'),
'th': fields.boolean('Thu'),
'fr': fields.boolean('Fri'),
'sa': fields.boolean('Sat'),
'su': fields.boolean('Sun'),
'select1': fields.selection([('date', 'Date of month'), \
('day', 'Day of month')], 'Option'),
'day': fields.integer('Date of month'),
'week_list': fields.selection([('MO', 'Monday'), ('TU', 'Tuesday'), \
('WE', 'Wednesday'), ('TH', 'Thursday'), \
('FR', 'Friday'), ('SA', 'Saturday'), \
('SU', 'Sunday')], 'Weekday'),
'byday': fields.selection([('1', 'First'), ('2', 'Second'), \
('3', 'Third'), ('4', 'Fourth'), \
('5', 'Fifth'), ('-1', 'Last')], 'By day'),
'month_list': fields.selection(months.items(), 'Month'),
'end_date': fields.date('Repeat Until')
}
_defaults = {
'freq': lambda *x: 'daily',
'select1': lambda *x: 'date',
'interval': lambda *x: 1,
}
def compute_rule_string(self, cr, uid, datas, context=None, *args):
weekdays = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su']
weekstring = ''
monthstring = ''
yearstring = ''
# logic for computing rrule string
freq = datas.get('freq')
if freq == 'None':
obj.write(cr, uid, [res_obj.id], {'rrule': ''})
return {}
if freq == 'weekly':
byday = map(lambda x: x.upper(), filter(lambda x: datas.get(x) and x in weekdays, datas))
if byday:
weekstring = ';BYDAY=' + ','.join(byday)
elif freq == 'monthly':
if datas.get('select1')=='date' and (datas.get('day') < 1 or datas.get('day') > 31):
raise osv.except_osv(_('Error!'), ("Please select proper Day of month"))
if datas.get('select1')=='day':
monthstring = ';BYDAY=' + datas.get('byday') + datas.get('week_list')
elif datas.get('select1')=='date':
monthstring = ';BYMONTHDAY=' + str(datas.get('day'))
elif freq == 'yearly':
if datas.get('select1')=='date' and (datas.get('day') < 1 or datas.get('day') > 31):
raise osv.except_osv(_('Error!'), ("Please select proper Day of month"))
bymonth = ';BYMONTH=' + str(datas.get('month_list'))
if datas.get('select1')=='day':
bystring = ';BYDAY=' + datas.get('byday') + datas.get('week_list')
elif datas.get('select1')=='date':
bystring = ';BYMONTHDAY=' + str(datas.get('day'))
yearstring = bymonth + bystring
if datas.get('end_date'):
datas['end_date'] = ''.join((re.compile('\d')).findall(datas.get('end_date'))) + '235959Z'
enddate = (datas.get('count') and (';COUNT=' + str(datas.get('count'))) or '') +\
((datas.get('end_date') and (';UNTIL=' + datas.get('end_date'))) or '')
rrule_string = 'FREQ=' + freq.upper() + weekstring + ';INTERVAL=' + \
str(datas.get('interval')) + enddate + monthstring + yearstring
# End logic
return rrule_string
def do_add(self, cr, uid, ids, context={}):
datas = self.read(cr, uid, ids)[0]
if datas.get('interval') <= 0:
raise osv.except_osv(_('Error!'), ("Please select proper Interval"))
if not context or not context.get('model'):
return {}
else:
model = context.get('model')
obj = self.pool.get(model)
res_obj = obj.browse(cr, uid, context['active_id'])
rrule_string = self.compute_rule_string(cr, uid, datas)
obj.write(cr, uid, [res_obj.id], {'rrule': rrule_string})
return {}
calendar_custom_rrule()
class res_users(osv.osv):
_inherit = 'res.users'
@ -1198,7 +1173,7 @@ class res_users(osv.osv):
status = 'busy'
res.update({user_id:status})
#TOCHECK: Delegrated Event
#TOCHECK: Delegated Event
for user_id in ids:
if user_id not in res:
res[user_id] = 'free'
@ -1214,4 +1189,5 @@ class res_users(osv.osv):
string='Free/Busy', method=True),
}
res_users()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -173,71 +173,6 @@
<field name="view_mode">tree,form</field>
</record>
<record id="view_custom_rule_form" model="ir.ui.view">
<field name="name">Custom Rule</field>
<field name="model">calendar.custom.rrule</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Custom Rule">
<separator string="Select data for Custom Rule" colspan="4"/>
<field name="freq" />
<field name="interval" />
<newline />
<field name="count"
attrs="{'required' : [('end_date','=',False)]}"/>
<field name="end_date"
attrs="{'required' : [('count','&lt;=',0), ('freq', '!=', 'None')]}"/>
<group col="7" colspan="4" name="Select weekdays"
attrs="{'invisible' : [('freq','!=','weekly')]}">
<separator string="" colspan="6" />
<newline />
<field name="mo" colspan="1" />
<field name="tu" colspan="1" />
<field name="we" colspan="1" />
<field name="th" colspan="1" />
<field name="fr" colspan="1" />
<field name="sa" colspan="1" />
<field name="su" colspan="1" />
<newline />
</group>
<group col="4" colspan="4" attrs="{'invisible' : [('freq','!=','monthly'), ('freq','!=','yearly')]}">
<separator string="" colspan="6"/>
<group col="2" colspan="4">
<field name="select1"/>
</group>
<group col="3" colspan="4" attrs="{'invisible' : [('select1','=','day')]}">
<field name="day" attrs="{'required' : [('select1','=','date')]}"/>
</group>
<newline />
<group col="3" colspan="4" attrs="{'invisible' : [('select1','=','date')]}">
<field name="byday" string="The"
attrs="{'required' : [('select1','=','day')]}"/>
<field name="week_list" nolabel="1"
attrs="{'required' : [('select1','=','day')]}"/>
</group>
<group col="2" colspan="4" attrs="{'invisible' : [('freq','!=','yearly')]}">
<field name="month_list" string="of" colspan="1"
attrs="{'required' : [('freq','=','yearly')]}"/>
</group>
</group>
<separator string="" colspan="6" />
<label string="" colspan="2"/>
<button icon='gtk-cancel' special="cancel" string="Cancel"/>
<button name="do_add" string="Ok" type="object" icon="gtk-ok"/>
</form>
</field>
</record>
<record id="action_calendar_custom_rrule_wizard" model="ir.actions.act_window">
<field name="name">Custom Rule</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">calendar.custom.rrule</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!-- Available alarms-->
<menuitem id="base.menu_calendar_configuration" name="Calendar"

View File

@ -24,30 +24,70 @@
<field name="model">crm.meeting</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Meetings">
<form string="Meetings">
<group col="6" colspan="4">
<field name="name" select="1" string="Summary"
colspan="4" />
<field name="categ_id" widget="selection" string="Meeting Type" domain="[('object_id.model', '=', 'crm.meeting')]"/>
colspan="4" />
<field name="categ_id" widget="selection" string="Meeting Type" domain="[('object_id.model', '=', 'crm.meeting')]"/>
<field name="date" string="Start Date" required="1" on_change="onchange_dates(date,duration,False)"/>
<field name="duration" widget="float_time" on_change="onchange_dates(date,duration,False)"/>
<field name="date_deadline" string="End Date" required="1" on_change="onchange_dates(date,False,date_deadline)"/>
<field name="location" />
<field name="alarm_id" string="Reminder" widget="selection" />
<group colspan="2" col="4" >
<field name="rrule_type" string="Recurrency"
on_change="onchange_rrule_type(rrule_type)"
<field name="rrule_type" string="Recurrency"
colspan="1" attrs="{'readonly':[('recurrent_uid','!=',False)]}"/>
<button string="Custom"
name="%(base_calendar.action_calendar_custom_rrule_wizard)d"
icon="gtk-save-as" type="action" context="{'model' : 'crm.meeting'}"
attrs="{'invisible': [('rrule_type','!=','custom')]}"
/>
<button string="Edit" help="Edit only this Occurrency Meeting" attrs="{'invisible':[('rrule_type','in', ('none', False))]}"
name="%(wizard_edit_this_event)d" icon="gtk-save"
<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"
type="action" context="{'model' : 'crm.meeting', 'date': date, 'date_deadline': date_deadline}" />
</group>
</group>
<group col="4" colspan="4" name="rrule" attrs="{'invisible': [('rrule_type','!=','custom')]}">
<separator string="Select data for Custom Rule" colspan="8"/>
<group col="8" colspan="4">
<field name="freq" />
<field name="interval" />
<field name="count"
attrs="{'required' : [('end_date','=',False)]}" />
<field name="end_date"
attrs="{'required' : [('count','&lt;=',0), ('freq', '!=', 'None')]}" />
</group>
<group col="14" colspan="4" name="Select weekdays"
attrs="{'invisible' : [('freq','!=','weekly')]}">
<field name="mo" colspan="1" />
<field name="tu" colspan="1" />
<field name="we" colspan="1" />
<field name="th" colspan="1" />
<field name="fr" colspan="1" />
<field name="sa" colspan="1" />
<field name="su" colspan="1" />
<newline />
</group>
<group col="10" colspan="4"
attrs="{'invisible' : [('freq','!=','monthly'), ('freq','!=','yearly')]}">
<group col="2" colspan="1">
<field name="select1" />
</group>
<group col="2" colspan="1"
attrs="{'invisible' : [('select1','=','day')]}">
<field name="day"
attrs="{'required' : [('select1','=','date')]}" />
</group>
<group col="3" colspan="1"
attrs="{'invisible' : [('select1','=','date')]}">
<field name="byday" string="The"
attrs="{'required' : [('select1','=','day')]}" />
<field name="week_list" nolabel="1"
attrs="{'required' : [('select1','=','day')]}" />
</group>
<group col="1" colspan="1"
attrs="{'invisible' : [('freq','!=','yearly')]}">
<field name="month_list" string="of"
colspan="1"
attrs="{'required' : [('freq','=','yearly')]}" />
</group>
</group>
</group>
<notebook colspan="4">
<page string="Meeting">
@ -62,11 +102,11 @@
<group colspan="4" col="4">
<field name="user_id" />
<field name="section_id" widget="selection" />
<field name="show_as" string="Show time as"/>
<field name="show_as" string="Show time as"/>
<field name="class" string="Privacy"/>
<field name="recurrent_id" invisible="1" />
<field name="recurrent_uid" invisible="1" />
<field name="rrule" invisible="1" />
<field name="rrule" groups="base.group_extended" />
</group>
<separator string="Description" colspan="4" />
<field name="description" nolabel="1" colspan="4" />
@ -129,10 +169,8 @@
</notebook>
</form>
</field>
</page>
</page>
</notebook>
</form>
</field>
</record>
@ -145,12 +183,12 @@
<tree string="Meetings" colors="red:state=='open';black:state in ('draft', 'cancel','done','pending')">
<field name="id" widget="char"/>
<field name="name" string="Subject"/>
<field name="partner_id" string="Partner"/>
<field name="partner_id" string="Partner"/>
<field name="section_id" />
<field name="date" string="Meeting Date"/>
<field name="date" string="Meeting Date"/>
<field name="categ_id"/>
<field name="user_id"/>
<field name="state"/>
<field name="state"/>
</tree>
</field>
</record>
@ -210,7 +248,7 @@
<field name="name">calendar.attendee.form.inherit</field>
<field name="model">calendar.attendee</field>
<field name="type">form</field>
<field name="inherit_id" ref="base_calendar.base_calendar_attendee_form_view"/>
<field name="inherit_id" ref="base_calendar.base_calendar_attendee_form_view"/>
<field name="arch" type="xml">
<field name="language" position="after">
<field name="categ_id" string="Event Type"/>
@ -222,7 +260,7 @@
<field name="name">calendar.attendee.tree.inherit</field>
<field name="model">calendar.attendee</field>
<field name="type">tree</field>
<field name="inherit_id" ref="base_calendar.base_calendar_attendee_tree_view"/>
<field name="inherit_id" ref="base_calendar.base_calendar_attendee_tree_view"/>
<field name="arch" type="xml">
<field name="role" position="after">
<field name="categ_id" string="Event Type"/>

View File

@ -76,15 +76,6 @@
<field name="fn">field</field>
</record>
<record model="basic.calendar.fields" id="map_event_8">
<field name="name" ref="caldav.field_event_priority"/>
<field name="type_id" ref="base_calendar.calendar_lines_event" />
<field name="field_id" search="[('name','=','priority'),('model_id.model','=','crm.meeting')]" />
<field name="fn">field</field>
<field name="mapping">{'1': '1', '2': '2', '3': '2','4': '2', '5': '3', '6': '4', '7': '4', '8': '4', '9': '5'}</field>
</record>
<record model="basic.calendar.fields" id="map_event_9">
<field name="name" ref="caldav.field_event_location"/>
<field name="type_id" ref="base_calendar.calendar_lines_event" />