[IMP] attach the 'Our company' menu items to the portal's root menu
[odoo/odoo.git] / addons / portal / portal.py
index 78483d6..399377e 100644 (file)
@@ -36,13 +36,12 @@ class portal(osv.osv):
     _columns = {
         'group_id': fields.many2one('res.groups', required=True, ondelete='cascade',
             string='Group',
-            help='The group extended by this portal'),
-        'other_group_ids': fields.many2many('res.groups',
-            'portal_group_rel', 'portal_id', 'group_id',
-            string='Other User Groups',
-            help="Those groups are assigned to the portal's users"),
+            help='The group corresponding to this portal'),
         'url': fields.char('URL', size=64,
             help="The url where portal users can connect to the server"),
+        'home_action_id': fields.many2one('ir.actions.actions',
+            string='Home Action',
+            help="if set, replaces the standard home action (first screen after loggin) for the portal's users"),
         'menu_action_id': fields.many2one('ir.actions.act_window', readonly=True,
             # ISSUE: 'ondelete' constraints do not seem effective on this field...
             string='Menu Action',
@@ -70,8 +69,8 @@ class portal(osv.osv):
         portal_id = super(portal, self).create(cr, uid, values, context)
         
         # assign menu action and widgets to users
-        if values.get('users') or values.get('other_group_ids') or values.get('menu_action_id'):
-            self._assign_menu_and_groups(cr, uid, [portal_id], context)
+        if values.get('users') or values.get('menu_action_id'):
+            self._assign_menu(cr, uid, [portal_id], context)
         if values.get('users') or values.get('widget_ids'):
             self._assign_widgets(cr, uid, [portal_id], context)
         
@@ -83,8 +82,8 @@ class portal(osv.osv):
         super(portal, self).write(cr, uid, ids, values, context)
         
         # assign menu action and widgets to users
-        if values.get('users') or values.get('other_group_ids') or values.get('menu_action_id'):
-            self._assign_menu_and_groups(cr, uid, ids, context)
+        if values.get('users') or values.get('menu_action_id'):
+            self._assign_menu(cr, uid, ids, context)
         if values.get('users') or values.get('widget_ids'):
             self._assign_widgets(cr, uid, ids, context)
         
@@ -98,37 +97,16 @@ class portal(osv.osv):
                 act_window_obj.write(cr, uid, action_ids, action_values, context)
         
         return True
-    
-    def do_create_menu(self, cr, uid, ids, context=None):
-        """ create a parent menu for the given portals """
-        menu_obj = self.pool.get('ir.ui.menu')
-        menu_root = self._res_xml_id(cr, uid, 'portal', 'portal_menu')
-        
-        for p in self.browse(cr, uid, ids, context):
-            # create a menuitem under 'portal.portal_menu'
-            menu_values = {
-                'name': _('%s Menu') % p.name,
-                'parent_id': menu_root,
-                'groups_id': [(6, 0, [p.group_id.id])],
-            }
-            menu_id = menu_obj.create(cr, uid, menu_values, context)
-            # set the parent_menu_id to item_id
-            self.write(cr, uid, [p.id], {'parent_menu_id': menu_id}, context)
-        
-        return True
 
-    def _assign_menu_and_groups(self, cr, uid, ids, context=None):
-        """ assign portal menu and other groups to users of portals (ids) """
+    def _assign_menu(self, cr, uid, ids, context=None):
+        """ assign portal_menu_settings to users of portals (ids) """
         user_obj = self.pool.get('res.users')
         for p in self.browse(cr, uid, ids, context):
-            # user groups = portal group + other groups
-            group_ids = [p.group_id.id] + [g.id for g in p.other_group_ids]
-            user_values = {'groups_id': [(6, 0, group_ids)]}
             # user menu action = portal menu action if set in portal
             if p.menu_action_id:
-                user_values['menu_id'] = p.menu_action_id.id
-            user_ids = [u.id for u in p.users if u.id != 1]
-            user_obj.write(cr, uid, user_ids, user_values, context)
+                user_ids = [u.id for u in p.users if u.id != 1]
+                user_values = {'menu_id': p.menu_action_id.id}
+                user_obj.write(cr, uid, user_ids, user_values, context)
 
     def _assign_widgets(self, cr, uid, ids, context=None):
         """ assign portal widgets to users of portals (ids) """
@@ -233,3 +211,5 @@ portal_widget()
 
 
 
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: