Khushboo Bhatt(openerp) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-calendar-phase2-cal_todo-kbh into
lp:~openerp-dev/openobject-addons/trunk-calendar-phase2.
Requested reviews:
Jigar Amin (OpenERP) (jam-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-calendar-phase2-cal_todo-kbh/+merge/92735
Hello,
======calendar_todo======
- Added demo data for calendar and for meeting.
- Added security file to model.
- changed the view of calendar_todo.
- Added method for onchange date.
- Added method for convert event into to task.
Thank you,
kbh.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-calendar-phase2-cal_todo-kbh/+merge/92735
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-calendar-phase2.
=== modified file 'base_calendar/__init__.py'
--- base_calendar/__init__.py 2011-07-27 10:39:01 +0000
+++ base_calendar/__init__.py 2012-02-13 11:09:22 +0000
@@ -24,7 +24,6 @@
import calendar_event_recurrent
import calendar_alarm
import calendar_attendee
-import calendar_todo
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'base_calendar/calendar_attendee.py'
--- base_calendar/calendar_attendee.py 2012-02-10 04:23:57 +0000
+++ base_calendar/calendar_attendee.py 2012-02-13 11:09:22 +0000
@@ -154,7 +154,7 @@
_defaults = {
'notification': True,
}
-
+
def write(self, cr, uid, ids, vals, context=None):
res = super(calendar_event, self).write(cr, uid, ids, vals, context=context)
email_template = self.pool.get('email.template')
=== removed file 'base_calendar/calendar_todo.py'
--- base_calendar/calendar_todo.py 2011-05-23 12:13:58 +0000
+++ base_calendar/calendar_todo.py 1970-01-01 00:00:00 +0000
@@ -1,67 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 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 fields, osv
-
-class calendar_todo(osv.osv):
- """ Calendar Task """
-
- _name = "calendar.todo"
- _inherit = "calendar.event"
- _description = "Calendar Task"
-
- def _get_date(self, cr, uid, ids, name, arg, context=None):
- """
- Get 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 ids: List of calendar todo's IDs.
- @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...].
- @param context: A standard dictionary for contextual values
- """
-
- res = {}
- for event in self.browse(cr, uid, ids, context=context):
- res[event.id] = event.date_start
- return res
-
- def _set_date(self, cr, uid, id, name, value, arg, context=None):
- """
- Set 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 id: calendar's ID.
- @param value: Get Value
- @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...].
- @param context: A standard dictionary for contextual values
- """
-
- assert name == 'date'
- return self.write(cr, uid, id, { 'date_start': value }, context=context)
-
- _columns = {
- 'date': fields.function(_get_date, method=True, fnct_inv=_set_date, \
- string='Duration', store=True, type='datetime'),
- 'duration': fields.integer('Duration'),
- }
-
-calendar_todo()
=== modified file 'base_calendar/security/ir.model.access.csv'
--- base_calendar/security/ir.model.access.csv 2011-07-28 10:20:39 +0000
+++ base_calendar/security/ir.model.access.csv 2012-02-13 11:09:22 +0000
@@ -3,5 +3,4 @@
"access_calendar_event","calendar.event","model_calendar_event","base.group_user",1,1,1,1
"access_calendar_alarm","calendar.alarm","model_calendar_alarm","base.group_user",1,1,1,1
"access_calendar_attendee","calendar.attendee","model_calendar_attendee","base.group_user",1,1,1,1
-"access_calendar_todo","calendar.todo","model_calendar_todo","base.group_user",1,1,1,1
"access_calendar_event_category","calendar.event.category","model_calendar_event_category","base.group_user",1,0,0,0
=== added directory 'calendar_todo'
=== added file 'calendar_todo/__init__.py'
--- calendar_todo/__init__.py 1970-01-01 00:00:00 +0000
+++ calendar_todo/__init__.py 2012-02-13 11:09:22 +0000
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 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/>.
+#
+##############################################################################
+
+import calendar_todo
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'calendar_todo/__openerp__.py'
--- calendar_todo/__openerp__.py 1970-01-01 00:00:00 +0000
+++ calendar_todo/__openerp__.py 2012-02-13 11:09:22 +0000
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 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/>.
+#
+##############################################################################
+
+{
+ "name" : "Calendar TODO Application",
+ "version" : "1.0",
+ "depends" : ["base_calendar", "project"],
+ 'description': """
+Calendar TODO List application :
+========================================
+This Application in based on Calendar which supports
+ - Defining List Of Task on Multi User Calendar
+ - MultiAlarm on TODO
+ - Recurring TODO
+ - ...
+ """,
+ "author" : "OpenERP SA",
+ 'category': 'Tools',
+ 'website': 'http://www.openerp.com',
+ "init_xml" : ['calendar_todo_data.xml',
+ ],
+ "demo_xml" : ['calendar_todo_demo.xml',
+ ],
+ "update_xml" : [
+ #TODO: Compose the TODO views by Combining the view of the calendar.event and project.ask
+ 'calendar_todo_view.xml',
+ ],
+ "test" : [
+ ],
+ "installable" : True,
+ 'auto_install': False,
+ "certificate" : False,
+ 'images': []
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'calendar_todo/calendar_todo.py'
--- calendar_todo/calendar_todo.py 1970-01-01 00:00:00 +0000
+++ calendar_todo/calendar_todo.py 2012-02-13 11:09:22 +0000
@@ -0,0 +1,117 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 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
+from datetime import datetime, timedelta
+
+class calendar_todo(osv.osv):
+ """ Calendar TODO """
+
+ _name = "calendar.todo"
+ _inherits = { 'calendar.event': 'event_id'}
+ _description = "Calendar TODO"
+ _columns = {
+ 'event_id': fields.many2one('calendar.event', 'Event'),
+ 'task_id': fields.many2one('project.task', 'Task'),
+ 'planned_hours':fields.related('task_id', 'planned_hours', type='many2one', relation='project.task', string='Planned Hours'),
+ }
+
+ def convert_task(self, cr, uid, ids, context=None):
+ cal_obj = self.pool.get('calendar.todo')
+ data_obj = self.pool.get('ir.model.data')
+ task_obj = self.pool.get('project.task')
+ if context is None:
+ context = {}
+
+ result = data_obj._get_id(cr, uid, 'project', 'view_task_search_form')
+ res = data_obj.read(cr, uid, result, ['res_id'])
+ id2 = data_obj._get_id(cr, uid, 'project', 'view_task_form2')
+ id3 = data_obj._get_id(cr, uid, 'project', 'view_task_tree2')
+ if id2:
+ id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+ if id3:
+ id3 = data_obj.browse(cr, uid, id3, context=context).res_id
+
+ for task in cal_obj.browse(cr, uid, ids, context=context):
+ new_task_id = task_obj.create(cr, uid, {
+ 'name': task.name,
+ 'date_deadline': task.date,
+ 'user_id': task.user_id.id,
+ 'planned_hours': 0.0,
+ })
+ vals = {
+ 'task_id': new_task_id,
+ }
+ cal_obj.write(cr, uid, [task.id], vals)
+
+ return {
+ 'name': ('Task'),
+ 'view_type': 'form',
+ 'view_mode': 'form,tree',
+ 'res_model': 'project.task',
+ 'res_id': int(new_task_id),
+ 'view_id': False,
+ 'views': [(id2,'form'),(id3,'tree'),(False,'calendar'),(False,'graph')],
+ 'type': 'ir.actions.act_window',
+ 'search_view_id': res['res_id'],
+ 'nodestroy': True
+ }
+
+ def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, allday=False, context=None):
+ """Returns duration and/or end date based on values passed
+ """
+ if context is None:
+ context = {}
+
+ value = {}
+ if not start_date:
+ return value
+ if not end_date and not duration:
+ duration = 1.00
+ value['duration'] = duration
+
+ if allday: # For all day event
+ value = {'duration': 24.0}
+ duration = 24.0
+ if start_date:
+ start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S")
+ start_date = datetime.strftime(datetime(start.year, start.month, start.day, 0,0,0), "%Y-%m-%d %H:%M:%S")
+ value['date'] = start_date
+
+ start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S")
+ if end_date and not duration:
+ end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S")
+ diff = end - start
+ duration = float(diff.days)* 24 + (float(diff.seconds) / 3600)
+ value['duration'] = round(duration, 2)
+ elif not end_date:
+ end = start + timedelta(hours=duration)
+ value['date_deadline'] = end.strftime("%Y-%m-%d %H:%M:%S")
+ elif end_date and duration and not allday:
+ # we have both, keep them synchronized:
+ # set duration based on end_date (arbitrary decision: this avoid
+ # getting dates like 06:31:48 instead of 06:32:00)
+ end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S")
+ diff = end - start
+ duration = float(diff.days)* 24 + (float(diff.seconds) / 3600)
+ value['duration'] = round(duration, 2)
+
+ return {'value': value}
\ No newline at end of file
=== added file 'calendar_todo/calendar_todo_data.xml'
--- calendar_todo/calendar_todo_data.xml 1970-01-01 00:00:00 +0000
+++ calendar_todo/calendar_todo_data.xml 2012-02-13 11:09:22 +0000
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <record id="calendar_todo_administrator" model="calendar.calendar">
+ <field name="user_id" ref="base.user_admin"/>
+ <field name="name">Project task</field>
+ <field eval="10" name="priority"/>
+ <field name="type">vtodo</field>
+ <field name="object_id" ref="model_calendar_todo"/>
+ </record>
+ </data>
+</openerp>
=== added file 'calendar_todo/calendar_todo_demo.xml'
--- calendar_todo/calendar_todo_demo.xml 1970-01-01 00:00:00 +0000
+++ calendar_todo/calendar_todo_demo.xml 2012-02-13 11:09:22 +0000
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data noupdate="1">
+
+ <record id="calendar_demo_user" model="calendar.calendar">
+ <field name="user_id" ref="base.user_demo"/>
+ <field name="name">Demo User Task</field>
+ <field eval="10" name="priority"/>
+ <field name="type">vtodo</field>
+ <field name="object_id" ref="model_calendar_todo"/>
+ </record>
+ <!-- Resource: calendar_todo meeting demo-->
+ <record id="calendar_todoadmin1" model="calendar.todo">
+ <field eval="1.0" name="duration"/>
+ <field name="user_id" ref="base.user_admin"/>
+ <field eval="1" name="notification"/>
+ <field name="state">draft</field>
+ <field name="end_type">forever</field>
+ <field eval="time.strftime('%Y-%m-15 19:05:15')" name="date"/>
+ <field eval="time.strftime('%Y-%m-15 23:05:15')" name="date_deadline"/>
+ <field name="calendar_id" ref="calendar_todo.calendar_todo_administrator"/>
+ <field name="freq">None</field>
+ <field name="show_as">busy</field>
+ <field name="name">Prepare Requirements Document</field>
+ <field eval="1" name="interval"/>
+ <field name="organizer_id" ref="base.user_admin"/>
+ <field name="rrule_type">none</field>
+ <field name="select1">date</field>
+ </record>
+ <record id="calendar_todoadmin2" model="calendar.todo">
+ <field eval="1.0" name="duration"/>
+ <field name="user_id" ref="base.user_admin"/>
+ <field eval="1" name="notification"/>
+ <field name="state">draft</field>
+ <field name="end_type">forever</field>
+ <field eval="time.strftime('%Y-%m-15 19:05:15')" name="date"/>
+ <field eval="time.strftime('%Y-%m-15 23:05:15')" name="date_deadline"/>
+ <field name="calendar_id" ref="calendar_todo.calendar_todo_administrator"/>
+ <field name="freq">None</field>
+ <field name="show_as">busy</field>
+ <field name="name">Performance tuning</field>
+ <field eval="1" name="interval"/>
+ <field name="organizer_id" ref="base.user_admin"/>
+ <field name="rrule_type">none</field>
+ <field name="select1">date</field>
+ </record>
+ <record id="calendar_todo_demo" model="calendar.todo">
+ <field eval="1.0" name="duration"/>
+ <field name="user_id" ref="base.user_demo"/>
+ <field eval="1" name="notification"/>
+ <field name="state">draft</field>
+ <field name="end_type">forever</field>
+ <field eval="time.strftime('%Y-%m-23 19:05:15')" name="date"/>
+ <field eval="time.strftime('%Y-%m-23 23:05:15')" name="date_deadline"/>
+ <field name="calendar_id" ref="calendar_demo_user"/>
+ <field name="freq">None</field>
+ <field name="show_as">busy</field>
+ <field name="name">Budget Planning</field>
+ <field eval="1" name="interval"/>
+ <field name="organizer_id" ref="base.user_admin"/>
+ <field name="rrule_type">none</field>
+ <field name="select1">date</field>
+ </record>
+ <record id="calendar_todo_demo2" model="calendar.todo">
+ <field eval="1.0" name="duration"/>
+ <field name="user_id" ref="base.user_demo"/>
+ <field eval="1" name="notification"/>
+ <field name="state">draft</field>
+ <field name="end_type">forever</field>
+ <field eval="time.strftime('%Y-%m-23 19:05:15')" name="date"/>
+ <field eval="time.strftime('%Y-%m-23 23:05:15')" name="date_deadline"/>
+ <field name="calendar_id" ref="calendar_demo_user"/>
+ <field name="freq">None</field>
+ <field name="show_as">busy</field>
+ <field name="name">Internal Testing</field>
+ <field eval="1" name="interval"/>
+ <field name="organizer_id" ref="base.user_admin"/>
+ <field name="rrule_type">none</field>
+ <field name="select1">date</field>
+ </record>
+ </data>
+</openerp>
=== added file 'calendar_todo/calendar_todo_view.xml'
--- calendar_todo/calendar_todo_view.xml 1970-01-01 00:00:00 +0000
+++ calendar_todo/calendar_todo_view.xml 2012-02-13 11:09:22 +0000
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <!-- Todo Form View-->
+ <record model="ir.ui.view" id="event_todo_form_view">
+ <field name="name">Event Form</field>
+ <field name="model">calendar.todo</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Events">
+ <group col="6" colspan="4">
+ <field name="name" select="1" string="Summary"
+ colspan="4" required="1" />
+ <field name="allday" colspan="2" on_change="onchange_dates(date,False,False,allday)" />
+ <newline/>
+ <field name="date" string="Start Date" required="1"
+ on_change="onchange_dates(date,duration,False,allday)" />
+ <field name="duration" widget="float_time"
+ on_change="onchange_dates(date,duration,False,allday)" attrs="{'invisible': [('allday', '=', True)]}"/>
+ <field name="date_deadline" string="End Date" required="1"
+ on_change="onchange_dates(date,False,date_deadline)"/>
+ <field name="location"/>
+ <field name="category_id" widget="selection" />
+ </group>
+ <group colspan="2" col="4">
+ <field name="recurrency"/>
+ <field name="edit_all" attrs="{'invisible':[('recurrency','=', False)]}" />
+ </group>
+ <notebook colspan="4">
+ <page string="Event">
+ <separator colspan="4" string="Visibility" />
+ <group col="6" colspan="4">
+ <field name="calendar_id" required="1" domain="[('user_id','=',user_id),('type','=','vtodo')]" string="Calendar" />
+ <field name="user_id" string="Responsible User"/>
+ <field name="organizer_id" string="Organizer" />
+ <field name="show_as" string="Show time as"/>
+ <field name="class"/>
+ </group>
+ <group>
+ <separator colspan="4" string="Task Information" />
+ <field name="task_id"/>
+ <button string="Convert To Task"
+ name="convert_task"
+ icon="gtk-index"
+ type="object"
+ attrs="{'invisible':[('task_id','!=',False)]}" />
+ </group>
+ </page>
+ <page string="Notes">
+ <field name="description" nolabel="1" colspan="4"/>
+ </page>
+ <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" attrs="{'readonly':[('recurrent_uid','!=',False)]}"/>
+ <field name="interval" />
+ <separator string="End of recurrency" colspan="4"/>
+ <field name="end_type" />
+ <label string=" " colspan="2" />
+ <newline />
+ <field name="count" attrs="{'invisible' : [('end_type', '!=', 'count')] }"/>
+ <label string=" " colspan="2" />
+ <newline />
+ <field name="end_date" attrs="{'invisible' : [('end_type', '!=', 'end_date')],'required' : [('end_type', '=', 'end_date')],}"/>
+ <newline />
+ </group>
+ <group col="8" colspan="4" name="Select weekdays" attrs="{'invisible' :[('rrule_type','not in', ['weekly'])]}">
+ <separator string="Choose day where repeat the meeting" colspan="8"/>
+ <field name="mo" colspan="1" />
+ <field name="tu" colspan="1" />
+ <field name="we" colspan="1" />
+ <field name="th" colspan="1" />
+ <newline/>
+ <field name="fr" colspan="1" />
+ <field name="sa" colspan="1" />
+ <field name="su" colspan="1" />
+ <newline />
+ </group>
+ <group col="10" colspan="4"
+ attrs="{'invisible' : [('rrule_type','!=','monthly')]}">
+ <separator string="Choose day in the month where repeat the meeting" colspan="12"/>
+ <group col="2" colspan="1">
+ <field name="select1" />
+ </group>
+ <group col="2" colspan="1">
+ <field name="day"
+ attrs="{'required' : [('select1','=','date'), ('rrule_type','=','monthly')],
+ 'invisible' : ['|', ('select1','=','day'), ('rrule_type','!=','monthly')]}" />
+ </group>
+ <group col="3" colspan="1"
+ attrs="{'invisible' : ['|', ('select1','=','date'), ('rrule_type','!=','monthly')]}">
+ <field name="byday" string="The"
+ attrs="{'required' : [('select1','=','day'), ('rrule_type','=','monthly')]}" />
+ <field name="week_list" nolabel="1"
+ attrs="{'required' : [('select1','=','day'), ('rrule_type','=','monthly')]}" />
+ </group>
+ </group>
+ </group>
+ </page>
+ </notebook>
+ </form>
+ </field>
+ </record>
+
+ <!-- Todo action -->
+
+ <record id="action_view_event_todo" model="ir.actions.act_window">
+ <field name="name">Todo Meetings</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">calendar.todo</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ </record>
+
+ <menuitem id="menu_todo_config" action="action_view_event_todo" name="Todo" parent="project.menu_project_management"/>
+ </data>
+ </openerp>
=== added directory 'calendar_todo/security'
=== added file 'calendar_todo/security/ir.model.access.csv'
--- calendar_todo/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ calendar_todo/security/ir.model.access.csv 2012-02-13 11:09:22 +0000
@@ -0,0 +1,2 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_calendar_todo","calendar.todo","model_calendar_todo","base.group_user",1,1,1,1
\ No newline at end of file
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp