Ejemplo n.º 1
0
    def __init__(self, model, sel_multi=True, ids=[], context={}, domain = [], parent=None):
        self.model = model
        self.first = True
        self.domain =domain
        self.context = context
        self.context.update(rpc.session.context)
        self.sel_multi = sel_multi
        self.glade = glade.XML(common.terp_path("openerp.glade"),'win_search',gettext.textdomain())
        self.win = self.glade.get_widget('win_search')
        self.win.set_icon(common.OPENERP_ICON)
        if not parent:
            parent = service.LocalService('gui.main').window
        self.parent = parent
        self.win.set_transient_for(parent)

        self.screen = Screen(model, view_type=['tree'], context=self.context, parent=self.win)
        self.view = self.screen.current_view
        self.view.unset_editable()
        sel = self.view.widget_tree.get_selection()

        if not sel_multi:
            sel.set_mode('single')
        else:
            sel.set_mode(gtk.SELECTION_MULTIPLE)
        vp = gtk.Viewport()
        vp.set_shadow_type(gtk.SHADOW_NONE)
        vp.add(self.screen.widget)
        sw = self.glade.get_widget('search_sw')
        sw.add(vp)
        sw.show_all()
        self.view.widget_tree.connect('row_activated', self.sig_activate)
        self.view.widget_tree.connect('button_press_event', self.sig_button)

        self.model_name = model

        view_form = rpc.session.rpc_exec_auth('/object', 'execute', self.model_name, 'fields_view_get', False, 'form', self.context)
        self.form = widget_search.form(view_form['arch'], view_form['fields'], model, parent=self.win)

        self.title = _('OpenERP Search: %s') % self.form.name
        self.title_results = _('OpenERP Search: %s (%%d result(s))') % self.form.name
        self.win.set_title(self.title)
        x, y = self.form.widget.size_request()

        hbox = self.glade.get_widget('search_hbox')
        hbox.pack_start(self.form.widget)
        self.ids = ids
        if self.ids:
            self.reload()
        self.old_search = None
        self.old_offset = self.old_limit = None
        if self.ids:
            self.old_search = []
            self.old_limit = self.form.get_limit()
            self.old_offset = self.form.get_offset()

        self.view.widget.show_all()
        if self.form.focusable:
            self.form.focusable.grab_focus()
Ejemplo n.º 2
0
    def search_active(self, active=True, show_search=True):

        if active:
            if not self.filter_widget:
                view_form = rpc.session.rpc_exec_auth('/object', 'execute',
                                                      self.name,
                                                      'fields_view_get', False,
                                                      'form', self.context)
                view_tree = rpc.session.rpc_exec_auth('/object', 'execute',
                                                      self.name,
                                                      'fields_view_get', False,
                                                      'tree', self.context)
                dom = xml.dom.minidom.parseString(view_tree['arch'])
                child_node = dom.childNodes[0].childNodes
                arch = ''
                for i in range(1, len(child_node)):
                    arch += child_node[i].toxml()
                #Generic case when we need to remove the last occurance of </form> from form view
                view_form['arch'] = view_form['arch'][0:view_form['arch'].
                                                      rfind('</form>')]
                #Special case when form is replaced,we need to remove </form>
                find_form = view_form['arch'].rfind('</form>')
                if find_form > 0:
                    view_form['arch'] = view_form['arch'][0:find_form]

                view_form['arch'] = view_form['arch'] + arch + '\n</form>'
                view_form['fields'].update(view_tree['fields'])
                self.filter_widget = widget_search.form(
                    view_form['arch'], view_form['fields'], self.name,
                    self.window, self.domain, (self, self.search_filter))
                self.screen_container.add_filter(self.filter_widget.widget,
                                                 self.search_filter,
                                                 self.search_clear,
                                                 self.search_offset_next,
                                                 self.search_offset_previous)
                self.filter_widget.set_limit(self.limit)
                self.screen_container.spin_limit.set_value(self.limit)
                self.filter_widget.set_offset(
                    self.screen_container.spin_offset.get_value())
                self.screen_container.spin_limit.connect(
                    'key_press_event', self.get_event)
                self.screen_container.spin_offset.connect(
                    'key_press_event', self.get_event)

        if active and show_search:
            self.screen_container.show_filter()
        else:
            self.screen_container.hide_filter()
Ejemplo n.º 3
0
    def search_active(self, active=True, show_search=True):
        if active:
            if not self.filter_widget:
                if not self.search_view:
                    self.search_view = rpc.session.rpc_exec_auth('/object', 'execute',
                            self.name, 'fields_view_get', False, 'search',
                            self.context)
                self.filter_widget = widget_search.form(self.search_view['arch'],
                        self.search_view['fields'], self.name, self.window,
                        self.domain, (self, self.search_filter))
                self.screen_container.add_filter(self)

        if active and show_search:
            self.screen_container.show_filter()
        else:
            self.screen_container.hide_filter()
Ejemplo n.º 4
0
    def search_active(self, active=True, show_search=True):
        if active:
            if not self.filter_widget:
                if not self.search_view:
                    self.search_view = rpc.session.rpc_exec_auth('/object', 'execute',
                            self.name, 'fields_view_get', False, 'search',
                            self.context)
                self.filter_widget = widget_search.form(self.search_view['arch'],
                        self.search_view['fields'], self.name, self.window,
                        self.domain, (self, self.search_filter))
                if self.context.has_key('group_by'):
                    self.limit = None
                self.screen_container.add_filter(self.filter_widget.widget,
                        self.search_filter, self.search_clear,
                        self.search_offset_next,
                        self.search_offset_previous,
                        self.execute_action, self.add_custom, self.name, self.limit)

        if active and show_search:
            self.screen_container.show_filter()
        else:
            self.screen_container.hide_filter()
Ejemplo n.º 5
0
    def search_active(self, active=True, show_search=True):
        if active:
            if not self.filter_widget:
                if not self.search_view:
                    self.search_view = rpc.session.rpc_exec_auth(
                        '/object', 'execute', self.name, 'fields_view_get',
                        False, 'search', self.context)
                self.filter_widget = widget_search.form(
                    self.search_view['arch'], self.search_view['fields'],
                    self.name, self.window, self.domain,
                    (self, self.search_filter))
                if self.context.has_key('group_by'):
                    self.limit = None
                self.screen_container.add_filter(
                    self.filter_widget.widget, self.search_filter,
                    self.search_clear, self.search_offset_next,
                    self.search_offset_previous, self.execute_action,
                    self.add_custom, self.name, self.limit)

        if active and show_search:
            self.screen_container.show_filter()
        else:
            self.screen_container.hide_filter()
Ejemplo n.º 6
0
    def search_active(self, active=True, show_search=True):

        if active:
            if not self.filter_widget:
                view_form = rpc.session.rpc_exec_auth('/object', 'execute',
                        self.name, 'fields_view_get', False, 'form',
                        self.context)
                view_tree = rpc.session.rpc_exec_auth('/object', 'execute',
                        self.name, 'fields_view_get', False, 'tree',
                        self.context)
                dom = xml.dom.minidom.parseString(view_tree['arch'])
                child_node=dom.childNodes[0].childNodes
                arch=''
                for i in range(1,len(child_node)):
                    arch += child_node[i].toxml()
                #Generic case when we need to remove the last occurance of </form> from form view    
                view_form['arch'] = view_form['arch'][0:view_form['arch'].rfind('</form>')]
                #Special case when form is replaced,we need to remove </form>
                find_form = view_form['arch'].rfind('</form>')
                if find_form > 0:
                    view_form['arch'] = view_form['arch'][0:find_form]

                view_form['arch'] = view_form['arch'] + arch + '\n</form>'
                view_form['fields'].update(view_tree['fields'])
                self.filter_widget = widget_search.form(view_form['arch'],
                        view_form['fields'], self.name, self.window,
                        self.domain, (self, self.search_filter))
                self.screen_container.add_filter(self.filter_widget.widget,
                        self.search_filter, self.search_clear,
                        self.search_offset_next,
                        self.search_offset_previous)
                self.filter_widget.set_limit(self.limit)
                
        if active and show_search:
            self.screen_container.show_filter()
        else:
            self.screen_container.hide_filter()
Ejemplo n.º 7
0
    def __init__(self,
                 model,
                 sel_multi=True,
                 ids=[],
                 context={},
                 domain=[],
                 parent=None):
        self.model = model
        self.first = True
        self.domain = domain
        self.context = context
        self.context.update(rpc.session.context)
        self.sel_multi = sel_multi
        self.glade = glade.XML(common.terp_path("openerp.glade"), 'win_search',
                               gettext.textdomain())
        self.win = self.glade.get_widget('win_search')
        self.win.set_icon(common.OPENERP_ICON)
        if not parent:
            parent = service.LocalService('gui.main').window
        self.parent = parent
        self.win.set_transient_for(parent)

        self.screen = Screen(model,
                             view_type=['tree'],
                             context=self.context,
                             parent=self.win)
        self.view = self.screen.current_view
        self.view.unset_editable()
        sel = self.view.widget_tree.get_selection()

        if not sel_multi:
            sel.set_mode('single')
        else:
            sel.set_mode(gtk.SELECTION_MULTIPLE)
        vp = gtk.Viewport()
        vp.set_shadow_type(gtk.SHADOW_NONE)
        vp.add(self.screen.widget)
        sw = self.glade.get_widget('search_sw')
        sw.add(vp)
        sw.show_all()
        self.view.widget_tree.connect('row_activated', self.sig_activate)
        self.view.widget_tree.connect('button_press_event', self.sig_button)

        self.model_name = model

        view_form = rpc.session.rpc_exec_auth('/object', 'execute',
                                              self.model_name,
                                              'fields_view_get', False, 'form',
                                              self.context)
        self.form = widget_search.form(view_form['arch'],
                                       view_form['fields'],
                                       model,
                                       parent=self.win)

        self.title = _('OpenERP Search: %s') % self.form.name
        self.title_results = _(
            'OpenERP Search: %s (%%d result(s))') % self.form.name
        self.win.set_title(self.title)
        x, y = self.form.widget.size_request()

        hbox = self.glade.get_widget('search_hbox')
        hbox.pack_start(self.form.widget)
        self.ids = ids
        if self.ids:
            self.reload()
        self.old_search = None
        self.old_offset = self.old_limit = None
        if self.ids:
            self.old_search = []
            self.old_limit = self.form.get_limit()
            self.old_offset = self.form.get_offset()

        self.view.widget.show_all()
        if self.form.focusable:
            self.form.focusable.grab_focus()