[CLEAN] calendar code and files __openerp__.py | 2
base_calendar.py | 120 ++++++---------------- base_calendar_view.xml | 3 wizard/__init__.py | 2 wizard/base_calendar_set_exrule.py | 163 ------------------------------- wizard/base_calendar_set_exrule_view.xml | 71 ------------- wizard/calendar_event_edit_all.py | 98 ------------------ wizard/calendar_event_edit_all_view.xml | 41 ------- 8 files changed, 35 insertions(+), 465 deletions(-) bzr revid: tfr@openerp.com-20110331151449-k5wcwdzmkf8x9rpz
This commit is contained in:
parent
692d25a7a5
commit
f1f4488523
|
@ -37,9 +37,7 @@
|
|||
"demo_xml" : [],
|
||||
"update_xml" : [
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/calendar_event_edit_all_view.xml',
|
||||
'wizard/base_calendar_invite_attendee_view.xml',
|
||||
'wizard/base_calendar_set_exrule_view.xml',
|
||||
'base_calendar_view.xml'
|
||||
],
|
||||
"test" : ['test/base_calendar_test.yml'],
|
||||
|
|
|
@ -54,18 +54,14 @@ def get_recurrent_dates(rrulestring, exdate, startdate=None, exrule=None):
|
|||
|
||||
if not exdate:
|
||||
exdate = []
|
||||
print "rrule str",str(rrulestring)
|
||||
rset1 = rrule.rrulestr(str(rrulestring), dtstart=startdate, forceset=True)
|
||||
i = 0
|
||||
for date in exdate:
|
||||
i += 1
|
||||
datetime_obj = todate(date)
|
||||
rset1._exdate.append(datetime_obj)
|
||||
|
||||
if exrule:
|
||||
rset1.exrule(rrule.rrulestr(str(exrule), dtstart=startdate))
|
||||
|
||||
rset1
|
||||
return list(rset1)
|
||||
|
||||
def base_calendar_id2real_id(base_calendar_id=None, with_date=False):
|
||||
|
@ -995,13 +991,13 @@ class calendar_event(osv.osv):
|
|||
"""
|
||||
|
||||
result = {}
|
||||
for datas in self.read(cr, uid, ids, ['id','byday','recurrency', 'month_list','end_date', 'freq', 'rrule_type', 'select1', 'interval', 'count', 'end_type', 'mo', 'tu', 'we', 'th', 'fr', 'sa', 'su', 'exrule', 'day', 'week_list' ], context=context):
|
||||
for datas in self.read(cr, uid, ids, ['id','byday','recurrency', 'month_list','end_date', 'rrule_type', 'select1', 'interval', 'count', 'end_type', 'mo', 'tu', 'we', 'th', 'fr', 'sa', 'su', 'exrule', 'day', 'week_list' ], context=context):
|
||||
event = datas['id']
|
||||
if datas.get('interval', 0) < 0:
|
||||
raise osv.except_osv(_('Warning!'), _('Interval can not be Negative'))
|
||||
if datas.get('count', 0) < 0:
|
||||
raise osv.except_osv(_('Warning!'), _('Count can not be Negative'))
|
||||
result[event] = self.compute_rule_string(cr, uid, datas, context=context)
|
||||
result[event] = self.compute_rule_string(datas)
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
|
@ -1042,13 +1038,6 @@ rule or repeating pattern of time to exclude from the recurring rule."),
|
|||
'user_id': fields.many2one('res.users', 'Responsible', states={'done': [('readonly', True)]}),
|
||||
'organizer': fields.char("Organizer", size=256, states={'done': [('readonly', True)]}), # Map with Organizer Attribure of VEvent.
|
||||
'organizer_id': fields.many2one('res.users', 'Organizer', states={'done': [('readonly', True)]}),
|
||||
'freq': fields.selection([('None', 'No Repeat'),
|
||||
('hourly', 'Hours'),
|
||||
('daily', 'Days'),
|
||||
('weekly', 'Weeks'),
|
||||
('monthly', 'Months'),
|
||||
('yearly', 'Years'), ], 'Frequency'),
|
||||
|
||||
'end_type' : fields.selection([('count', 'Fix amout of times'), ('end_date','End date')], 'Way to end reccurency'),
|
||||
'interval': fields.integer('Repeat every', help="Repeat every (Days/Week/Month/Year)"),
|
||||
'count': fields.integer('Repeat', help="Repeat x times"),
|
||||
|
@ -1094,7 +1083,6 @@ rule or repeating pattern of time to exclude from the recurring rule."),
|
|||
'state': 'tentative',
|
||||
'class': 'public',
|
||||
'show_as': 'busy',
|
||||
'freq': 'None',
|
||||
'select1': 'date',
|
||||
'interval': 1,
|
||||
'active': 1,
|
||||
|
@ -1103,32 +1091,6 @@ rule or repeating pattern of time to exclude from the recurring rule."),
|
|||
'edit_all' : False,
|
||||
}
|
||||
|
||||
def modify_all(self, cr, uid, event_ids, defaults, context=None, *args):
|
||||
"""
|
||||
Modifies the recurring event
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param event_ids: List of crm meeting’s IDs.
|
||||
@param context: A standard dictionary for contextual values
|
||||
@return: True
|
||||
"""
|
||||
for event_id in event_ids:
|
||||
event_id = base_calendar_id2real_id(event_id)
|
||||
|
||||
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" % (event_id)
|
||||
cr.execute(qry, defaults)
|
||||
|
||||
return True
|
||||
|
||||
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100, context=None):
|
||||
"""Gives virtual event ids for recurring events based on value of Recurrence Rule
|
||||
This method gives ids of dates that comes between start date and end date of calendar views
|
||||
|
@ -1155,24 +1117,16 @@ rule or repeating pattern of time to exclude from the recurring rule."),
|
|||
until_date = base_until_date and datetime.strptime(base_until_date[:10]+ ' 23:59:59', "%Y-%m-%d %H:%M:%S") or False
|
||||
event_date = datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S")
|
||||
# To check: If the start date is replace by event date .. the event date will be changed by that of calendar code
|
||||
start_date = event_date
|
||||
|
||||
if not data['rrule']:
|
||||
|
||||
if start_date and (event_date < start_date):
|
||||
continue
|
||||
if until_date and (event_date > until_date):
|
||||
continue
|
||||
idval = data['id']
|
||||
if not data['recurrent_id']:
|
||||
result.append(idval)
|
||||
else:
|
||||
ex_id = real_id2base_calendar_id(data['recurrent_uid'], data['recurrent_id'])
|
||||
ls = base_calendar_id2real_id(ex_id, with_date=data and data.get('duration', 0) or 0)
|
||||
if not isinstance(ls, (str, int, long)) and len(ls) >= 2:
|
||||
if ls[1] == data['recurrent_id']:
|
||||
result.append(idval)
|
||||
recur_dict.append(ex_id)
|
||||
result.append(idval)
|
||||
else:
|
||||
start_date = event_date
|
||||
exdate = data['exdate'] and data['exdate'].split(',') or []
|
||||
rrule_str = data['rrule']
|
||||
new_rrule_str = []
|
||||
|
@ -1212,50 +1166,44 @@ rule or repeating pattern of time to exclude from the recurring rule."),
|
|||
return ids and ids[0] or False
|
||||
return ids
|
||||
|
||||
def compute_rule_string(self, cr, uid, datas, context=None, *args):
|
||||
def compute_rule_string(self, datas):
|
||||
"""
|
||||
Compute rule string according to value type RECUR of iCalendar from the values given.
|
||||
@param self: the object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param datas: dictionary of freq and interval value.
|
||||
@param context: A standard dictionary for contextual values
|
||||
@return: String value of the format RECUR of iCalendar
|
||||
"""
|
||||
|
||||
weekdays = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su']
|
||||
weekstring = ''
|
||||
monthstring = ''
|
||||
yearstring = ''
|
||||
|
||||
def get_week_string(freq, datas):
|
||||
weekdays = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su']
|
||||
if freq == 'weekly':
|
||||
byday = map(lambda x: x.upper(), filter(lambda x: datas.get(x) and x in weekdays, datas))
|
||||
if byday:
|
||||
return ';BYDAY=' + ','.join(byday)
|
||||
return ''
|
||||
|
||||
def get_month_string(freq, datas):
|
||||
if 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':
|
||||
return ';BYDAY=' + datas.get('byday') + datas.get('week_list')
|
||||
elif datas.get('select1')=='date':
|
||||
return ';BYMONTHDAY=' + str(datas.get('day'))
|
||||
return ''
|
||||
|
||||
def get_end_date(datas):
|
||||
if datas.get('end_date'):
|
||||
datas['end_date'] = ''.join((re.compile('\d')).findall(datas.get('end_date'))) + 'T235959Z'
|
||||
|
||||
return (datas.get('end_type') == 'count' and (';COUNT=' + str(datas.get('count'))) or '') +\
|
||||
((datas.get('end_date') and datas.get('end_type') == 'end_date' and (';UNTIL=' + datas.get('end_date'))) or '')
|
||||
|
||||
freq=datas.get('rrule_type')
|
||||
if freq == 'none':
|
||||
return ''
|
||||
|
||||
interval_srting = datas.get('interval') and (';INTERVAL=' + str(datas.get('interval'))) or ''
|
||||
|
||||
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'))
|
||||
|
||||
|
||||
if datas.get('end_date'):
|
||||
datas['end_date'] = ''.join((re.compile('\d')).findall(datas.get('end_date'))) + 'T235959Z'
|
||||
enddate = (datas.get('end_type') == 'count' and (';COUNT=' + str(datas.get('count'))) or '') +\
|
||||
((datas.get('end_date') and datas.get('end_type') == 'end_date' and (';UNTIL=' + datas.get('end_date'))) or '')
|
||||
|
||||
rrule_string = 'FREQ=' + freq.upper() + weekstring + interval_srting \
|
||||
+ enddate + monthstring + yearstring
|
||||
|
||||
return rrule_string
|
||||
return 'FREQ=' + freq.upper() + get_week_string(freq, datas) + interval_srting + get_end_date(datas) + get_month_string(freq, datas)
|
||||
|
||||
|
||||
def remove_virtual_id(self, ids):
|
||||
|
|
|
@ -242,8 +242,7 @@
|
|||
widget="selection" />
|
||||
<group colspan="2" col="4" attrs="{'readonly': [('state','=','done')]}">
|
||||
<field name="recurrency"/>
|
||||
<field name="edit_all" attrs="{'invisible':[('recurrency','=', False)]}"
|
||||
on_change="onchange_edit_all(rrule_type,edit_all)"/>
|
||||
<field name="edit_all" attrs="{'invisible':[('recurrency','=', False)]}" />
|
||||
</group>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import calendar_event_edit_all
|
||||
import base_calendar_invite_attendee
|
||||
import base_calendar_set_exrule
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from base_calendar import base_calendar
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import tools
|
||||
import re
|
||||
|
||||
|
||||
months = {
|
||||
1: "January", 2: "February", 3: "March", 4: "April", \
|
||||
5: "May", 6: "June", 7: "July", 8: "August", 9: "September", \
|
||||
10: "October", 11: "November", 12: "December"
|
||||
}
|
||||
|
||||
class base_calendar_set_exrule(osv.osv_memory):
|
||||
"""
|
||||
Set Exrule.
|
||||
"""
|
||||
|
||||
_name = "base.calendar.set.exrule"
|
||||
_description = "Set Exrule"
|
||||
|
||||
_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'),
|
||||
|
||||
}
|
||||
|
||||
def view_init(self, cr, uid, fields, context=None):
|
||||
"""
|
||||
This function checks for precondition before wizard executes
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param fields: List of fields for default value
|
||||
@param context: A standard dictionary for contextual values
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
event_obj = self.pool.get(context.get('active_model'))
|
||||
for event in event_obj.browse(cr, uid, context.get('active_ids', []), context=context):
|
||||
if not event.rrule:
|
||||
raise osv.except_osv(_("Warning !"), _("Please Apply Recurrency before applying Exception Rule."))
|
||||
return False
|
||||
|
||||
def compute_exrule_string(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Compute rule string.
|
||||
@param self: the object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param datas: dictionary of freq and interval value.
|
||||
@return: string value which compute FREQILY;INTERVAL
|
||||
"""
|
||||
|
||||
weekdays = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su']
|
||||
weekstring = ''
|
||||
monthstring = ''
|
||||
yearstring = ''
|
||||
if context is None:
|
||||
context = {}
|
||||
ex_id = base_calendar.base_calendar_id2real_id(context.get('active_id', False))
|
||||
model = context.get('model', False)
|
||||
model_obj = self.pool.get(model)
|
||||
for datas in self.read(cr, uid, ids, context=context):
|
||||
freq = datas.get('freq')
|
||||
if freq == 'None':
|
||||
model_obj.write(cr, uid, ex_id,{'exrule': ''})
|
||||
return{}
|
||||
|
||||
interval_srting = datas.get('interval') and (';INTERVAL=' + str(datas.get('interval'))) or ''
|
||||
|
||||
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 '')
|
||||
|
||||
exrule_string = 'FREQ=' + freq.upper() + weekstring + interval_srting \
|
||||
+ enddate + monthstring + yearstring
|
||||
|
||||
model_obj.write(cr, uid, ex_id,{'exrule': exrule_string})
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
_defaults = {
|
||||
'freq': lambda *x: 'None',
|
||||
'select1': lambda *x: 'date',
|
||||
'interval': lambda *x: 1,
|
||||
}
|
||||
|
||||
base_calendar_set_exrule()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,71 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_base_calendar_set_exrule" model="ir.ui.view">
|
||||
<field name="name">base.calendar.set.exrule.form</field>
|
||||
<field name="model">base.calendar.set.exrule</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Set Exrule">
|
||||
<separator string="Select range to Exclude" colspan="8"/>
|
||||
<group col="8" colspan="6">
|
||||
<field name="interval" />
|
||||
<field name="freq" />
|
||||
<field name="count" />
|
||||
<field name="end_date" />
|
||||
</group>
|
||||
<group col="8" colspan="8" 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="8" colspan="6"
|
||||
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 colspan="4" col="6">
|
||||
<separator string="" colspan="8"/>
|
||||
<label string="" colspan="2"/>
|
||||
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
|
||||
<button icon="gtk-ok" string="_Ok" name="compute_exrule_string" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_base_calendar_set_exrule" model="ir.actions.act_window">
|
||||
<field name="name">Set Exclude range</field>
|
||||
<field name="res_model">base.calendar.set.exrule</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form,tree</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,98 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
|
||||
class calendar_event_edit_all(osv.osv_memory):
|
||||
|
||||
def _default_values(self, cr, uid, context=None):
|
||||
""" Get Default value for Start Date
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param context: A standard dictionary for contextual values
|
||||
@Return: Get Default value for Start Date
|
||||
"""
|
||||
context_id = context and context.get('active_id', False) or False
|
||||
if context_id:
|
||||
if context.get('date'):
|
||||
return context.get('date')
|
||||
else:
|
||||
model = context.get('model', False)
|
||||
model_obj = self.pool.get(model)
|
||||
event = model_obj.read(cr, uid, context_id, ['name', 'location', 'alarm_id'])
|
||||
return event['date']
|
||||
|
||||
def _default_deadline(self, cr, uid, context=None):
|
||||
""" Get Default value for End Date
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param context: A standard dictionary for contextual values
|
||||
@return: Get Default value for End Date
|
||||
"""
|
||||
|
||||
context_id = context and context.get('active_id', False) or False
|
||||
if context_id:
|
||||
if context.get('date_deadline'):
|
||||
return context.get('date_deadline')
|
||||
else:
|
||||
model = context.get('model', False)
|
||||
model_obj = self.pool.get(model)
|
||||
event = model_obj.read(cr, uid, context_id, ['name', 'location', 'alarm_id'])
|
||||
return event['date_deadline']
|
||||
|
||||
def modify_this(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Modify All event for Crm Meeting.
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of calendar event edit all’s IDs
|
||||
@return: dictionary {}
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
context_id = context and context.get('active_id', False) or False
|
||||
if context_id:
|
||||
for datas in self.read(cr, uid, ids):
|
||||
model = context.get('model', False)
|
||||
model_obj = self.pool.get(model)
|
||||
model_obj.modify_all(cr, uid, [context_id], datas, context=context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
_name = "calendar.event.edit.all"
|
||||
_description = "Calendar Edit all event"
|
||||
_columns = {
|
||||
'name': fields.char('Title', size=64, required=True),
|
||||
'date': fields.datetime('Start Date', required=True),
|
||||
'date_deadline': fields.datetime('End Date', required=True),
|
||||
'location': fields.char('Location', size=124),
|
||||
'alarm_id': fields.many2one('res.alarm', 'Reminder'),
|
||||
}
|
||||
_defaults = {
|
||||
'date': _default_values,
|
||||
'date_deadline': _default_deadline
|
||||
}
|
||||
calendar_event_edit_all()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,41 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_calendar_event_edit_all" model="ir.ui.view">
|
||||
<field name="name">calendar.event.edit.all.form</field>
|
||||
<field name="model">calendar.event.edit.all</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Edit all Occurrences">
|
||||
<group colspan="4" >
|
||||
<separator string="" colspan="4" />
|
||||
<newline/>
|
||||
<field name='name' colspan="4" />
|
||||
<newline />
|
||||
<field name='location' colspan="4" />
|
||||
<newline />
|
||||
<field name='date' />
|
||||
<field name='date_deadline' />
|
||||
<newline />
|
||||
<field name='alarm_id'/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-save" string="_Save" name="modify_this" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_calendar_event_edit_all" model="ir.actions.act_window">
|
||||
<field name="name">Edit all events</field>
|
||||
<field name="res_model">calendar.event.edit.all</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_calendar_event_edit_all"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue