def create(self, params, tg_errors=None):

        params.view_type = params.view_type or params.view_mode[0]
        if params.view_type == 'tree':
            params.editable = True

        form = self.create_form(params, tg_errors)
        
        editable = form.screen.editable
        mode = form.screen.view_type
        id = form.screen.id
        ids = form.screen.ids

        buttons = TinyDict()    # toolbar
        links = TinyDict()      # bottom links (customise view, ...)
        
        buttons.new = not editable or mode == 'tree'
        buttons.edit = not editable and mode == 'form'
        buttons.save = editable and mode == 'form'
        buttons.cancel = editable and mode == 'form'
        buttons.delete = not editable and mode == 'form'
        buttons.pager =  mode == 'form' # Pager will visible in edit and non-edit mode in form view.

        buttons.search = 'tree' in params.view_mode and mode != 'tree'
        buttons.graph = 'graph' in params.view_mode and mode != 'graph'
        buttons.form = 'form' in params.view_mode and mode != 'form'
        buttons.calendar = 'calendar' in params.view_mode and mode != 'calendar'
        buttons.gantt = 'gantt' in params.view_mode and mode != 'gantt'
        buttons.can_attach = id and mode == 'form'
        buttons.has_attach = buttons.can_attach # and self._has_attachments(params.model, id, mode)
        buttons.i18n = not editable and mode == 'form'

        target = params.context.get('_terp_target')
        buttons.toolbar = target != 'new' and not form.is_dashboard

        links.view_manager = True
        links.workflow_manager = False
        
        proxy = rpc.RPCProxy('workflow')
        wkf_ids = proxy.search([('osv', '=', params.model)], 0, 0, 0, rpc.session.context)
        links.workflow_manager = (wkf_ids or False) and wkf_ids[0]
        
        pager = None
        if buttons.pager:
            pager = tw.pager.Pager(id=form.screen.id, ids=form.screen.ids, offset=form.screen.offset, 
                                   limit=form.screen.limit, count=form.screen.count, view_type=params.view_type)

        if not params.load_counter:
            params.load_counter=1
        return dict(form=form, params=params,pager=pager, buttons=buttons, links=links, show_header_footer=False)
Example #2
0
    def create(self, params, tg_errors=None):

        params.view_type = params.view_type or params.view_mode[0]

        if params.view_type == 'tree':
            params.editable = True

        form = self.create_form(params, tg_errors)

        if not tg_errors:
            try:
                cherrypy.session.pop('remember_notebooks')
            except:
                self.reset_notebooks()

        editable = form.screen.editable
        mode = form.screen.view_type
        id = form.screen.id
        ids = form.screen.ids

        buttons = TinyDict()    # toolbar
        links = TinyDict()      # bottom links (customise view, ...)
        
        buttons.saveandedit = False
        buttons.new =  editable or mode == 'tree'
        buttons.edit = not editable and mode == 'form'
        buttons.save = editable and mode == 'form'
        buttons.cancel = editable and mode == 'form'
        buttons.delete = editable and mode == 'form'
        buttons.pager =  mode == 'form' # Pager will visible in edit and non-edit mode in form view.

        buttons.search = 'tree' in params.view_mode and mode != 'tree'
        buttons.graph = 'graph' in params.view_mode and mode != 'graph'
        buttons.form = 'form' in params.view_mode and mode != 'form'
        buttons.calendar = 'calendar' in params.view_mode and mode != 'calendar'
        buttons.gantt = 'gantt' in params.view_mode and mode != 'gantt'
        buttons.can_attach = id and mode == 'form'
        buttons.has_attach = buttons.can_attach and len(form.sidebar.attachments)
        buttons.i18n = not editable and mode == 'form'

        target = getattr(cherrypy.request, '_terp_view_target', None)
        
        show_header = target != 'new'
        if not int(cherrypy.request.params.get('_terp_header_footer', 1)):
            show_header = False
        cherrypy.request.show_header_footer = show_header
            
        buttons.toolbar = target != 'new' and not form.is_dashboard

        if cache.can_write('ir.ui.view'):
            links.view_manager = True
            
        if cache.can_write('workflow'):
            links.workflow_manager = True
            
        buttons.process = cache.can_read('process.process')

        pager = None
        if buttons.pager:
            pager = tw.pager.Pager(id=form.screen.id, ids=form.screen.ids, offset=form.screen.offset,
                                   limit=form.screen.limit, count=form.screen.count, view_type=params.view_type)

        return dict(form=form, pager=pager, buttons=buttons, links=links, path=self.path, show_header_footer=show_header)
Example #3
0
    def create(self, params, tg_errors=None):

        params.view_type = params.view_type or params.view_mode[0]

        if params.view_type == 'tree':
            params.editable = True
        form = self.create_form(params, tg_errors)

        if not tg_errors:
            try:
                cherrypy.session.pop('remember_notebooks')
            except:
                self.reset_notebooks()

        editable = form.screen.editable
        mode = form.screen.view_type
        id = form.screen.id
        buttons = TinyDict()    # toolbar
        buttons.new = (not editable or mode == 'tree') and mode != 'diagram'
        buttons.edit = not editable and (mode == 'form' or mode == 'diagram')
        buttons.save = editable and mode == 'form'
        buttons.cancel = editable and mode == 'form'
        buttons.delete = not editable and mode == 'form'
        buttons.pager =  mode == 'form' or mode == 'diagram'# Pager will visible in edit and non-edit mode in form view.
        buttons.can_attach = id and mode == 'form'
        buttons.i18n = not editable and mode == 'form'
        buttons.show_grid = mode == 'diagram'
        buttons.create_node = mode == 'diagram' and editable

        from openerp.widgets import get_registered_views
        buttons.views = []

        for kind, view in get_registered_views():
            buttons.views.append(dict(kind=kind, name=view.name, desc=view.desc))

        target = getattr(cherrypy.request, '_terp_view_target', None)
        buttons.toolbar = (target != 'new' and not form.is_dashboard) or mode == 'diagram'
        pager = None
        if buttons.pager:
            pager = tw.pager.Pager(id=form.screen.id, ids=form.screen.ids, offset=form.screen.offset,
                                   limit=form.screen.limit, count=form.screen.count, view_type=params.view_type)

        can_shortcut = self.can_shortcut_create()
        shortcut_ids = []

        if cherrypy.session.get('terp_shortcuts'):
            for sc in cherrypy.session['terp_shortcuts']:
                if isinstance(sc['res_id'], tuple):
                    shortcut_ids.append(sc['res_id'][0])
                else:
                    shortcut_ids.append(sc['res_id'])        
        
        title = form.screen.string or ''
        display_name = {}
        if params.view_type == 'form':
            if params.id:
                if form.screen.view.get('fields') and form.screen.view['fields'].get('name'):
                    display_name = {'field': form.screen.view['fields']['name']['string'], 'value': ustr(form.screen.view['fields']['name']['value'])}
                    title= ustr(display_name['field']) + ':' + ustr(display_name['value'])
        elif params.view_type == 'diagram':
            display_name = {'field': form.screen.view['fields']['name']['string'], 'value': rpc.RPCProxy(params.model).name_get(form.screen.id, rpc.get_session().context)[0][1]}

        # For Corporate Intelligence visibility.
        obj_process = rpc.RPCProxy('ir.model').search([('model', '=', 'process.process')]) or None
        
        tips = params.display_menu_tip
        if params.view_type == params.view_mode[0] and tips:
            tips = tips
        
        is_dashboard = form.screen.is_dashboard or False
        return dict(form=form, pager=pager, buttons=buttons, path=self.path, can_shortcut=can_shortcut, shortcut_ids=shortcut_ids, display_name=display_name, title=title, tips=tips, obj_process=obj_process, is_dashboard=is_dashboard)
Example #4
0
    def create(self, params, tg_errors=None):

        params.view_type = params.view_type or params.view_mode[0]

        if params.view_type == 'tree':
            params.editable = True
        form = self.create_form(params, tg_errors)

        if not tg_errors:
            try:
                cherrypy.session.pop('remember_notebooks')
            except:
                self.reset_notebooks()

        editable = form.screen.editable
        mode = form.screen.view_type
        id = form.screen.id
        buttons = TinyDict()  # toolbar
        buttons.new = (not editable or mode == 'tree') and mode != 'diagram'
        buttons.edit = not editable and (mode == 'form' or mode == 'diagram')
        buttons.save = editable and mode == 'form'
        buttons.cancel = editable and mode == 'form'
        buttons.delete = not editable and mode == 'form'
        buttons.pager = mode == 'form' or mode == 'diagram'  # Pager will visible in edit and non-edit mode in form view.
        buttons.can_attach = id and mode == 'form'
        buttons.i18n = not editable and mode == 'form'
        buttons.show_grid = mode == 'diagram'
        buttons.create_node = mode == 'diagram' and editable

        from openerp.widgets import get_registered_views
        buttons.views = []

        for kind, view in get_registered_views():
            buttons.views.append(
                dict(kind=kind, name=view.name, desc=view.desc))

        target = getattr(cherrypy.request, '_terp_view_target', None)
        buttons.toolbar = (target != 'new'
                           and not form.is_dashboard) or mode == 'diagram'
        pager = None
        if buttons.pager:
            pager = tw.pager.Pager(id=form.screen.id,
                                   ids=form.screen.ids,
                                   offset=form.screen.offset,
                                   limit=form.screen.limit,
                                   count=form.screen.count,
                                   view_type=params.view_type)

        can_shortcut = self.can_shortcut_create()
        shortcut_ids = []

        if cherrypy.session.get('terp_shortcuts'):
            for sc in cherrypy.session['terp_shortcuts']:
                if isinstance(sc['res_id'], tuple):
                    shortcut_ids.append(sc['res_id'][0])
                else:
                    shortcut_ids.append(sc['res_id'])

        title = form.screen.string or ''
        display_name = {}
        if params.view_type == 'form':
            if params.id:
                if form.screen.view.get(
                        'fields') and form.screen.view['fields'].get('name'):
                    display_name = {
                        'field': form.screen.view['fields']['name']['string'],
                        'value':
                        ustr(form.screen.view['fields']['name']['value'])
                    }
                    title = ustr(display_name['field']) + ':' + ustr(
                        display_name['value'])
        elif params.view_type == 'diagram':
            display_name = {
                'field':
                form.screen.view['fields']['name']['string'],
                'value':
                rpc.RPCProxy(params.model).name_get(form.screen.id,
                                                    rpc.session.context)[0][1]
            }

        # For Corporate Intelligence visibility.
        obj_process = rpc.RPCProxy('ir.model').search(
            [('model', '=', 'process.process')]) or None

        tips = params.display_menu_tip
        if params.view_type == params.view_mode[0] and tips:
            tips = tips

        is_dashboard = form.screen.is_dashboard or False
        return dict(form=form,
                    pager=pager,
                    buttons=buttons,
                    path=self.path,
                    can_shortcut=can_shortcut,
                    shortcut_ids=shortcut_ids,
                    display_name=display_name,
                    title=title,
                    tips=tips,
                    obj_process=obj_process,
                    is_dashboard=is_dashboard)
Example #5
0
    def create(self, params, tg_errors=None):

        params.view_type = params.view_type or params.view_mode[0]

        if params.view_type == 'tree':
            params.editable = True

        form = self.create_form(params, tg_errors)

        if not tg_errors:
            try:
                cherrypy.session.pop('remember_notebooks')
            except:
                self.reset_notebooks()

        editable = form.screen.editable
        mode = form.screen.view_type
        id = form.screen.id
        ids = form.screen.ids

        buttons = TinyDict()  # toolbar
        links = TinyDict()  # bottom links (customise view, ...)

        buttons.new = not editable or mode == 'tree'
        buttons.edit = not editable and mode == 'form'
        buttons.save = editable and mode == 'form'
        buttons.cancel = editable and mode == 'form'
        buttons.delete = not editable and mode == 'form'
        buttons.pager = mode == 'form'  # Pager will visible in edit and non-edit mode in form view.

        buttons.search = 'tree' in params.view_mode and mode != 'tree'
        buttons.graph = 'graph' in params.view_mode and mode != 'graph'
        buttons.form = 'form' in params.view_mode and mode != 'form'
        buttons.calendar = 'calendar' in params.view_mode and mode != 'calendar'
        buttons.gantt = 'gantt' in params.view_mode and mode != 'gantt'
        buttons.can_attach = id and mode == 'form'
        buttons.has_attach = buttons.can_attach and len(
            form.sidebar.attachments)
        buttons.i18n = not editable and mode == 'form'

        target = getattr(cherrypy.request, '_terp_view_target', None)

        show_header = target != 'new'
        if not int(cherrypy.request.params.get('_terp_header_footer', 1)):
            show_header = False
        cherrypy.request.show_header_footer = show_header

        buttons.toolbar = target != 'new' and not form.is_dashboard

        if cache.can_write('ir.ui.view'):
            links.view_manager = True

        if cache.can_write('workflow'):
            links.workflow_manager = True

        buttons.process = cache.can_read('process.process')

        pager = None
        if buttons.pager:
            pager = tw.pager.Pager(id=form.screen.id,
                                   ids=form.screen.ids,
                                   offset=form.screen.offset,
                                   limit=form.screen.limit,
                                   count=form.screen.count,
                                   view_type=params.view_type)

        return dict(form=form,
                    pager=pager,
                    buttons=buttons,
                    links=links,
                    path=self.path,
                    show_header_footer=show_header)