~openerp-commiter/openobject-addons/trunk-extra-addons

« back to all changes in this revision

Viewing changes to portal/portal.py

  • Committer: Fabien Pinckaers
  • Date: 2008-09-24 19:47:55 UTC
  • mfrom: (3288.1.9 trunk-extra-addons)
  • Revision ID: fp@tinyerp.com-20080924194755-a15pg8qpaxmnhvx2
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
##############################################################################
28
28
 
29
29
from osv import fields, osv
30
 
 
 
30
import pooler
31
31
 
32
32
class portal_portal(osv.osv):
33
33
    _name = "portal.portal"
63
63
            vals['menu_action_id']= self.create_action_menu(cr,user,vals['menu_id'], vals['name'],context)
64
64
        return super(portal_portal, self).create(cr, user, vals, context)
65
65
 
66
 
    def create_menu(self, cr, uid,portal_id, portal_model_id, menu_name, action_id,parent_menu_id=None,view_ids=None,view_type=False,context=None):
 
66
    def create_menu(self, cr, uid,portal_id, portal_model_id, menu_name, action_id,parent_menu_id=None,view_ids=None,view_type=False,context=None):        
67
67
        """
68
68
        Create a menuitem for the given portal and model whith the given name and action.
69
69
        """
80
80
 
81
81
        portal= self.pool.get('portal.portal').browse(cr,uid,portal_id)
82
82
        model= self.pool.get('portal.model').browse(cr,uid,portal_model_id)
83
 
        action= self.pool.get('ir.actions.act_window').browse(cr,uid,action_id)
 
83
        action_obj= self.pool.get('ir.actions.act_window')
 
84
        action= action_obj.browse(cr,uid,action_id)
84
85
        ## Create the menu:
85
86
        menu_id=self.pool.get('ir.ui.menu').create(cr, uid, {
86
87
            'name': menu_name,
94
95
        vids = []
95
96
        i = 0
96
97
        ## Fetch the views:
97
 
        for view in self.pool.get('ir.actions.act_window').browse(cr,uid,action_id).views:
 
98
        for view in action_obj.browse(cr,uid,action_id,context=context).views:
98
99
            vids.append((0,0, {
99
100
                'sequence':i,
100
101
                'view_id': available_view.get(view[1], view[0]),
158
159
                    vids[1]=temp
159
160
 
160
161
        ## Duplicate the action and give the fetched views to the new one:
161
 
        action_id = action.copy(cr,uid, action.id,{
 
162
        action_id = action_obj.copy(cr,uid, action.id,{
162
163
            'name': menu_name,
163
164
            'view_ids': vids,
164
165
            'view_type': v[0]
165
 
            })
 
166
            },context=context)
166
167
 
167
168
        ## Create the values:
168
169
        value_id = self.pool.get('ir.values').create(cr, uid, {
231
232
        'portal_visible': lambda *a: True,
232
233
    }
233
234
ir_actions_act_window()
 
235
 
 
236
class portal_config_install_modules_wizard(osv.osv_memory):
 
237
    _name='portal.config.install_modules_wizard'
 
238
    _columns = {
 
239
        'portal_sale':fields.boolean('Portal for Sale Module'),
 
240
        'portal_service':fields.boolean('Portal for Service Module'),
 
241
        'portal_account':fields.boolean('Portal for Account Module'),
 
242
        'portal_analytic':fields.boolean('Portal for Analytic Account Module'),        
 
243
    }
 
244
    def action_cancel(self,cr,uid,ids,conect=None):
 
245
        return {
 
246
                'view_type': 'form',
 
247
                "view_mode": 'form',
 
248
                'res_model': 'ir.module.module.configuration.wizard',
 
249
                'type': 'ir.actions.act_window',
 
250
                'target':'new',
 
251
         }
 
252
    def action_install(self, cr, uid, ids, context=None):
 
253
        result=self.read(cr,uid,ids)        
 
254
        mod_obj = self.pool.get('ir.module.module')
 
255
        for res in result:
 
256
            for r in res:
 
257
                if r<>'id' and res[r]:
 
258
                    ids = mod_obj.search(cr, uid, [('name', '=', r)])
 
259
                    mod_obj.action_install(cr, uid, ids, context=context)
 
260
        cr.commit()
 
261
        db, pool = pooler.restart_pool(cr.dbname,force_demo=True, update_module=True)
 
262
        return {
 
263
                'view_type': 'form',
 
264
                "view_mode": 'form',
 
265
                'res_model': 'ir.module.module.configuration.wizard',
 
266
                'type': 'ir.actions.act_window',
 
267
                'target':'new',
 
268
            }
 
269
portal_config_install_modules_wizard()
 
270
 
234
271
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
235
272