[MERGE] with addons 1 improvement meeting recurrent

bzr revid: tfr@openerp.com-20110118224539-m6j3iv8o0jxg175m
This commit is contained in:
Thibault Francois 2011-01-18 23:45:39 +01:00
commit 019c02eaf0
12 changed files with 54 additions and 28 deletions

View File

@ -30,6 +30,7 @@ import re
import time
import tools
months = {
1: "January", 2: "February", 3: "March", 4: "April", \
5: "May", 6: "June", 7: "July", 8: "August", 9: "September", \
@ -1080,8 +1081,6 @@ class calendar_event(osv.osv):
for datas in self.read(cr, uid, ids, context=context):
event = datas['id']
if datas.get('rrule_type'):
if datas['rrule_type']=='daily_working':
datas.update({'rrule_type': 'weekly'})
if datas.get('rrule_type') == 'none':
result[event] = False
cr.execute("UPDATE %s set exrule=Null where id=%%s" % self._table,( event,))
@ -1256,7 +1255,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
ids = select
result = []
recur_dict = []
if ids and (base_start_date or base_until_date):
if ids:
cr.execute("select m.id, m.rrule, m.date, m.date_deadline, m.duration, \
m.exdate, m.exrule, m.recurrent_id, m.recurrent_uid from " + self._table + \
" m where m.id = ANY(%s)", (ids,) )
@ -1425,19 +1424,25 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
new_ids = []
res = False
for event_id in select:
real_event_id = base_calendar_id2real_id(event_id)
if len(str(event_id).split('-')) > 1:
real_event_id = base_calendar_id2real_id(event_id)
event = self.browse(cr,uid, event_id, context=context)
if('edit_all' in vals):
edit_all = vals['edit_all']
else:
edit_all = event.edit_all or not event.recurrency
if not edit_all:
data = self.read(cr, uid, event_id, ['date', 'date_deadline', \
'rrule', 'duration'])
if data.get('rrule'):
data.update({
'recurrent_uid': real_event_id,
'recurrent_id': data.get('date'),
'rrule_type': 'none',
'rrule': ''
})
data.update(vals)
new_id = self.copy(cr, uid, real_event_id, default=data, context=context)
self.unlink(cr, uid, [event_id], context=context)
context.update({'active_id': new_id, 'active_ids': [new_id]})
continue
if not real_event_id in new_ids:
@ -1454,6 +1459,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
context=context)
vals.update(updated_vals.get('value', {}))
if new_ids:
res = super(calendar_event, self).write(cr, uid, new_ids, vals, context=context)
@ -1515,6 +1521,8 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
for base_calendar_id, real_id in select:
#REVET: Revision ID: olt@tinyerp.com-20100924131709-cqsd1ut234ni6txn
res = super(calendar_event, self).read(cr, uid, real_id, fields=fields, context=context, load=load)
if not res:
res = {}
ls = base_calendar_id2real_id(base_calendar_id, with_date=res and res.get('duration', 0) or 0)
if not isinstance(ls, (str, int, long)) and len(ls) >= 2:
res['date'] = ls[1]
@ -1553,8 +1561,9 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
@return: True
"""
res = False
for event_datas in self.read(cr, uid, ids, ['date', 'rrule', 'exdate'], context=context):
for event_datas in self.read(cr, uid, ids, ['date', 'rrule', 'exdate', 'edit_all'], context=context):
event_id = event_datas['id']
edit_all = event_datas.get('edit_all', False)
if isinstance(event_id, (int, long)):
res = super(calendar_event, self).unlink(cr, uid, event_id, context=context)
self.pool.get('res.alarm').do_alarm_unlink(cr, uid, [event_id], self._name)
@ -1562,12 +1571,12 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
else:
str_event, date_new = event_id.split('-')
event_id = int(str_event)
if event_datas['rrule']:
if event_datas['rrule'] and not edit_all:
# Remove one of the recurrent event
date_new = time.strftime("%Y%m%dT%H%M%S", \
time.strptime(date_new, "%Y%m%d%H%M%S"))
exdate = (event_datas['exdate'] and (event_datas['exdate'] + ',') or '') + date_new
res = self.write(cr, uid, [event_id], {'exdate': exdate})
res = super(calendar_event, self).write(cr, uid, [event_id], {'exdate': exdate})
else:
res = super(calendar_event, self).unlink(cr, uid, [event_id], context=context)
self.pool.get('res.alarm').do_alarm_unlink(cr, uid, [event_id], self._name)
@ -1601,7 +1610,8 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
res = super(calendar_event, self).create(cr, uid, vals, context)
alarm_obj = self.pool.get('res.alarm')
alarm_obj.do_alarm_create(cr, uid, [res], self._name, 'date', context=context)
return res
records = self.browse(cr, uid, [res], context=context)
return real_id2base_calendar_id(records[0].id, records[0].date)
def do_tentative(self, cr, uid, ids, context=None, *args):
""" Makes event invitation as Tentative

View File

@ -240,7 +240,7 @@
<field name="location" />
<field name="alarm_id" string="Reminder"
widget="selection" />
<group colspan="2" col="4" >
<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)"/>
@ -344,7 +344,7 @@
</form>
</field>
</page>
<page string="Recurrency Option" attrs="{'invisible':[('recurrency','=',False)]}">
<page string="Recurrency Option" attrs="{'invisible': [('recurrency','=',False)]}">
<group col="4" colspan="4" name="rrule">
<group col="4" colspan="4">
<field name="rrule_type" string="Recurrency period"

View File

@ -75,8 +75,8 @@ class crm_meeting(crm_case, osv.osv):
size=16, readonly=True),
}
_defaults = {
'state': lambda *a: 'draft',
'active': lambda *a: 1,
'state': 'draft',
'active': 1,
'user_id': lambda self, cr, uid, ctx: uid,
}

View File

@ -43,7 +43,7 @@
<field name="location" />
<field name="alarm_id" string="Reminder"
widget="selection" />
<group colspan="2" col="4" >
<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)"/>
@ -165,11 +165,10 @@
</form>
</field>
</page>
<page string="Recurrency Option" attrs="{'invisible':[('recurrency','=',False)]}">
<page string="Recurrency Option" attrs="{'invisible': [('recurrency','=',False)], 'readonly': [('state','=','done')}">
<group col="4" colspan="4" name="rrule">
<group col="4" colspan="4">
<field name="rrule_type" string="Recurrency period"
attrs="{'readonly':[('recurrent_uid','!=',False)]}" />
<field name="rrule_type" string="Recurrency period" />
<field name="interval" />

View File

@ -20,7 +20,6 @@
<field name="nbr" string="#Claim" sum="#Claim"/>
<field name="email" sum="# Mails"/>
<field name="delay_close" avg="Avg Closing Delay"/>
<field name="email"/>
<field name="probability" widget="progressbar"/>
<field name="delay_expected"/>
<field name="state" invisible="1"/>

View File

@ -126,7 +126,7 @@ class hr_holidays(osv.osv):
'notes': fields.text('Reasons',readonly=True, states={'draft':[('readonly',False)]}),
'number_of_days_temp': fields.float('Number of Days', readonly=True, states={'draft':[('readonly',False)]}),
'number_of_days': fields.function(_compute_number_of_days, method=True, string='Number of Days', store=True),
'case_id': fields.many2one('crm.meeting', 'Meeting'),
'case_id': fields.char('Meeting', size=64),
'type': fields.selection([('remove','Leave Request'),('add','Allocation Request')], 'Request Type', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="Choose 'Leave Request' if someone wants to take an off-day. \nChoose 'Allocation Request' if you want to increase the number of leaves available for someone"),
'parent_id': fields.many2one('hr.holidays', 'Parent'),
'linked_request_ids': fields.one2many('hr.holidays', 'parent_id', 'Linked Requests',),
@ -290,7 +290,7 @@ class hr_holidays(osv.osv):
for record in self.browse(cr, uid, ids):
# Delete the meeting
if record.case_id:
obj_crm_meeting.unlink(cr, uid, [record.case_id.id])
obj_crm_meeting.unlink(cr, uid, [record.case_id])
# If a category that created several holidays, cancel all related
wf_service = netsvc.LocalService("workflow")

View File

@ -476,8 +476,20 @@ class task(osv.osv):
ids = child_ids
return True
def _check_dates(self, cr, uid, ids, context=None):
if context == None:
context = {}
obj_task = self.browse(cr, uid, ids[0], context=context)
start = obj_task.date_start or False
end = obj_task.date_end or False
if start and end :
if start > end:
return False
return True
_constraints = [
(_check_recursion, 'Error ! You cannot create recursive tasks.', ['parent_ids'])
(_check_recursion, 'Error ! You cannot create recursive tasks.', ['parent_ids']),
(_check_dates, 'Error ! Task end-date must be greater then task start-date', ['date_start','date_end'])
]
#
# Override view according to the company definition
@ -541,6 +553,7 @@ class task(osv.osv):
"""
request = self.pool.get('res.request')
for task in self.browse(cr, uid, ids, context=context):
vals = {}
project = task.project_id
if project:
# Send request to project manager
@ -563,7 +576,11 @@ class task(osv.osv):
reopen = False
if reopen:
self.do_reopen(cr, uid, [parent_id.id])
self.write(cr, uid, [task.id], {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
vals.update({'state': 'done'})
vals.update({'remaining_hours': 0.0})
if not task.date_end:
vals.update({ 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')})
self.write(cr, uid, [task.id],vals)
message = _("The task '%s' is done") % (task.name,)
self.log(cr, uid, task.id, message)
return True

View File

@ -184,7 +184,7 @@ class survey_page(osv.osv):
if len(context['line_order'][-1]) > 2 and type(context['line_order'][-1][2]) == type({}) and context['line_order'][-1][2].has_key('sequence'):
data['sequence'] = context['line_order'][-1][2]['sequence'] + 1
if context.has_key('survey_id'):
data['survey_id'] = context['survey_id']
data['survey_id'] = context.get('survey_id', False)
return data
def survey_save(self, cr, uid, ids, context=None):

View File

@ -297,8 +297,9 @@ class survey_question_wiz(osv.osv_memory):
fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id)] = {'type':'datetime', 'string':ans.answer}
elif que_rec.type == 'descriptive_text':
for que_test in que_rec.descriptive_text.split('\n'):
etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_test)), 'align':"0.0"})
if que_rec.descriptive_text:
for que_test in que_rec.descriptive_text.split('\n'):
etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_test)), 'align':"0.0"})
elif que_rec.type == 'single_textbox':
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que.id) + "_single", 'nolabel':"1" ,'colspan':"4"})

View File

@ -1,7 +1,7 @@
all: xpi
jar:
jar cvf chrome/openerp_plugin.jar chrome/openerp_plugin/*
jar cvf chrome/openerp_plugin.jar -C chrome/openerp_plugin/ .
xpi: jar
zip -r ../openerp_plugin.xpi *