Arnaud Pineux (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/7.0-base_calendar-api into 
lp:openobject-addons/7.0.

Requested reviews:
  qdp (OpenERP) (qdp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-base_calendar-api/+merge/141782

Base_calendar:
Objective: Have every meeting where the user belongs to the attentees on the 
calendar view.
How to: It was impossible to simple had a domain for the calendar filter so I 
decide to overwrite the search method of crm_meeting such that it catch a 
special element of the domain.
So when in the domain of search method we have "attendee_ids", "in", ... we 
choose ourself the meetings to be displayed and we replace the domain with this 
"id", "in", [list of ids that we collect]

API
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-base_calendar-api/+merge/141782
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/7.0-base_calendar-api.
=== modified file 'base_calendar/base_calendar.py'
--- base_calendar/base_calendar.py	2012-12-28 11:18:53 +0000
+++ base_calendar/base_calendar.py	2013-01-03 16:24:26 +0000
@@ -1350,6 +1350,7 @@
         if context is None:
             context = {}
         new_args = []
+        recurrent_args = []
 
         for arg in args:
             new_arg = arg
@@ -1359,12 +1360,16 @@
             elif arg[0] == "id":
                 new_id = get_real_ids(arg[2])
                 new_arg = (arg[0], arg[1], new_id)
+                #recurrent = (arg[0], arg[1], arg[2])
+                recurrent_args.append(new_arg)
             new_args.append(new_arg)
-
         #offset, limit and count must be treated separately as we may need to deal with virtual ids
         res = super(calendar_event, self).search(cr, uid, new_args, offset=0, limit=0, order=order, context=context, count=False)
+
         if context.get('virtual_id', True):
-            res = self.get_recurrent_ids(cr, uid, res, new_args, limit, context=context)
+            recurrent = ('recurrency','=',1)
+            recurrent_args.append(recurrent)
+            res += self.get_recurrent_ids(cr, uid, super(calendar_event, self).search(cr, uid, recurrent_args, offset=0, limit=0, order=order, context=context, count=False), new_args, limit, context=context)
         if count:
             return len(res)
         elif limit:

=== modified file 'base_calendar/base_calendar_view.xml'
--- base_calendar/base_calendar_view.xml	2012-12-10 15:08:45 +0000
+++ base_calendar/base_calendar_view.xml	2013-01-03 16:24:26 +0000
@@ -254,14 +254,13 @@
             <field name="arch" type="xml">
                 <search string="Search Events">
                     <field name="name" filter_domain="['|',('name','ilike',self),('location','ilike',self)]" string="Event"/>
-                    <field name="show_as"/>
                     <field name="class" string="Privacy"/>
                     <filter icon="terp-go-today" string="My Events" domain="[('user_id','=',uid)]" help="My Events"/>
                     <separator/>
                     <filter icon="terp-check" string="Confirmed" domain="[('state','=','confirmed')]" help="Confirmed Events"/>
                     <field name="user_id"/>
                     <group expand="0" string="Group By...">
-                        <filter string="Responsible" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
+                        <filter string="Responsible" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/> 
                         <filter string="Availability" icon="terp-camera_test" domain="[]" context="{'group_by':'show_as'}"/>
                         <filter string="Privacy" icon="terp-locked" domain="[]" context="{'group_by':'class'}"/>
                         <filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>

=== modified file 'base_calendar/crm_meeting.py'
--- base_calendar/crm_meeting.py	2012-12-20 12:49:27 +0000
+++ base_calendar/crm_meeting.py	2013-01-03 16:24:26 +0000
@@ -107,6 +107,24 @@
                     'message': warning_msg,
                     }
                 }
+    def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
+        if context is None:
+            context = {}
+        domain = []
+        ids = []
+        for elmt in args:
+            if "attendee_ids" in elmt[0] and "in" in elmt[1]:
+                meeting_ids = self.search(cr,uid,[],context={})
+                for meeting in self.browse(cr,uid,meeting_ids,context=context):
+                    for attendee in meeting.attendee_ids:
+                        if attendee.user_id.id == uid:
+                            ids.append(meeting.id)
+            else:
+                domain.append(elmt)
+        if ids:
+            domain.append(['id','in',ids])
+        return super(crm_meeting, self).search(cr, uid, domain, offset=offset, limit=limit, order=order, context=context, count=count)
+
     # ----------------------------------------
     # OpenChatter
     # ----------------------------------------

=== modified file 'base_calendar/crm_meeting_view.xml'
--- base_calendar/crm_meeting_view.xml	2012-12-28 08:48:40 +0000
+++ base_calendar/crm_meeting_view.xml	2013-01-03 16:24:26 +0000
@@ -236,7 +236,8 @@
                 <field name="name" string="Meeting" filter_domain="[('name','ilike',self)]"/>
                 <filter string="Unread Messages" name="message_unread" domain="[('message_unread','=',True)]"/>
                 <separator/>
-                <filter string="My Meetings" help="My Meetings" domain="[('user_id','=',uid)]"/>
+                <filter string="My Respnsability" help="My Responsability" domain="[('user_id','=', uid)]"/>
+                <filter name='mymeetings' string="My Meetings" help="My Meetings" domain="[('attendee_ids','in', uid)]"/>
                 <field name="user_id"/>
                 <field name="partner_ids"/>
             </search>
@@ -251,7 +252,7 @@
         <field name="view_mode">calendar,tree,form,gantt</field>
         <field name="view_id" ref="view_crm_meeting_calendar"/>
         <field name="search_view_id" ref="view_crm_meeting_search"/>
-        <field name="context">{"calendar_default_user_id": uid}</field>
+        <field name="context">{"search_default_mymeetings":1}</field>
         <field name="help" type="html">
           <p class="oe_view_nocontent_create">
             Click to schedule a new meeting.

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to