diff --git a/addons/caldav/caldav_view.xml b/addons/caldav/caldav_view.xml
index 46b6329e1d6..06050f03b5a 100644
--- a/addons/caldav/caldav_view.xml
+++ b/addons/caldav/caldav_view.xml
@@ -14,7 +14,8 @@
-
+
@@ -118,11 +119,11 @@
calendar.attendee
tree
-
-
-
-
+
+
+
+
@@ -152,38 +153,6 @@
-
-
- calendar.attendee.tree1
- calendar.attendee
- tree
- 10
-
-
-
-
-
-
-
-
-
-
- calendar.attendee.form1
- calendar.attendee
- form
- 10
-
-
-
-
-
res.alarm.form
res.alarm
@@ -233,66 +202,63 @@
form
-
-
-
-
- Custom Rule
- calendar.custom.rrule
- tree
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Custom Rule
+ ir.actions.act_window
+ calendar.custom.rrule
+ form
+ form
+ new
+
diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py
index 5154e1fffaa..2d8edb1b204 100644
--- a/addons/caldav/calendar.py
+++ b/addons/caldav/calendar.py
@@ -23,9 +23,9 @@ from datetime import datetime, timedelta
from dateutil import parser
from dateutil.rrule import *
from osv import osv
+import common
import re
import vobject
-import common
# O-1 Optional and can come only once
# O-n Optional and can come more than once
@@ -78,9 +78,9 @@ class CalDAV(object):
}
def get_recurrent_dates(self, rrulestring, exdate, startdate=None):
if not startdate:
- startdate = datetime.now()
+ startdate = datetime.now()
rset1 = rrulestr(rrulestring, dtstart=startdate, forceset=True)
-
+
for date in exdate:
datetime_obj = todate(date)
rset1._exdate.append(datetime_obj)
@@ -128,10 +128,10 @@ class CalDAV(object):
continue
uidval = common.openobjectid2uid(cr, data[map_field], model)
vevent.add('uid').value = uidval
- elif field == 'attendee' and data[map_field]:
+ elif field == 'attendee' and data[map_field]:
attendee_obj = self.pool.get('basic.calendar.attendee')
vevent = attendee_obj.export_ical(cr, uid, data[map_field], vevent, context=context)
- elif field == 'valarm' and data[map_field]:
+ elif field == 'valarm' and data[map_field]:
alarm_obj = self.pool.get('basic.calendar.alarm')
vevent = alarm_obj.export_ical(cr, uid, data[map_field][0], vevent, context=context)
elif data[map_field]:
@@ -149,7 +149,7 @@ class CalDAV(object):
if self.__attribute__.get(field).has_key('mapping'):
for key1, val1 in self.ical_get(field, 'mapping').items():
if val1 == data[map_field]:
- vevent.add(field).value = key1
+ vevent.add(field).value = key1
return ical
def import_ical(self, cr, uid, ical_data):
@@ -238,7 +238,7 @@ class Event(CalDAV, osv.osv_memory):
}
def export_ical(self, cr, uid, datas, context={}):
return super(Event, self).export_ical(cr, uid, datas, 'vevent', context=context)
-
+
Event()
class ToDo(CalDAV, osv.osv_memory):
@@ -251,8 +251,8 @@ class ToDo(CalDAV, osv.osv_memory):
'description': None,
'dtstamp': None,
'dtstart': None,
- 'duration': None,
- 'due': None,
+ 'duration': None,
+ 'due': None,
'geo': None,
'last-mod ': None,
'location': None,
@@ -278,7 +278,7 @@ class ToDo(CalDAV, osv.osv_memory):
'rdate': None,
'rrule': None,
}
-
+
def export_ical(self, cr, uid, datas, context={}):
return super(ToDo, self).export_ical(cr, uid, datas, 'vtodo', context=context)
@@ -340,7 +340,7 @@ class Alarm(CalDAV, osv.osv_memory):
interval = alarm_data['trigger_interval']
occurs = alarm_data['trigger_occurs']
duration = (occurs == 'after' and alarm_data['trigger_duration']) \
- or -(alarm_data['trigger_duration'])
+ or -(alarm_data['trigger_duration'])
related = alarm_data['trigger_related']
trigger = valarm.add('TRIGGER')
trigger.params['related'] = [related.upper()]
@@ -357,7 +357,7 @@ class Alarm(CalDAV, osv.osv_memory):
valarm.add('ACTION').value = alarm_data['action']
- def import_ical(self, cr, uid, ical_data):
+ def import_ical(self, cr, uid, ical_data):
for child in ical_data.getChildren():
if child.name.lower() == 'trigger':
seconds = child.value.seconds
@@ -405,10 +405,11 @@ class Attendee(CalDAV, osv.osv_memory):
'language': None, # Use: 0-1 Specify the language for text values in a property or property parameter.
}
- def import_ical(self, cr, uid, ical_data):
+ def import_ical(self, cr, uid, ical_data):
for para in ical_data.params:
if para.lower() == 'cn':
- self.ical_set(para.lower(), ical_data.params[para][0]+':'+ ical_data.value, 'value')
+ self.ical_set(para.lower(), ical_data.params[para][0]+':'+ \
+ ical_data.value, 'value')
else:
self.ical_set(para.lower(), ical_data.params[para][0].lower(), 'value')
if not ical_data.params.get('CN'):
diff --git a/addons/caldav/common.py b/addons/caldav/common.py
index 63340dc4013..a96d40e2a9c 100644
--- a/addons/caldav/common.py
+++ b/addons/caldav/common.py
@@ -19,12 +19,13 @@
#
##############################################################################
+
+from datetime import datetime
from osv import fields, osv
from service import web_services
from tools.translate import _
import re
import time
-import datetime
months = {
1:"January", 2:"February", 3:"March", 4:"April", \
@@ -109,7 +110,7 @@ class calendar_attendee(osv.osv):
for attdata in self.browse(cr, uid, ids, context=context):
id = attdata.id
- result[id] = {}
+ result[id] = {}
if name == 'sent_by':
if not attdata.sent_by_uid:
result[id][name] = ''
@@ -118,7 +119,12 @@ class calendar_attendee(osv.osv):
result[id][name] = self._get_address(attdata.sent_by_uid.name, \
attdata.sent_by_uid.address_id.email)
if name == 'cn':
- result[id][name] = self._get_address(attdata.user_id.name, attdata.email)
+ if attdata.user_id:
+ result[id][name] = self._get_address(attdata.user_id.name, attdata.email)
+ elif attdata.partner_address_id:
+ result[id][name] = self._get_address(attdata.partner_id.name, attdata.email)
+ else:
+ result[id][name] = self._get_address(None, attdata.email)
if name == 'delegated_to':
user_obj = self.pool.get('res.users')
todata = map(get_delegate_data, attdata.del_to_user_ids)
@@ -131,21 +137,21 @@ class calendar_attendee(osv.osv):
if name == 'event_date':
if attdata.ref:
model, res_id = tuple(attdata.ref.split(','))
- model_obj = self.pool.get(model)
- obj = model_obj.read(cr, uid, res_id, ['date'])[0]
+ model_obj = self.pool.get(model)
+ obj = model_obj.read(cr, uid, res_id, ['date'])[0]
result[id][name] = obj['date']
if name == 'event_end_date':
if attdata.ref:
model, res_id = tuple(attdata.ref.split(','))
- model_obj = self.pool.get(model)
- obj = model_obj.read(cr, uid, res_id, ['date_deadline'])[0]
+ model_obj = self.pool.get(model)
+ obj = model_obj.read(cr, uid, res_id, ['date_deadline'])[0]
result[id][name] = obj['date_deadline']
if name == 'sent_by_uid':
if attdata.ref:
model, res_id = tuple(attdata.ref.split(','))
- model_obj = self.pool.get(model)
- obj = model_obj.read(cr, uid, res_id, ['user_id'])[0]
+ model_obj = self.pool.get(model)
+ obj = model_obj.read(cr, uid, res_id, ['user_id'])[0]
result[id][name] = obj['user_id']
return result
@@ -184,12 +190,12 @@ class calendar_attendee(osv.osv):
help="Indicats whether the favor of a reply is requested"),
'delegated_to': fields.function(_compute_data, method=True, \
string='Delegated To', type="char", size=124, store=True, \
- multi='delegated_to', help="The users that the original request \
- was delegated to"),
- 'del_to_user_ids': fields.many2many('res.users', 'att_del_to_user_rel',
+ multi='delegated_to', help="The users that the original \
+request was delegated to"),
+ 'del_to_user_ids': fields.many2many('res.users', 'att_del_to_user_rel',
'attendee_id', 'user_id', 'Users'),
'delegated_from': fields.function(_compute_data, method=True, string=\
- 'Delegated From', type="char", store=True, size=124, multi='delegated_from'),
+ 'Delegated From', type="char", store=True, size=124, multi='delegated_from'),
'del_from_user_ids': fields.many2many('res.users', 'att_del_from_user_rel', \
'attendee_id', 'user_id', 'Users'),
'sent_by': fields.function(_compute_data, method=True, string='Sent By', type="char", multi='sent_by', store=True, size=124, help="Specify the user that is acting on behalf of the calendar user"),
@@ -198,15 +204,17 @@ class calendar_attendee(osv.osv):
'dir': fields.char('URI Reference', size=124, help="Reference to the URI that points to the directory information corresponding to the attendee."),
'language': fields.selection(_lang_get, 'Language',
help="To specify the language for text values in a property or property parameter."),
- 'user_id': fields.many2one('res.users', 'User'),
- 'email': fields.char('Email', size=124),
- 'event_date' : fields.function(_compute_data, method=True, string='Event Date', type="datetime", multi='event_date'),
- 'event_end_date' : fields.function(_compute_data, method=True, string='Event End Date', type="datetime", multi='event_end_date'),
- 'ref': fields.reference('Document Ref', selection=_links_get, size=128),
- 'availability': fields.selection([('free', 'Free'), ('busy', 'Busy')], 'Free/Busy', readonly="True"),
+ 'user_id': fields.many2one('res.users', 'User'),
+ 'partner_address_id': fields.many2one('res.partner.address', 'Contact'),
+ 'partner_id':fields.related('partner_address_id', 'partner_id', type='many2one', relation='res.partner', string='Partner'),
+ 'email': fields.char('Email', size=124),
+ 'event_date' : fields.function(_compute_data, method=True, string='Event Date', type="datetime", multi='event_date'),
+ 'event_end_date' : fields.function(_compute_data, method=True, string='Event End Date', type="datetime", multi='event_end_date'),
+ 'ref': fields.reference('Document Ref', selection=_links_get, size=128),
+ 'availability': fields.selection([('free', 'Free'), ('busy', 'Busy')], 'Free/Busy', readonly="True"),
}
_defaults = {
- 'state': lambda *x: 'needs-action',
+ 'state': lambda *x: 'needs-action',
}
def onchange_user_id(self, cr, uid, ids, user_id, *args, **argv):
@@ -287,12 +295,12 @@ or contains the text to be used for display"""),
'attach': fields.binary('Attachment', help="""* Points to a sound resource, which is rendered when the alarm is triggered for audio,
* File which is intended to be sent as message attachments for email,
* Points to a procedure resource, which is invoked when the alarm is triggered for procedure."""),
- 'res_id' : fields.integer('Resource ID'),
- 'model_id': fields.many2one('ir.model', 'Model'),
- 'user_id': fields.many2one('res.users', 'Owner'),
- 'event_date' : fields.datetime('Event Date'),
- 'event_end_date' : fields.datetime('Event End Date'),
- 'trigger_date' : fields.datetime('Trigger Date', readonly="True"),
+ 'res_id' : fields.integer('Resource ID'),
+ 'model_id': fields.many2one('ir.model', 'Model'),
+ 'user_id': fields.many2one('res.users', 'Owner'),
+ 'event_date' : fields.datetime('Event Date'),
+ 'event_end_date' : fields.datetime('Event End Date'),
+ 'trigger_date' : fields.datetime('Trigger Date', readonly="True"),
'state':fields.selection([
('draft', 'Draft'),
('run', 'Run'),
@@ -306,10 +314,10 @@ or contains the text to be used for display"""),
'state' : lambda *x: 'run',
}
- def create(self, cr, uid, vals, context={}):
+ def create(self, cr, uid, vals, context={}):
event_date = vals.get('event_date', False)
if event_date:
- dtstart = datetime.datetime.strptime(vals['event_date'], "%Y-%m-%d %H:%M:%S")
+ dtstart = datetime.strptime(vals['event_date'], "%Y-%m-%d %H:%M:%S")
if vals['trigger_interval'] == 'days':
delta = datetime.timedelta(days=vals['trigger_duration'])
if vals['trigger_interval'] == 'hours':
@@ -325,7 +333,7 @@ or contains the text to be used for display"""),
context=None):
if not context:
context = {}
- current_datetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+ current_datetime = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
cr.execute("select alarm.id as id \
from calendar_alarm alarm \
where alarm.state = %s and alarm.trigger_date <= %s", ('run', current_datetime))
@@ -363,7 +371,8 @@ or contains the text to be used for display"""),
%s
%s
- """ %(alarm.name, alarm.trigger_date, alarm.description, alarm.user_id.name, alarm.user_id.sign)
+ """ %(alarm.name, alarm.trigger_date, alarm.description, \
+ alarm.user_id.name, alarm.user_id.sign)
mail_to = [alarm.user_id.address_id.email]
for att in alarm.attendee_ids:
mail_to.append(att.user_id.address_id.email)
@@ -396,34 +405,34 @@ class ir_attachment(osv.osv):
if arg[0] == 'res_id':
new_args[i] = (arg[0], arg[1], caldav_id2real_id(arg[2]))
return super(ir_attachment, self).search(cr, uid, new_args, offset=offset,
- limit=limit, order=order,
- context=context, count=False)
+ limit=limit, order=order,
+ context=context, count=False)
ir_attachment()
class ir_values(osv.osv):
_inherit = 'ir.values'
- def set(self, cr, uid, key, key2, name, models, value, replace=True, isobject=False, \
- meta=False, preserve_user=False, company=False):
+ def set(self, cr, uid, key, key2, name, models, value, replace=True, \
+ isobject=False, meta=False, preserve_user=False, company=False):
new_model = []
for data in models:
if type(data) in (list, tuple):
new_model.append((data[0], caldav_id2real_id(data[1])))
else:
new_model.append(data)
- return super(ir_values, self).set(cr, uid, key, key2, name, new_model, value, \
- replace, isobject, meta, preserve_user, company)
+ return super(ir_values, self).set(cr, uid, key, key2, name, new_model,\
+ value, replace, isobject, meta, preserve_user, company)
- def get(self, cr, uid, key, key2, models, meta=False, context={}, res_id_req=False, \
- without_user=True, key2_req=True):
+ def get(self, cr, uid, key, key2, models, meta=False, context={},\
+ res_id_req=False, without_user=True, key2_req=True):
new_model = []
for data in models:
if type(data) in (list, tuple):
new_model.append((data[0], caldav_id2real_id(data[1])))
else:
new_model.append(data)
- return super(ir_values, self).get(cr, uid, key, key2, new_model, meta, context, \
- res_id_req, without_user, key2_req)
+ return super(ir_values, self).get(cr, uid, key, key2, new_model, \
+ meta, context, res_id_req, without_user, key2_req)
ir_values()
@@ -433,7 +442,8 @@ class ir_model(osv.osv):
def read(self, cr, uid, ids, fields=None, context={},
load='_classic_read'):
- data = super(ir_model, self).read(cr, uid, ids, fields=fields, context=context, load=load)
+ data = super(ir_model, self).read(cr, uid, ids, fields=fields, \
+ context=context, load=load)
if data:
for val in data:
val['id'] = caldav_id2real_id(val['id'])
@@ -445,7 +455,8 @@ class virtual_report_spool(web_services.report_spool):
def exp_report(self, db, uid, object, ids, datas=None, context=None):
if object == 'printscreen.list':
- return super(virtual_report_spool, self).exp_report(db, uid, object, ids, datas, context)
+ return super(virtual_report_spool, self).exp_report(db, uid, \
+ object, ids, datas, context)
new_ids = []
for id in ids:
new_ids.append(caldav_id2real_id(id))
@@ -481,9 +492,9 @@ class calendar_custom_rrule(osv.osv):
('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'),
+ ('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'),
@@ -516,7 +527,7 @@ class calendar_custom_rrule(osv.osv):
weekstring = ';BYDAY=' + ','.join(byday)
elif freq == 'monthly':
- if datas.get('select1')=='date' and (datas.get('day') < 1 or datas.get('day') > 31):
+ 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')
@@ -544,42 +555,59 @@ class calendar_custom_rrule(osv.osv):
# 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'
-
+
def _get_user_avail(self, cr, uid, ids, context=None):
- current_datetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
- res = {}
+ current_datetime = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+ res = {}
attendee_obj = self.pool.get('calendar.attendee')
attendee_ids = attendee_obj.search(cr, uid, [
- ('event_date','<=',current_datetime), ('event_end_date','<=',current_datetime),
- ('state','=','accepted'), ('user_id','in',ids)
+ ('event_date', '<=', current_datetime), ('event_end_date', '<=', current_datetime),
+ ('state', '=', 'accepted'), ('user_id', 'in', ids)
])
-
+
result = cr.dictfetchall()
for attendee_data in attendee_obj.read(cr, uid, attendee_ids, ['user_id']):
user_id = attendee_data['user_id']
status = 'busy'
res.update({user_id:status})
-
+
#TOCHECK : Delegrated Event
#cr.execute("SELECT user_id,'busy' FROM att_del_to_user_rel where user_id = ANY(%s)", (ids,))
- #res.update(cr.dictfetchall())
+ #res.update(cr.dictfetchall())
for user_id in ids:
if user_id not in res:
res[user_id] = 'free'
-
+
return res
- def _get_user_avail_fun(self, cr, uid, ids, name, args, context=None):
+ def _get_user_avail_fun(self, cr, uid, ids, name, args, context=None):
return self._get_user_avail(cr, uid, ids, context=context)
-
+
_columns = {
'availability': fields.function(_get_user_avail_fun, type='selection', \
selection=[('free', 'Free'), ('busy', 'Busy')], \
- string='Free/Busy', method=True),
+ string='Free/Busy', method=True),
}
res_users()
@@ -591,16 +619,12 @@ class invite_attendee_wizard(osv.osv_memory):
'type': fields.selection([('internal', 'Internal User'), \
('external', 'External Email'), \
('partner', 'Partner Contacts')], 'Type', required=True),
- 'user_ids': fields.many2many('res.users', 'invite_user_rel',
+ 'user_ids': fields.many2many('res.users', 'invite_user_rel',
'invite_id', 'user_id', 'Users'),
'partner_id': fields.many2one('res.partner', 'Partner'),
- 'email': fields.char('Email', size=124),
- 'contact_ids': fields.many2many('res.partner.address', 'invite_contact_rel',
+ 'email': fields.char('Email', size=124),
+ 'contact_ids': fields.many2many('res.partner.address', 'invite_contact_rel',
'invite_id', 'contact_id', 'Contacts'),
- 'role': fields.selection([ ('REQ-PARTICIPANT', 'REQ-PARTICIPANT'), \
- ('CHAIR', 'CHAIR'), ('OPT-PARTICIPANT', 'OPT-PARTICIPANT'), \
- ('NON-PARTICIPANT', 'NON-PARTICIPANT')], 'Role', \
- help='Participation role for the calendar user'),
}
def do_invite(self, cr, uid, ids, context={}):
@@ -625,18 +649,22 @@ class invite_attendee_wizard(osv.osv_memory):
'email': user.address_id.email})
att_id = att_obj.create(cr, uid, vals)
obj.write(cr, uid, res_obj.id, {'attendee_ids': [(4, att_id)]})
+
elif type == 'external' and datas.get('email'):
vals.update({'email': datas['email']})
att_id = att_obj.create(cr, uid, vals)
obj.write(cr, uid, res_obj.id, {'attendee_ids': [(4, att_id)]})
+
elif type == 'partner':
add_obj = self.pool.get('res.partner.address')
for contact in add_obj.browse(cr, uid, datas['contact_ids']):
- vals.update({'email': contact.email})
+ vals.update({
+ 'partner_address_id': contact.id,
+ 'email': contact.email})
att_id = att_obj.create(cr, uid, vals)
obj.write(cr, uid, res_obj.id, {'attendee_ids': [(4, att_id)]})
return {}
-
+
def onchange_partner_id(self, cr, uid, ids, partner_id, *args, **argv):
if not partner_id:
@@ -647,7 +675,7 @@ class invite_attendee_wizard(osv.osv_memory):
if not contacts:
raise osv.except_osv(_('Error!'), \
("Partner does not have any Contacts"))
-
+
return {'value': {'contact_ids': contacts}}
invite_attendee_wizard()
diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py
index b506beed77b..cbdb7998a38 100644
--- a/addons/crm/crm_meeting.py
+++ b/addons/crm/crm_meeting.py
@@ -20,36 +20,29 @@
##############################################################################
from caldav import common
+from datetime import datetime, timedelta
+from dateutil import parser
from osv import fields, osv
-import datetime
+from tools.translate import _
import base64
import re
import time
import tools
-from tools.translate import _
-from dateutil import parser
class crm_meeting_categ(osv.osv):
_name = "crm.meeting.categ"
_description = "Category of Meetings"
_columns = {
- 'name': fields.char('Meeting Category Name', size=64, required=True, translate=True),
- 'probability': fields.float('Probability (%)', required=True),
- 'section_id': fields.many2one('crm.case.section', 'Case Section'),
+ 'name': fields.char('Meeting Category Name', size=64, required=True, \
+ translate=True),
+ 'probability': fields.float('Probability (%)', required=True),
+ 'section_id': fields.many2one('crm.case.section', 'Case Section'),
}
_defaults = {
'probability': lambda *args: 0.0
}
crm_meeting_categ()
-class rrule_wizard(osv.osv):
- _inherit = "calendar.custom.rrule"
-
- _columns = {
- 'case_id':fields.many2one('crm.case','Case'),
- }
-rrule_wizard()
-
class crm_meeting(osv.osv):
_name = 'crm.meeting'
_description = "Meeting Cases"
@@ -64,10 +57,11 @@ class crm_meeting(osv.osv):
'location': {'field': 'location', 'type': 'text'},
#'organizer': {'field': 'partner_id', 'sub-field': 'name', 'type': 'many2one'},
'priority': {'field': 'priority', 'type': 'int'},
- 'dtstamp' : {'field': 'date', 'type': 'datetime'},
+ 'dtstamp': {'field': 'date', 'type': 'datetime'},
'seq': None,
- 'status': {'field': 'state', 'type': 'selection', 'mapping': {'tentative': 'draft', \
- 'confirmed': 'open' , 'cancelled': 'cancel'}},
+ 'status': {'field': 'state', 'type': 'selection', 'mapping': \
+ {'tentative': 'draft', 'confirmed': 'open', \
+ 'cancelled': 'cancel'}},
'summary': {'field': 'name', 'type': 'text'},
'transp': {'field': 'transparent', 'type': 'text'},
'uid': {'field': 'id', 'type': 'text'},
@@ -75,129 +69,112 @@ class crm_meeting(osv.osv):
'recurid': None,
# 'attach': {'field': 'attachment_ids', 'sub-field': 'datas', 'type': 'list'},
'attendee': {'field': 'attendee_ids', 'type': 'many2many', 'object': 'crm.caldav.attendee'},
-# 'categories': {'field': 'categ_id', 'sub-field': 'name'},
'categories': {'field': 'categ_id', 'type': 'many2one', 'object': 'crm.meeting.categ'},
'comment': None,
'contact': None,
- 'exdate' : {'field': 'exdate', 'type': 'datetime'},
- 'exrule' : {'field': 'exrule', 'type': 'text'},
+ 'exdate': {'field': 'exdate', 'type': 'datetime'},
+ 'exrule': {'field': 'exrule', 'type': 'text'},
'rstatus': None,
'related': None,
'resources': None,
'rdate': None,
'rrule': {'field': 'rrule', 'type': 'text'},
'x-openobject-model': {'value': _name, 'type': 'text'},
-# 'duration': {'field': 'duration'},
'dtend': {'field': 'date_deadline', 'type': 'datetime'},
'valarm': {'field': 'caldav_alarm_id', 'type': 'many2one', 'object': 'calendar.alarm'},
}
def _get_duration(self, cr, uid, ids, name, arg, context):
res = {}
- for id in ids:
- meeting = self.browse(cr, uid, id, context=context)
- start = datetime.datetime.strptime(meeting.date, "%Y-%m-%d %H:%M:%S")
- end = datetime.datetime.strptime(meeting.date_deadline[:19], "%Y-%m-%d %H:%M:%S")
+ for meeting in self.browse(cr, uid, ids, context=context):
+ start = datetime.strptime(meeting.date, "%Y-%m-%d %H:%M:%S")
+ end = datetime.strptime(meeting.date_deadline[:19], "%Y-%m-%d %H:%M:%S")
diff = end - start
duration = float(diff.days)* 24 + (float(diff.seconds) / 3600)
- res[id] = round(duration, 2)
+ res[meeting.id] = round(duration, 2)
return res
-
+
def _set_duration(self, cr, uid, id, name, value, arg, context):
meeting = self.browse(cr, uid, id, context=context)
- start = datetime.datetime.strptime(meeting.date, "%Y-%m-%d %H:%M:%S")
- end = start + datetime.timedelta(hours=value)
+ start = datetime.strptime(meeting.date, "%Y-%m-%d %H:%M:%S")
+ end = start + timedelta(hours=value)
cr.execute("UPDATE crm_meeting set date_deadline='%s' \
- where id=%s"% (end.strftime("%Y-%m-%d %H:%M:%S"), id))
+ where id=%s"% (end.strftime("%Y-%m-%d %H:%M:%S"), id))
return True
-
- def _get_rrule(self, cr, uid, ids, name, arg, context):
- res = {}
- rrule_obj = self.pool.get('calendar.custom.rrule')
- for id in ids:
- meeting = self.browse(cr, uid, id, context=context)
- type = meeting.rrule_type
- if type == 'none' or not type:
- res[id] = ''
- cr.execute('DELETE from calendar_custom_rrule where case_id=%s' % (id))
- elif type != 'custom':
- rrule = self.pool.get('calendar.custom.rrule')
- rrulestr = rrule.compute_rule_string(cr, uid, {'freq': type.upper(),\
- 'interval': 1})
- res[id] = rrulestr
- cr.execute('DELETE from calendar_custom_rrule where case_id=%s' % (id))
- elif type == 'custom':
- for rrule in meeting.rule_ids:
- rule_datas = rrule_obj.read(cr, uid, rrule.id)
- rulestr = rrule_obj.compute_rule_string(cr, uid, rule_datas)
- res[id] = rulestr
- cr.commit()
- return res
-
+
+ def onchange_rrule_type(self, cr, uid, ids, type, *args, **argv):
+ if type == 'none':
+ return {'value': {'rrule': ''}}
+ if type == 'custom':
+ return {}
+ rrule = self.pool.get('calendar.custom.rrule')
+ rrulestr = rrule.compute_rule_string(cr, uid, {'freq': type.upper(), \
+ 'interval': 1})
+ return {'value': {'rrule': rrulestr}}
+
_columns = {
- 'name': fields.char('Description',size=64,required=True),
- 'section_id': fields.many2one('crm.case.section', 'Section', select=True, help='Section to which Case belongs to. Define Responsible user and Email account for mail gateway.'),
- 'date': fields.datetime('Date'),
- 'date_deadline': fields.datetime('Deadline'),
+ 'name': fields.char('Description', size=64, required=True),
+ 'section_id': fields.many2one('crm.case.section', 'Section', select=True, help='Section to which Case belongs to. Define Responsible user and Email \
+account for mail gateway.'),
+ 'date': fields.datetime('Date'),
+ 'date_deadline': fields.datetime('Deadline'),
'duration': fields.function(_get_duration, method=True, \
fnct_inv=_set_duration, string='Duration'),
'categ_id': fields.many2one('crm.meeting.categ', 'Category', \
domain="[('section_id','=',section_id)]", \
help='Category related to the section.Subdivide the CRM cases \
independently or section-wise.'),
- 'description': fields.text('Your action'),
+ 'description': fields.text('Your action'),
'class': fields.selection([('public', 'Public'), ('private', 'Private'), \
('confidential', 'Confidential')], 'Mark as'),
- 'location': fields.char('Location', size=264, help="Gives Location of Meeting"),
+ 'location': fields.char('Location', size=264, help="Location of Meeting"),
'show_as': fields.selection([('free', 'Free'), \
('busy', 'Busy')],
'Show as'),
'caldav_url': fields.char('Caldav URL', size=264),
- 'exdate': fields.text('Exception Date/Times', help="This property 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.function(_get_rrule, string='Recurrent Rule', method=True,\
- store=True, type='char', size=124),
- 'rrule_type' : fields.selection([('none', 'None'), ('daily', 'Daily'), \
- ('weekly', 'Weekly'), ('monthly', 'Monthly'), ('yearly', 'Yearly'), ('custom', 'Custom')], 'Recurrency'),
- 'attendee_ids': fields.many2many('calendar.attendee', 'crm_attendee_rel', 'case_id', \
- 'attendee_id', 'Attendees'),
+ 'exdate': fields.text('Exception Date/Times', help="This property \
+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_type': fields.selection([('none', 'None'), ('daily', 'Daily'), \
+ ('weekly', 'Weekly'), ('monthly', 'Monthly'), \
+ ('yearly', 'Yearly'), ('custom', 'Custom')], 'Recurrency'),
+ 'attendee_ids': fields.many2many('calendar.attendee', 'crm_attendee_rel', 'case_id', 'attendee_id', 'Attendees'),
'alarm_id': fields.many2one('res.alarm', 'Alarm'),
'caldav_alarm_id': fields.many2one('calendar.alarm', 'Alarm'),
- 'rule_ids': fields.one2many('calendar.custom.rrule', 'case_id', 'Rules'),
}
_defaults = {
'class': lambda *a: 'public',
- 'show_as' : lambda *a : 'busy',
+ 'show_as': lambda *a: 'busy',
}
def do_alarm_create(self, cr, uid, ids, context={}):
alarm_obj = self.pool.get('calendar.alarm')
model_obj = self.pool.get('ir.model')
- model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
+ model_id = model_obj.search(cr, uid, [('model', '=', self._name)])[0]
for meeting in self.browse(cr, uid, ids):
self.do_alarm_unlink(cr, uid, [meeting.id])
basic_alarm = meeting.alarm_id
if basic_alarm:
vals = {
- 'action': 'display',
- 'description': meeting.description,
- 'name': meeting.name,
- 'attendee_ids': [(6,0, map(lambda x:x.id, meeting.attendee_ids))],
- 'trigger_related': basic_alarm.trigger_related,
- 'trigger_duration': basic_alarm.trigger_duration,
- 'trigger_occurs': basic_alarm.trigger_occurs,
- 'trigger_interval': basic_alarm.trigger_interval,
- 'duration': basic_alarm.duration,
- 'repeat': basic_alarm.repeat,
- 'state' : 'run',
- 'event_date' : meeting.date,
- 'res_id' : meeting.id,
- 'model_id' : model_id,
- 'user_id' : uid
+ 'action': 'display',
+ 'description': meeting.description,
+ 'name': meeting.name,
+ 'attendee_ids': [(6, 0, map(lambda x:x.id, meeting.attendee_ids))],
+ 'trigger_related': basic_alarm.trigger_related,
+ 'trigger_duration': basic_alarm.trigger_duration,
+ 'trigger_occurs': basic_alarm.trigger_occurs,
+ 'trigger_interval': basic_alarm.trigger_interval,
+ 'duration': basic_alarm.duration,
+ 'repeat': basic_alarm.repeat,
+ 'state': 'run',
+ 'event_date': meeting.date,
+ 'res_id': meeting.id,
+ 'model_id': model_id,
+ 'user_id': uid
}
alarm_id = alarm_obj.create(cr, uid, vals)
cr.execute('Update crm_meeting set caldav_alarm_id=%s \
@@ -208,9 +185,9 @@ independently or section-wise.'),
def do_alarm_unlink(self, cr, uid, ids, context={}):
alarm_obj = self.pool.get('calendar.alarm')
model_obj = self.pool.get('ir.model')
- model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
+ model_id = model_obj.search(cr, uid, [('model', '=', self._name)])[0]
for meeting in self.browse(cr, uid, ids):
- alarm_ids = alarm_obj.search(cr, uid, [('model_id','=',model_id), ('res_id','=',meeting.id)])
+ alarm_ids = alarm_obj.search(cr, uid, [('model_id', '=', model_id), ('res_id', '=', meeting.id)])
if alarm_ids and len(alarm_ids):
alarm_obj.unlink(cr, uid, alarm_ids)
cr.execute('Update crm_meeting set caldav_alarm_id=NULL, \
@@ -221,20 +198,20 @@ independently or section-wise.'),
def on_change_duration(self, cr, uid, id, date, duration):
if not date:
return {}
- start_date = datetime.datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
- if duration >= 0 :
+ start_date = datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
+ if duration >= 0:
end = start_date + datetime.timedelta(hours=duration)
if duration < 0:
- raise osv.except_osv(_('Warning !'),
+ raise osv.except_osv(_('Warning !'),
_('You can not set negative Duration.'))
- res = {'value' : {'date_deadline' : end.strftime('%Y-%m-%d %H:%M:%S')}}
+ res = {'value': {'date_deadline': end.strftime('%Y-%m-%d %H:%M:%S')}}
return res
def export_cal(self, cr, uid, ids, context={}):
+ ids = map(lambda x: common.caldav_id2real_id(x), ids)
crm_data = self.read(cr, uid, ids)
event_obj = self.pool.get('basic.calendar.event')
event_obj.__attribute__.update(self.__attribute__)
-
ical = event_obj.export_ical(cr, uid, crm_data, {'model': self._name})
cal_val = ical.serialize()
cal_val = cal_val.replace('"', '').strip()
@@ -269,16 +246,17 @@ independently or section-wise.'),
ids = select
result = []
if ids and (base_start_date or base_until_date):
- cr.execute("select m.id, m.rrule, m.date, m.exdate from crm_meeting m\
+ cr.execute("select m.id, m.rrule, m.date, m.exdate \
+ from crm_meeting m\
where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")")
count = 0
for data in cr.dictfetchall():
- start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False
- until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False
+ start_date = base_start_date and datetime.strptime(base_start_date, "%Y-%m-%d") or False
+ until_date = base_until_date and datetime.strptime(base_until_date, "%Y-%m-%d") or False
if count > limit:
break
- event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S")
+ event_date = datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S")
if start_date and start_date <= event_date:
start_date = event_date
if not data['rrule']:
@@ -314,10 +292,10 @@ independently or section-wise.'),
new_rule = '%s=%s' % (name, value)
new_rrule_str.append(new_rule)
new_rrule_str = ';'.join(new_rrule_str)
- start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S")
+ start_date = datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S")
rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date)
for rdate in rdates:
- r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S")
+ r_date = datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S")
if start_date and r_date < start_date:
continue
if until_date and r_date > until_date:
@@ -331,7 +309,7 @@ independently or section-wise.'),
return ids and ids[0] or False
return ids
- def search(self, cr, uid, args, offset=0, limit=100, order=None,
+ def search(self, cr, uid, args, offset=0, limit=100, order=None,
context=None, count=False):
args_without_date = []
start_date = False
@@ -344,7 +322,7 @@ independently or section-wise.'),
start_date = arg[2]
elif arg[1] in ('<', '<='):
until_date = arg[2]
- res = super(crm_meeting, self).search(cr, uid, args_without_date, offset,
+ res = super(crm_meeting, self).search(cr, uid, args_without_date, offset,
limit, order, context, count)
return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)
@@ -399,8 +377,7 @@ independently or section-wise.'),
return result
def copy(self, cr, uid, id, default=None, context={}):
- res = super(crm_meeting, self).copy(cr, uid, common.caldav_id2real_id(id), \
- default, context)
+ res = super(crm_meeting, self).copy(cr, uid, common.caldav_id2real_id(id), default, context)
self.do_alarm_create(cr, uid, [res])
return res
@@ -434,33 +411,16 @@ independently or section-wise.'),
return res
- def onchange_case_id(self, cr, uid, ids, *args, **argv):
- return self._map_ids('onchange_case_id', cr, uid, ids, *args, **argv)
- def onchange_partner_id(self, cr, uid, ids, *args, **argv):
- return self._map_ids('onchange_partner_id', cr, uid, ids, *args, **argv)
- def onchange_partner_address_id(self, cr, uid, ids, *args, **argv):
- return self._map_ids('onchange_partner_address_id', cr, uid, ids, *args, **argv)
- def onchange_categ_id(self, cr, uid, ids, *args, **argv):
- return self._map_ids('onchange_categ_id', cr, uid, ids, *args, **argv)
- def case_close(self, cr, uid, ids, *args, **argv):
- return self._map_ids('case_close', cr, uid, ids, *args, **argv)
- def case_open(self, cr, uid, ids, *args, **argv):
- return self._map_ids('case_open', cr, uid, ids, *args, **argv)
- def case_cancel(self, cr, uid, ids, *args, **argv):
- return self._map_ids('case_cancel', cr, uid, ids, *args, **argv)
- def case_reset(self, cr, uid, ids, *args, **argv):
- return self._map_ids('case_reset', cr, uid, ids, *args, **argv)
-
def msg_new(self, cr, uid, msg):
mailgate_obj = self.pool.get('mail.gateway')
msg_body = mailgate_obj.msg_body_get(msg)
data = {
- 'name': msg['Subject'],
- 'email_from': msg['From'],
- 'email_cc': msg['Cc'],
- 'user_id': False,
- 'description': msg_body['body'],
- 'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })],
+ 'name': msg['Subject'],
+ 'email_from': msg['From'],
+ 'email_cc': msg['Cc'],
+ 'user_id': False,
+ 'description': msg_body['body'],
+ 'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })],
}
res = mailgate_obj.partner_get(cr, uid, msg['From'])
if res:
@@ -468,13 +428,6 @@ independently or section-wise.'),
res = self.create(cr, uid, data)
return res
- def msg_update(self, cr, uid, ids, *args, **argv):
- return self._map_ids('msg_update', cr, uid, ids, *args, **argv)
- def emails_get(self, cr, uid, ids, *args, **argv):
- return self._map_ids('emails_get', cr, uid, ids, *args, **argv)
- def msg_send(self, cr, uid, ids, *args, **argv):
- return self._map_ids('msg_send', cr, uid, ids, *args, **argv)
-
crm_meeting()
@@ -482,8 +435,8 @@ class crm_meeting_generic_wizard(osv.osv_memory):
_name = 'crm.meeting.generic_wizard'
_columns = {
- 'section_id': fields.many2one('crm.case.section', 'Section', required=False),
- 'user_id': fields.many2one('res.users', 'Responsible'),
+ 'section_id': fields.many2one('crm.case.section', 'Section', required=False),
+ 'user_id': fields.many2one('res.users', 'Responsible'),
}
def _get_default_section(self, cr, uid, context):
@@ -500,6 +453,7 @@ class crm_meeting_generic_wizard(osv.osv_memory):
_defaults = {
'section_id': _get_default_section
}
+
def action_create(self, cr, uid, ids, context=None):
case_obj = self.pool.get('crm.meeting')
case_id = context.get('active_id', [])
@@ -507,23 +461,22 @@ class crm_meeting_generic_wizard(osv.osv_memory):
case = case_obj.browse(cr, uid, case_id)
if case.state in ('done'):
raise osv.except_osv(_('Error !'), _('You can not assign Closed Case.'))
- new_case_id = case_obj.copy(cr, uid, case_id, default=
- {
- 'section_id': res.get('section_id', False),
- 'user_id': res.get('user_id', False),
- 'case_id': case.inherit_case_id.id
- }, context=context)
+ new_case_id = case_obj.copy(cr, uid, case_id, default= {
+ 'section_id': res.get('section_id', False),
+ 'user_id': res.get('user_id', False),
+ 'case_id': case.inherit_case_id.id
+ }, context=context)
case_obj.case_close(cr, uid, [case_id])
data_obj = self.pool.get('ir.model.data')
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter')
search_view = data_obj.read(cr, uid, result, ['res_id'])
new_case = case_obj.read(cr, uid, new_case_id, ['id'])
value = {
- 'name': _('Meetings'),
- 'view_type': 'form',
- 'view_mode': 'calendar, tree, form',
- 'res_model': 'crm.meeting',
- 'type': 'ir.actions.act_window',
+ 'name': _('Meetings'),
+ 'view_type': 'form',
+ 'view_mode': 'calendar, tree, form',
+ 'res_model': 'crm.meeting',
+ 'type': 'ir.actions.act_window',
'search_view_id': search_view['res_id']
}
return value
@@ -533,13 +486,13 @@ crm_meeting_generic_wizard()
class res_users(osv.osv):
_inherit = 'res.users'
def _get_user_avail(self, cr, uid, ids, context=None):
- current_datetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+ current_datetime = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
res = super(res_users, self)._get_user_avail(cr, uid, ids, context)
cr.execute("SELECT m.user_id, 'busy' as status \
FROM crm_meeting m\
where m.date <= %s and m.date_deadline >= %s \
- and m.user_id = ANY(%s) and m.show_as = %s",
- (current_datetime, current_datetime , ids, 'busy'))
+ and m.user_id = ANY(%s) and m.show_as = %s",
+ (current_datetime, current_datetime, ids, 'busy'))
result = cr.dictfetchall()
for user_data in result:
user_id = user_data['user_id']
diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml
index 16b3fcc4c4f..4ded3780fc8 100644
--- a/addons/crm/crm_meeting_view.xml
+++ b/addons/crm/crm_meeting_view.xml
@@ -51,11 +51,16 @@
-
-
-
-
+
+
+
+
@@ -68,7 +73,31 @@
icon="terp-partner" type="action"
context="{'model' : 'crm.meeting'}" colspan="2"/>
+ nolabel="1" widget="one2many" mode="tree,form">
+
+
+
+
+
+
+
@@ -76,7 +105,7 @@
-
+