def __init__(self, parent=None): self.glade = glade.XML(common.terp_path("openerp.glade"),'win_preference', gettext.textdomain()) self.win = self.glade.get_widget('win_preference') self.win.set_icon(common.OPENERP_ICON) if not parent: parent = service.LocalService('gui.main').window self.win.set_transient_for(parent) self.parent = parent action_id = rpc.session.rpc_exec_auth('/object', 'execute', 'res.users', 'action_get', {}) action = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.actions.act_window', 'read', [action_id], False, rpc.session.context)[0] view_ids=[] if action.get('views', []): view_ids=[x[0] for x in action['views']] elif action.get('view_id', False): view_ids=[action['view_id'][0]] self.screen = Screen('res.users', view_type=[], window=parent) self.screen.add_view_id(view_ids[0], 'form', display=True) self.screen.load([rpc.session.uid]) self.screen.display(rpc.session.uid) vbox = self.glade.get_widget('preference_vbox') vbox.pack_start(self.screen.widget) self.win.set_title(_('Preference')) self.win.show_all()
def __init__(self, parent=None): self.glade = glade.XML(common.terp_path("openerp.glade"), 'win_preference', gettext.textdomain()) self.win = self.glade.get_widget('win_preference') self.win.set_icon(common.OPENERP_ICON) if not parent: parent = service.LocalService('gui.main').window self.win.set_transient_for(parent) self.parent = parent action_id = rpc.session.rpc_exec_auth('/object', 'execute', 'res.users', 'action_get', {}) action = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.actions.act_window', 'read', [action_id], False, rpc.session.context)[0] view_ids = [] if action.get('views', []): view_ids = [x[0] for x in action['views']] elif action.get('view_id', False): view_ids = [action['view_id'][0]] self.screen = Screen('res.users', view_type=[], window=parent) self.screen.add_view_id(view_ids[0], 'form', display=True) self.screen.load([rpc.session.uid]) self.screen.display(rpc.session.uid) vbox = self.glade.get_widget('preference_vbox') vbox.pack_start(self.screen.widget) self.win.set_title(_('Preferences')) self.win.show_all()
def __init__(self, parent=None): glade = gtk.glade.XML(common.terp_path('openerp.glade'), 'win_extension', gettext.textdomain()) self.win = glade.get_widget('win_extension') self.win.set_icon(common.OPENERP_ICON) model = gtk.ListStore( str, str, str ) self.treeview = glade.get_widget('treeview_extension') self.treeview.set_model(model) for index, text in enumerate(['Extension', 'Application', 'Print Processor']): renderer = gtk.CellRendererText() renderer.set_property( 'editable', True ) renderer.connect( 'edited', self._on_cell_renderer_edited ) column = gtk.TreeViewColumn( text, renderer, text=index ) column.set_resizable( True ) self.treeview.append_column( column ) dict = { 'on_button5_clicked' : self._sig_add, 'on_button6_clicked' : self._sig_remove, } for signal in dict: glade.signal_connect( signal, dict[signal] ) self.load_from_file()
def __init__(self, parent=None): glade = gtk.glade.XML(common.terp_path('openerp.glade'), 'win_extension', gettext.textdomain()) self.win = glade.get_widget('win_extension') self.win.set_transient_for(parent) self.win.set_icon(common.OPENERP_ICON) model = gtk.ListStore( str, str, str ) self.treeview = glade.get_widget('treeview_extension') self.treeview.set_model(model) for index, text in enumerate([_('Extension'), _('Application'), _('Print Processor')]): renderer = gtk.CellRendererText() renderer.set_property( 'editable', True ) renderer.connect( 'edited', self._on_cell_renderer_edited ) column = gtk.TreeViewColumn( text, renderer, text=index ) column.set_resizable( True ) self.treeview.append_column( column ) dict = { 'on_button5_clicked' : self._sig_add, 'on_button6_clicked' : self._sig_remove, } for signal in dict: glade.signal_connect( signal, dict[signal] ) self.load_from_file()
def __init__(self, view, model, res_id=False, domain=[], context={}, window=None, name=False): self.glade = glade.XML(common.terp_path("openerp.glade"),'win_tree_container',gettext.textdomain()) self.widget = self.glade.get_widget('win_tree_container') self.widget.show_all() self.model = view['model'] self.domain2 = domain if view.get('field_parent', False): self.domain = [] else: self.domain = domain self.view = view self.window=window self.context=context self.tree_res = view_tree.view_tree(view, [], res_id, True, context=context) self.tree_res.view.connect('row-activated', self.sig_open) sel = self.tree_res.view.get_selection() sel.connect('changed', self.expand_one) if not name: self.name = self.tree_res.name else: self.name = name self.vp = self.glade.get_widget('main_tree_sw') wid = self.glade.get_widget('widget_vbox') wid.show() widget_sc = self.glade.get_widget('win_tree_sc') widget_sc.connect('row-activated', self.sc_go) self.tree_sc = view_tree.view_tree_sc(widget_sc, self.model) self.handlers = { 'but_reload': self.sig_reload, 'but_switch': self.sig_edit, 'but_chroot': self.sig_chroot, 'but_open': self.sig_action, 'but_action': self.sig_action, 'but_print': self.sig_print, 'but_print_html': self.sig_print_html, 'but_close': self.sig_close, 'but_save_as': self.sig_save_as, } dict = { 'on_but_sc_go_clicked': self.sc_go, 'on_but_sc_add_clicked': self.sc_add, 'on_but_sc_del_clicked': self.sc_del, 'on_but_expand_collapse_clicked': self.expand_collapse_all, 'on_tbsc_clicked': self.sc_btn, } self.vp.add(self.tree_res.widget_get()) self.sig_reload() for signal in dict: self.glade.signal_connect(signal, dict[signal]) self.expand = True
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()
def __init__(self, window, parent, model, attrs={}): interface.widget_interface.__init__(self, window, parent, model, attrs) self.act_id = int(attrs['name']) res = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.actions.actions', 'read', [self.act_id], ['type'], rpc.session.context) if not res: raise Exception, 'ActionNotFound' type = res[0]['type'] self.action = rpc.session.rpc_exec_auth('/object', 'execute', type, 'read', [self.act_id], False, rpc.session.context)[0] if 'view_mode' in attrs: self.action['view_mode'] = attrs['view_mode'] if self.action['type'] == 'ir.actions.act_window': if not self.action.get('domain', False): self.action['domain'] = '[]' if attrs.get('domain', False): self.action['domain'] = attrs.get('domain') self.context = {'active_id': False, 'active_ids': []} self.context.update( tools.expr_eval(self.action.get('context', '{}'), self.context.copy())) self.domain = tools.expr_eval(self.action['domain'], self.context.copy()) view_id = [] if self.action['view_id']: view_id = [self.action['view_id'][0]] if self.action['view_type'] == 'form': mode = (self.action['view_mode'] or 'form,tree').split(',') self.screen = Screen(self.action['res_model'], view_type=mode, context=self.context, view_ids=view_id, domain=self.domain) self.win_gl = glade.XML(common.terp_path("openerp.glade"), 'widget_paned', gettext.textdomain()) self.win_gl.signal_connect('on_switch_button_press_event', self._sig_switch) self.win_gl.signal_connect('on_search_button_press_event', self._sig_search) self.win_gl.signal_connect('on_open_button_press_event', self._sig_open) label = self.win_gl.get_widget('widget_paned_lab') label.set_text( attrs.get('string', self.screen.current_view.title)) vbox = self.win_gl.get_widget('widget_paned_vbox') vbox.add(self.screen.widget) self.widget = self.win_gl.get_widget('widget_paned') self.widget.set_size_request(int(attrs.get('width', -1)), int(attrs.get('height', -1))) elif self.action['view_type'] == 'tree': pass #TODO
def __init__(self,window, model, node_attr, arrow_attr, attrs, screen): self.glade = gtk.glade.XML(common.terp_path("openerp.glade"),'widget_view_diagram', gettext.textdomain()) self.widget = self.glade.get_widget('widget_view_diagram') self.model = model self.screen = screen self.node = node_attr self.arrow = arrow_attr self.id = None self.window = xdot.DotWindow(window,self.widget, self.screen, node_attr, arrow_attr, attrs)
def __init__(self, window, parent, model, attrs={}): interface.widget_interface.__init__(self, window, parent, model, attrs) self.win_gl = glade.XML(common.terp_path("picture2.glade"),"widget_picture") self.widget = self.win_gl.get_widget('widget_picture') self.win_gl.signal_connect('on_picture_but_open_clicked', self.sig_add) self.win_gl.signal_connect('on_picture_but_clear_clicked', self.sig_clear) self.win_gl.signal_connect('on_picture_but_saveas_clicked', self.sig_save_as) #self.wid_text = self.win_gl.get_widget('ent_picture') self.wid_picture = self.win_gl.get_widget('widget_picture_view') self.value=False
def __init__(self, model, sel_multi=True, ids=[], context={}, domain=[], parent=None): self.model = model self.sel_multi = sel_multi self.ids = ids self.ctx = context 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'], show_search=True, domain=domain, context=context, parent=self.win, win_search=True) self.view = self.screen.current_view if self.screen.filter_widget.focusable: self.screen.filter_widget.focusable.grab_focus() self.title = _('OpenERP Search: %s') % self.screen.name self.title_results = _('OpenERP Search: %s (%%d result(s))') % ( self.screen.name, ) self.win.set_title(self.title) 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) self.view.widget_tree.connect('row_activated', self.sig_activate) self.view.widget_tree.connect('button_press_event', self.sig_button) self.screen.win_search_callback = self.update_title vp = gtk.Viewport() vp.set_shadow_type(gtk.SHADOW_NONE) vp.add(self.screen.widget) vp.show() self.sw = gtk.ScrolledWindow() self.sw.set_shadow_type(gtk.SHADOW_NONE) self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.sw.add(vp) self.sw.show() self.wid = self.glade.get_widget('win_search_vbox') self.wid.pack_start(self.sw) self.wid.show_all()
def __init__(self, name, parent, attrs={}, call=None): wid_int.wid_int.__init__(self, name, parent, attrs) win_gl = glade.XML(common.terp_path("openerp.glade"),"hbox_custom_filter",gettext.textdomain()) self.widget = win_gl.get_widget('hbox_custom_filter') #Changing the date format when using custom filter self.Dt_Tm_format = tools.user_locale_format.get_datetime_format(True) self.Dt_format = tools.user_locale_format.get_date_format() # Processing fields self.combo_fields = win_gl.get_widget('combo_fields') self.field_selection = {} fields = attrs.get('fields',None) for item in fields: self.field_selection[item[1].encode('utf-8')] = (item[0], item[2], item[3]) self.combo_fields.append_text(item[1]) self.combo_fields.set_active(0) # Processing operator combo self.combo_op = win_gl.get_widget('combo_operator') self.op_selection = {} for item in (['ilike', _('contains')], ['not ilike', _('doesn\'t contain')], ['=', _('is equal to')], ['<>',_('is not equal to')], ['>',_('greater than')], ['<',_('less than')], ['in',_('in')], ['not in',_('not in')], ): self.op_selection[item[1].encode('utf-8')] = item[0] self.combo_op.append_text(item[1]) self.combo_op.set_active(0) # Processing text value self.right_text = win_gl.get_widget('right_compare') # Processing Custom conditions self.condition_next = win_gl.get_widget('cond_custom') self.condition_next.set_active(0) self.condition_next.hide() # Processing Removal of panel self.remove_filter = win_gl.get_widget('remove_custom') self.remove_filter.set_relief(gtk.RELIEF_NONE) try: self.right_text.set_tooltip_markup(tools.to_xml(_("Enter Values separated by ',' if operator 'in' or 'not in' is chosen.\nFor Date and DateTime Formats, specify text in '%Y-%m-%d' and '%Y-%m-%d %H:%M:%S' formats respectively."))) except: pass self.remove_filter.connect('clicked',call,self)
def __init__(self, window, parent, model, attrs={}): interface.widget_interface.__init__(self, window, parent, model, attrs) self.win_gl = glade.XML(common.terp_path("openerp.glade"), "widget_textbox_tag", gettext.textdomain()) self.widget = self.win_gl.get_widget('widget_textbox_tag') self.tv = self.win_gl.get_widget('widget_textbox_tag_tv') self.tv.set_wrap_mode(gtk.WRAP_WORD) self.tv.connect('focus-out-event', lambda x, y: self._focus_out()) self.widget.show_all() self.tags = {} self.tags_dic = {} self.buf = self.tv.get_buffer() self.tagdict = {} self.buf.connect_after('insert-text', self.sig_insert_text) self.buf.connect('mark-set', self.sig_mark_set) self.value = '' # self.sizeButton = self.win_gl.get_widget('font_size') # self.colorButton =self.win_gl.get_widget('font_color') self.boldButton = self.win_gl.get_widget('toggle_bold') self.italicButton = self.win_gl.get_widget('toggle_italic') self.underlineButton = self.win_gl.get_widget('toggle_underline') self.strikethroughButton = self.win_gl.get_widget( 'toggle_strikethrough') self.internal_toggle = False self.setup_default_tags() self.win_gl.signal_connect('on_toggle_bold_toggled', self._toggle, [self.bold]) self.win_gl.signal_connect('on_toggle_italic_toggled', self._toggle, [self.italic]) self.win_gl.signal_connect('on_toggle_underline_toggled', self._toggle, [self.underline]) self.win_gl.signal_connect('on_toggle_strike_toggled', self._toggle, [self.strikethrough]) # self.win_gl.signal_connect('on_font_size_changed',self._font_changed) # self.win_gl.signal_connect('on_color_changed',self._color_changed) self.win_gl.signal_connect('on_font_button_clicked', self._font_changed) self.win_gl.signal_connect('on_color_button_clicked', self._color_changed) self.justify = gtk.JUSTIFY_LEFT self.leading = 14 + 7 self.win_gl.signal_connect('on_radiofill_toggled', self._toggle_justify, gtk.JUSTIFY_FILL) self.win_gl.signal_connect('on_radiocenter_toggled', self._toggle_justify, gtk.JUSTIFY_CENTER) self.win_gl.signal_connect('on_radioright_toggled', self._toggle_justify, gtk.JUSTIFY_RIGHT) self.win_gl.signal_connect('on_radioleft_toggled', self._toggle_justify, gtk.JUSTIFY_LEFT)
def __init__(self, window, model, node_attr, arrow_attr, attrs, screen): self.glade = gtk.glade.XML(common.terp_path("openerp.glade"), 'widget_view_diagram', gettext.textdomain()) self.widget = self.glade.get_widget('widget_view_diagram') self.model = model self.screen = screen self.node = node_attr self.arrow = arrow_attr self.id = None if self.screen.current_model: self.id = screen.current_model.id self.window = xdot.DotWindow(window, self.widget, self.screen, node_attr, arrow_attr, attrs) self.draw_diagram()
def field_pref_set(field, name, model, value, dependance=None, window=None): win_gl = glade.XML(common.terp_path('openerp.glade'), 'win_field_pref', gettext.textdomain()) if dependance is None: dependance = [] if window is None: window = service.LocalService('gui.main').window win = win_gl.get_widget('win_field_pref') win.set_transient_for(window) win.set_icon(common.OPENERP_ICON) ent = win_gl.get_widget('ent_field') ent.set_text(name) ent = win_gl.get_widget('ent_domain') ent.set_text(model) ent = win_gl.get_widget('ent_value') ent.set_text((value and str(value)) or '/') radio = win_gl.get_widget('radio_user_pref') vbox = win_gl.get_widget('pref_vbox') widgets = {} addwidget = False for (fname, fvalue, rname, rvalue) in dependance: if rvalue: addwidget = True widget = gtk.CheckButton(fname + ' = ' + str(rname)) widgets[(fvalue, rvalue)] = widget vbox.pack_start(widget) if not len(dependance) or not addwidget: vbox.pack_start(gtk.Label(_('Always applicable !'))) vbox.show_all() res = win.run() deps = False for nv in widgets.keys(): if widgets[nv].get_active(): deps = nv[0] + '=' + str(nv[1]) break window.present() win.destroy() if res == gtk.RESPONSE_OK: rpc.session.rpc_exec_auth('/object', 'execute', 'ir.values', 'set', 'default', deps, field, [(model, False)], value, True, False, False, radio.get_active(), True) return True return False
def __init__(self, model, sel_multi=True, ids=[], context={}, domain=[], parent=None): self.model = model self.sel_multi = sel_multi self.ids = ids self.ctx = context 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"], show_search=True, domain=domain, context=context, parent=self.win, win_search=True, ) self.view = self.screen.current_view if self.screen.filter_widget.focusable: self.screen.filter_widget.focusable.grab_focus() self.title = _("OpenERP Search: %s") % self.screen.name self.title_results = _("OpenERP Search: %s (%%d result(s))") % (self.screen.name,) self.win.set_title(self.title) 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) self.view.widget_tree.connect("row_activated", self.sig_activate) self.view.widget_tree.connect("button_press_event", self.sig_button) self.screen.win_search_callback = self.update_title vp = gtk.Viewport() vp.set_shadow_type(gtk.SHADOW_NONE) vp.add(self.screen.widget) vp.show() self.sw = gtk.ScrolledWindow() self.sw.set_shadow_type(gtk.SHADOW_NONE) self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.sw.add(vp) self.sw.show() self.wid = self.glade.get_widget("win_search_vbox") self.wid.pack_start(self.sw) self.wid.show_all()
def sig_goto(self, *args): if not self.modified_save(): return glade2 = glade.XML(common.terp_path("openerp.glade"),'dia_goto_id',gettext.textdomain()) widget = glade2.get_widget('goto_spinbutton') win = glade2.get_widget('dia_goto_id') widget.connect('key_press_event',self.get_event,win) win.set_transient_for(self.window) win.show_all() response = win.run() win.destroy() if response == gtk.RESPONSE_OK: self.get_resource(widget)
def field_pref_set(field, name, model, value, pwdfield, dependance=None, window=None): win_gl = glade.XML(common.terp_path('openerp.glade'), 'win_field_pref', gettext.textdomain()) if dependance is None: dependance = [] if window is None: window = service.LocalService('gui.main').window win = win_gl.get_widget('win_field_pref') win.set_transient_for(window) win.set_icon(common.OPENERP_ICON) ent = win_gl.get_widget('ent_field') ent.set_text(name) ent = win_gl.get_widget('ent_domain') ent.set_text(model) ent = win_gl.get_widget('ent_value') ent.set_text((value and str(value)) or '/') ent.set_visibility(not pwdfield) radio = win_gl.get_widget('radio_user_pref') vbox = win_gl.get_widget('pref_vbox') widgets = {} addwidget = False for (fname,fvalue,rname,rvalue) in dependance: if rvalue: addwidget = True widget = gtk.CheckButton(fname+' = '+str(rname)) widgets[(fvalue,rvalue)] = widget vbox.pack_start(widget) if not len(dependance) or not addwidget: vbox.pack_start(gtk.Label(_('Always applicable !'))) vbox.show_all() res = win.run() deps = False for nv in widgets.keys(): if widgets[nv].get_active(): deps = nv[0]+'='+str(nv[1]) break window.present() win.destroy() if res==gtk.RESPONSE_OK: rpc.session.rpc_exec_auth('/object', 'execute', 'ir.values', 'set', 'default', deps, field, [(model,False)], value, True, False, False, radio.get_active(), True) return True return False
def __init__(self, ids, model, view=None): self.glade = glade.XML(common.terp_path("openerp.glade"), "win_selection", gettext.textdomain()) self.win = self.glade.get_widget('win_selection') self.win.set_icon(common.OPENERP_ICON) self.parent = service.LocalService('gui.main').window self.win.set_transient_for(parent) self.ids = ids self.view = self.glade.get_widget('win_sel_tree') self.view.get_selection().set_mode('single') if view == None: fields = {'name': {'type': 'char', 'string': _('Name')}} xml = '''<?xml version="1.0"?> <tree string="%s"> <field name="name" string="%s"></field> </tree>''' % (_('Ressource Name'), _('Names')) else: fields = None xml = None p = parse.parse(fields) p.parse(xml, self.view) self.view.set_expander_column(self.view.get_column(1)) self.fields_order = p.fields_order types = [gobject.TYPE_STRING] for x in self.fields_order: types.append( fields_list_type.get(fields[x]['type'], gobject.TYPE_STRING)) self.model = gtk.ListStore(*types) if view == None: res_ids = rpc.session.rpc_exec_auth('/object', 'execute', model, 'name_get', self.ids, rpc.session.context) for res in res_ids: num = self.model.append() self.model.set(num, 0, res[0], 1, res[1]) else: pass # Todo self.view.set_model(self.model) self.view.show_all()
def concurrency(resource, id, context, parent=None): dia = glade.XML(common.terp_path("openerp.glade"),'dialog_concurrency_exception',gettext.textdomain()) win = dia.get_widget('dialog_concurrency_exception') if not parent: parent=service.LocalService('gui.main').window win.set_transient_for(parent) win.set_icon(OPENERP_ICON) res= win.run() parent.present() win.destroy() if res == gtk.RESPONSE_OK: return True if res == gtk.RESPONSE_APPLY: obj = service.LocalService('gui.window') obj.create(False, resource, id, [], 'form', None, context,'form,tree') return False
def __init__(self,window, parent, model, attrs={}, label=None): interface.widget_interface.__init__(self, window, parent, model, attrs, label_ebox=label) self.win_gl = glade.XML(common.terp_path("openerp.glade"),"widget_textbox_tag", gettext.textdomain()) self.widget = self.win_gl.get_widget('widget_textbox_tag') self.tv = self.win_gl.get_widget('widget_textbox_tag_tv') self.tv.set_wrap_mode(gtk.WRAP_WORD) self.tv.connect('focus-out-event', lambda x,y: self._focus_out()) self.widget.show_all() self.tags = {} self.tags_dic = {} self.buf = self.tv.get_buffer() self.tagdict = {} self.buf.connect_after('insert-text', self.sig_insert_text) self.buf.connect('mark-set', self.sig_mark_set) self.value='' # self.sizeButton = self.win_gl.get_widget('font_size') # self.colorButton =self.win_gl.get_widget('font_color') self.boldButton = self.win_gl.get_widget('toggle_bold') self.italicButton = self.win_gl.get_widget('toggle_italic') self.underlineButton = self.win_gl.get_widget('toggle_underline') self.strikethroughButton=self.win_gl.get_widget('toggle_strikethrough') self.internal_toggle = False self.setup_default_tags () self.win_gl.signal_connect('on_toggle_bold_toggled', self._toggle, [self.bold]) self.win_gl.signal_connect('on_toggle_italic_toggled', self._toggle, [self.italic]) self.win_gl.signal_connect('on_toggle_underline_toggled', self._toggle, [self.underline]) self.win_gl.signal_connect('on_toggle_strike_toggled', self._toggle, [self.strikethrough]) # self.win_gl.signal_connect('on_font_size_changed',self._font_changed) # self.win_gl.signal_connect('on_color_changed',self._color_changed) self.win_gl.signal_connect('on_font_button_clicked',self._font_changed) self.win_gl.signal_connect('on_color_button_clicked',self._color_changed) self.justify = gtk.JUSTIFY_LEFT self.leading = 14+7 self.win_gl.signal_connect('on_radiofill_toggled',self._toggle_justify, gtk.JUSTIFY_FILL) self.win_gl.signal_connect('on_radiocenter_toggled',self._toggle_justify, gtk.JUSTIFY_CENTER) self.win_gl.signal_connect('on_radioright_toggled',self._toggle_justify, gtk.JUSTIFY_RIGHT) self.win_gl.signal_connect('on_radioleft_toggled',self._toggle_justify, gtk.JUSTIFY_LEFT)
def __init__(self, window, parent, model, attrs={}): interface.widget_interface.__init__(self, window, parent, model, attrs) self.act_id=attrs['name'] res = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.actions.actions', 'read', [self.act_id], ['type'], rpc.session.context) if not res: raise Exception, 'ActionNotFound' type=res[0]['type'] self.action = rpc.session.rpc_exec_auth('/object', 'execute', type, 'read', [self.act_id], False, rpc.session.context)[0] if 'view_mode' in attrs: self.action['view_mode'] = attrs['view_mode'] if self.action['type']=='ir.actions.act_window': if not self.action.get('domain', False): self.action['domain']='[]' self.context = {'active_id': False, 'active_ids': []} self.context.update(eval(self.action.get('context', '{}'), self.context.copy())) a = self.context.copy() a['time'] = time a['datetime'] = datetime self.domain = tools.expr_eval(self.action['domain'], a) view_id = [] if self.action['view_id']: view_id = [self.action['view_id'][0]] if self.action['view_type']=='form': mode = (self.action['view_mode'] or 'form,tree').split(',') self.screen = Screen(self.action['res_model'], view_type=mode, context=self.context, view_ids = view_id, domain=self.domain) self.win_gl = glade.XML(common.terp_path("openerp.glade"), 'widget_paned', gettext.textdomain()) self.win_gl.signal_connect('on_switch_button_press_event', self._sig_switch) self.win_gl.signal_connect('on_search_button_press_event', self._sig_search) self.win_gl.signal_connect('on_open_button_press_event', self._sig_open) label=self.win_gl.get_widget('widget_paned_lab') label.set_text(attrs.get('string', self.screen.current_view.title)) vbox=self.win_gl.get_widget('widget_paned_vbox') vbox.add(self.screen.widget) self.widget=self.win_gl.get_widget('widget_paned') self.widget.set_size_request(int(attrs.get('width', -1)), int(attrs.get('height', -1))) elif self.action['view_type']=='tree': pass #TODO
def __init__(self, ids, model, view=None): self.glade = glade.XML(common.terp_path("openerp.glade"), "win_selection",gettext.textdomain()) self.win = self.glade.get_widget('win_selection') self.win.set_icon(common.OPENERP_ICON) self.parent = service.LocalService('gui.main').window self.win.set_transient_for(parent) self.ids = ids self.view = self.glade.get_widget('win_sel_tree') self.view.get_selection().set_mode('single') if view==None: fields = { 'name': {'type': 'char', 'string':_('Name')} } xml = '''<?xml version="1.0"?> <tree string="%s"> <field name="name" string="%s"></field> </tree>''' % (_('Ressource Name'), _('Names')) else: fields = None xml = None p = parse.parse(fields) p.parse(xml, self.view) self.view.set_expander_column(self.view.get_column(1)) self.fields_order = p.fields_order types=[ gobject.TYPE_STRING ] for x in self.fields_order: types.append( fields_list_type.get(fields[x]['type'], gobject.TYPE_STRING)) self.model = gtk.ListStore(*types) if view==None: res_ids = rpc.session.rpc_exec_auth('/object', 'execute', model, 'name_get', self.ids, rpc.session.context) for res in res_ids: num = self.model.append() self.model.set(num, 0, res[0], 1, res[1]) else: pass # Todo self.view.set_model(self.model) self.view.show_all()
def __init__(self, model, res_id=False, domain=None, view_type=None, view_ids=None, window=None, context=None, name=False, help={}, limit=100, auto_refresh=False, auto_search=True, search_view=None): if not view_type: view_type = ['form', 'tree'] if domain is None: domain = [] if view_ids is None: view_ids = [] if context is None: context = {} fields = {} self.model = model self.window = window self.previous_action = None self.glade = glade.XML(common.terp_path("openerp.glade"), 'win_form_container', gettext.textdomain()) self.widget = self.glade.get_widget('win_form_container') self.widget.show_all() self.fields = fields self.domain = domain self.context = context self.screen = Screen(self.model, view_type=view_type, context=self.context, view_ids=view_ids, domain=domain, help=help, hastoolbar=options.options['form.toolbar'], hassubmenu=options.options['form.submenu'], show_search=True, window=self.window, limit=limit, readonly=bool(auto_refresh), auto_search=auto_search, search_view=search_view) self.screen.signal_connect(self, 'record-message', self._record_message) self.screen.widget.show() oregistry.add_receiver('misc-message', self._misc_message) if not name: self.name = self.screen.current_view.title else: self.name = name vp = gtk.Viewport() vp.set_shadow_type(gtk.SHADOW_NONE) vp.add(self.screen.widget) vp.show() self.sw = gtk.ScrolledWindow() self.sw.set_shadow_type(gtk.SHADOW_NONE) self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.sw.add(vp) self.sw.show() self.has_backup = False self.backup = {} self.widget.pack_start(self.sw) self.handlers = { 'but_new': self.sig_new, 'but_copy': self.sig_copy, 'but_save': self.sig_save, 'but_save_as': self.sig_save_as, 'but_import': self.sig_import, 'but_print_repeat': self.sig_print_repeat, 'but_remove': self.sig_remove, 'but_search': self.sig_search, 'but_previous': self.sig_previous, 'but_next': self.sig_next, 'but_goto_id': self.sig_goto, 'but_log': self.sig_logs, 'but_print': self.sig_print, 'but_reload': self.sig_reload, 'but_print_html': self.sig_print_html, 'but_action': self.sig_action, 'but_switch': self.sig_switch, 'but_attach': self.sig_attach, 'but_close': self.sig_close, } if 'tree' in view_type: self.handlers['radio_tree'] = self.sig_switch_tree if 'form' in view_type: self.handlers['radio_form'] = self.sig_switch_form if 'graph' in view_type: self.handlers['radio_graph'] = self.sig_switch_graph if 'calendar' in view_type: self.handlers['radio_calendar'] = self.sig_switch_calendar if 'diagram' in view_type: self.handlers['radio_diagram'] = self.sig_switch_diagram if res_id: if isinstance(res_id, ( int, long, )): res_id = [res_id] self.screen.load(res_id) else: if self.screen.current_view.view_type == 'form': self.sig_new(autosave=False) if self.screen.current_view.view_type in ('tree', 'graph', 'calendar'): self.screen.search_filter() if auto_refresh and int(auto_refresh): gobject.timeout_add(int(auto_refresh) * 1000, self.sig_reload)
def __init__(self, view, model, res_id=False, domain=[], context={}, help={}, window=None, name=False): self.glade = glade.XML(common.terp_path("openerp.glade"),'win_tree_container',gettext.textdomain()) self.widget = self.glade.get_widget('win_tree_container') self.widget.show_all() self.model = view['model'] self.domain2 = domain if view.get('field_parent', False): self.domain = [] else: self.domain = domain self.view = view self.window=window self.context=context self.tree_res = view_tree.view_tree(view, [], res_id, True, context=context) self.tree_res.view.connect('row-activated', self.sig_open) sel = self.tree_res.view.get_selection() sel.connect('changed', self.expand_one) if not name: self.name = self.tree_res.name else: self.name = name self.vp = self.glade.get_widget('main_tree_sw') wid = self.glade.get_widget('widget_vbox') wid.show() widget_sc = self.glade.get_widget('win_tree_sc') widget_sc.connect('row-activated', self.sc_go) self.tree_sc = view_tree.view_tree_sc(widget_sc, self.model) self.handlers = { 'but_reload': self.sig_reload, 'but_switch': self.sig_edit, 'but_chroot': self.sig_chroot, 'but_open': self.sig_action, 'but_action': self.sig_action, 'but_print': self.sig_print, 'but_print_html': self.sig_print_html, 'but_close': self.sig_close, 'but_save_as': self.sig_save_as, } dict = { 'on_but_sc_go_clicked': self.sc_go, 'on_but_sc_add_clicked': self.sc_add, 'on_but_sc_del_clicked': self.sc_del, 'on_but_expand_collapse_clicked': self.expand_collapse_all, 'on_tbsc_clicked': self.sc_btn, } self.help = help self.help_frame = False wid = self.tree_res.widget_get() if self.help: action_tips = common.action_tips(self.help) self.help_frame = action_tips.help_frame if self.help_frame: vbox = gtk.VBox() vbox.pack_start(self.help_frame, expand=False, fill=False, padding=2) vbox.pack_end(wid) vbox.show_all() wid = vbox if self.help_frame: self.vp.add_with_viewport(wid) else: self.vp.add(wid) self.sig_reload() for signal in dict: self.glade.signal_connect(signal, dict[signal]) self.expand = True
def terp_survey(): if options['survey.position'] == SURVEY_VERSION: return False def color_set(widget, name): colour = widget.get_colormap().alloc_color( common.colors.get(name, 'white')) widget.modify_bg(gtk.STATE_ACTIVE, colour) widget.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("black")) widget.modify_base(gtk.STATE_NORMAL, colour) widget.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse("black")) widget.modify_text(gtk.STATE_INSENSITIVE, gtk.gdk.color_parse("black")) widnames = ('country', 'role', 'industry', 'employee', 'hear', 'system', 'opensource') winglade = glade.XML(common.terp_path("dia_survey.glade"), "dia_survey", gettext.textdomain()) win = winglade.get_widget('dia_survey') parent = service.LocalService('gui.main').window win.set_transient_for(parent) win.set_icon(OPENERP_ICON) for widname in widnames: wid = winglade.get_widget('combo_' + widname) wid.child.set_editable(False) email_widget = winglade.get_widget('entry_email') want_ebook_widget = winglade.get_widget('check_button_ebook') def toggled_cb(togglebutton, *args): value = togglebutton.get_active() color_set(email_widget, ('normal', 'required')[value]) want_ebook_widget.connect('toggled', toggled_cb) while True: res = win.run() if res == gtk.RESPONSE_OK: email = email_widget.get_text() want_ebook = want_ebook_widget.get_active() if want_ebook and not len(email): color_set(email_widget, 'invalid') else: company = winglade.get_widget('entry_company').get_text() phone = winglade.get_widget('entry_phone').get_text() name = winglade.get_widget('entry_name').get_text() city = winglade.get_widget('entry_city').get_text() result = "\ncompany: " + str(company) result += "\nname: " + str(name) result += "\nphone: " + str(phone) result += "\ncity: " + str(city) for widname in widnames: wid = winglade.get_widget('combo_' + widname) result += "\n" + widname + ": " + wid.child.get_text() result += "\nplan_use: " + str( winglade.get_widget('check_use').get_active()) result += "\nplan_sell: " + str( winglade.get_widget('check_sell').get_active()) result += "\nwant_ebook: " + str(want_ebook) buffer = winglade.get_widget('textview_comment').get_buffer() iter_start = buffer.get_start_iter() iter_end = buffer.get_end_iter() result += "\nnote: " + buffer.get_text(iter_start, iter_end, False) upload_data(email, result, type='SURVEY ' + str(SURVEY_VERSION)) options['survey.position'] = SURVEY_VERSION options.save() parent.present() win.destroy() common.message( _('Thank you for the feedback !\n\ Your comments have been sent to OpenERP.\n\ You should now start by creating a new database or\n\ connecting to an existing server through the "File" menu.')) break elif res == gtk.RESPONSE_CANCEL or gtk.RESPONSE_DELETE_EVENT: parent.present() win.destroy() common.message( _('Thank you for testing OpenERP !\n\ You should now start by creating a new database or\n\ connecting to an existing server through the "File" menu.')) break return True
def __init__(self, model, fields, preload = [], parent=None, local_context=None): self.glade = glade.XML(common.terp_path("openerp.glade"), 'win_import', gettext.textdomain()) self.glade.get_widget('import_csv_combo').set_active(0) self.win = self.glade.get_widget('win_import') self.model = model self.fields_data = {} self.invert = False self.context = local_context or {} if parent is None: parent = service.LocalService('gui.main').window self.win.set_transient_for(parent) self.win.set_icon(common.OPENERP_ICON) self.parent = parent self.autodetect_btn = self.glade.get_widget('button_autodetect') self.filechooser = self.glade.get_widget('import_csv_file') self.filechooser.set_current_folder( options.options['client.default_path']) self.filechooser.connect('selection-changed',self.file_changed) self.view1 = gtk.TreeView() self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.glade.get_widget('import_vp_left').add(self.view1) self.view2 = gtk.TreeView() self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.glade.get_widget('import_vp_right').add(self.view2) self.view1.set_headers_visible(False) self.view2.set_headers_visible(False) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Field name'), cell, text=0, background=2) self.view1.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Field name'), cell, text=0) self.view2.append_column(column) self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) for f in preload: self.model2.set(self.model2.append(), 0, f[1], 1, f[0]) self.fields = {} self.fields_invert = {} def model_populate(fields, prefix_node='', prefix=None, prefix_value='', level=2): fields_order = fields.keys() fields_order.sort(lambda x,y: -cmp(fields[x].get('string', ''), fields[y].get('string', ''))) for field in fields_order: if (fields[field].get('type','') not in ('reference',)) \ and (not fields[field].get('readonly', False) \ or not dict(fields[field].get('states', {}).get( 'draft', [('readonly', True)])).get('readonly', True)\ or not dict(fields[field].get('states', {}).get( field, [('readonly', True)])).get('readonly', True)): self.fields_data[prefix_node+field] = fields[field] st_name = prefix_value+fields[field]['string'] or field node = self.model1.insert(prefix, 0, [st_name, prefix_node+field, (fields[field].get('required', False) and '#ddddff') or 'white']) self.fields[prefix_node+field] = st_name self.fields_invert[st_name] = prefix_node+field if fields[field].get('type','') == 'one2many' and level>0: fields2 = rpc.session.rpc_exec_auth('/object', 'execute', fields[field]['relation'], 'fields_get', False, rpc.session.context) model_populate(fields2, prefix_node+field+'/', node, st_name+'/', level-1) if fields[field].get('relation',False) and level>0: #self.fields[field+':id'] = fields[field]['string'] #self.fields_invert[fields[field]['string']] = field+':id' model_populate({'/id':{'string':'ID'},'.id':{'string':_('Database ID')}}, \ prefix_node+field, node, st_name+'/', level-1) fields.update({'id':{'string':'ID'},'.id':{'string':_('Database ID')}}) model_populate(fields) #for f in fields: # self.model1.set(self.model1.append(), 1, f, 0, fields[f].get('string', 'unknown')) self.view1.set_model(self.model1) self.view2.set_model(self.model2) self.view1.show_all() self.view2.show_all() self.glade.signal_connect('on_but_unselect_all_clicked', self.sig_unsel_all) self.glade.signal_connect('on_but_select_all_clicked', self.sig_sel_all) self.glade.signal_connect('on_but_select_clicked', self.sig_sel) self.glade.signal_connect('on_but_unselect_clicked', self.sig_unsel) self.glade.signal_connect('on_but_autodetect_clicked', self.sig_autodetect)
def __init__(self, model, ids, fields, preload = [], parent=None, context=None): self.glade = glade.XML(common.terp_path("openerp.glade"), 'win_save_as', gettext.textdomain()) self.win = self.glade.get_widget('win_save_as') self.ids = ids self.model = model self.fields_data = {} self.fields = {} if context is None: context = {} self.context = context if parent is None: parent = service.LocalService('gui.main').window self.win.set_transient_for(parent) self.win.set_icon(common.OPENERP_ICON) self.parent = parent self.view1 = gtk.TreeView() self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.glade.get_widget('exp_vp1').add(self.view1) self.view2 = gtk.TreeView() self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.glade.get_widget('exp_vp2').add(self.view2) self.view1.set_headers_visible(False) self.view2.set_headers_visible(False) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Field Name'), cell, text=0, background=2) self.view1.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Field Name'), cell, text=0) self.view2.append_column(column) #for f in preload: # self.model2.set(self.model2.append(), 0, f[1], 1, f[0]) self.wid_import_compatible = self.glade.get_widget('import_compatible') self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.fields_original = fields self.model_populate(self.fields_original) self.view1.set_model(self.model1) self.view2.set_model(self.model2) self.view1.show_all() self.view2.show_all() self.wid_action = self.glade.get_widget('win_saveas_combo') self.wid_write_field_names = self.glade.get_widget('add_field_names_cb') action = self.wid_action.set_active(os.name!='nt') if os.name != 'nt': self.wid_action.remove_text(0) else: try: from win32com.client import Dispatch import pywintypes xlApp = Dispatch("Excel.Application") except Exception,e: if isinstance(e, pywintypes.com_error): action = self.wid_action.set_active(isinstance(e, pywintypes.com_error)) self.wid_action.remove_text(0) else: pass
def __init__(self, model, axis, fields, attrs): self.glade = gtk.glade.XML(common.terp_path("openerp.glade"),'widget_view_calendar', gettext.textdomain()) self.widget = self.glade.get_widget('widget_view_calendar') self._label_current = self.glade.get_widget('label_current') self._radio_month = self.glade.get_widget('radio_month') self._radio_week = self.glade.get_widget('radio_week') self._radio_day = self.glade.get_widget('radio_day') self._small_calendar = self.glade.get_widget('calendar_small') self._calendar_treeview = self.glade.get_widget('calendar_treeview') mode = attrs.get('mode','month') self.log = logging.getLogger('calender') self.fields = fields self.attrs = attrs self.axis = axis self.screen = None if mode == 'day': self._radio_day.set_active(True) elif mode == 'week': self._radio_week.set_active(True) else: self._radio_month.set_active(True) self.mode = mode self.modex = mode self.cal_model = TinyCalModel() self.cal_view = Calendar.Calendar(self.cal_model, mode) self.cal_view.connect('event-clicked', self._on_event_clicked) self.cal_view.connect('do_month_back_forward', self._back_forward) self.cal_view.connect('day-selected', self._change_small) vbox = self.glade.get_widget('cal_vbox') vbox.pack_start(self.cal_view) vbox.show_all() self.process = False self.glade.signal_connect('on_but_forward_clicked', self._back_forward, 1) self.glade.signal_connect('on_but_back_clicked', self._back_forward, -1) self.glade.signal_connect('on_but_today_clicked', self._today) self.glade.signal_connect('on_calendar_small_day_selected_double_click', self._change_small, False,False) self.glade.signal_connect('on_button_day_clicked', self._change_view, 'day') self.glade.signal_connect('on_button_week_clicked', self._change_view, 'week') self.glade.signal_connect('on_button_month_clicked', self._change_view, 'month') self.date = datetime.today() self.string = attrs.get('string', '') self.date_start = attrs.get('date_start') self.date_delay = attrs.get('date_delay') self.date_stop = attrs.get('date_stop') self.color_field = attrs.get('color') self.color_field_custom = attrs.get('color_custom', 'color') self.color_model = False self.color_filters = {} self.colors = {} self.day_length = int(attrs.get('day_length', 8)) self.models = None self.models_record_group = None if self.color_field: self.color_model = gtk.ListStore(str, str, str, gobject.TYPE_BOOLEAN) self._calendar_treeview.set_model(self.color_model) self._calendar_treeview.get_selection().set_mode(gtk.SELECTION_NONE) for c in (self.TV_COL_ID, self.TV_COL_COLOR): column = gtk.TreeViewColumn(None, gtk.CellRendererText(), text=c) self._calendar_treeview.append_column(column) column.set_visible(False) # Row toogle renderer = gtk.CellRendererToggle() renderer.set_property('activatable', True) renderer.connect('toggled', self._treeview_toggled, self.color_model, self.color_filters) column = gtk.TreeViewColumn(None, renderer) column.add_attribute(renderer, "active", self.TV_COL_TOGGLE) column.set_cell_data_func(renderer, self._treeview_setter) self._calendar_treeview.append_column(column) renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(None, renderer, text=self.TV_COL_LABEL) col_label = gtk.Label('') col_label.set_markup('<b>%s</b>' % self.fields[self.color_field]['string']) col_label.show() column.set_widget(col_label) column.set_cell_data_func(renderer, self._treeview_setter) self._calendar_treeview.append_column(column)
def execute_action(self, combo): flag = combo.get_active_text() combo_model = combo.get_model() active_id = combo.get_active() action_name = active_id != -1 and flag not in [ 'mf', 'blk', 'sf' ] and combo_model[active_id][2] # 'mf' Section manages Filters def clear_domain_ctx(): for key in self.old_ctx.keys(): if key in self.context_init: del self.context_init[key] for domain in self.latest_search: if domain in self.domain_init: self.domain_init.remove(domain) #append action domain to filter domain self.domain_init += self.action_domain if flag == 'mf': obj = service.LocalService('action.main') act = { 'name': 'Manage Filters', 'res_model': 'ir.filters', 'type': 'ir.actions.act_window', 'view_type': 'form', 'view_mode': 'tree,form', 'domain': '[(\'model_id\',\'=\',\'' + self.name + '\'),(\'user_id\',\'=\',' + str(rpc.session.uid) + ')]' } ctx = self.context.copy() for key in ('group_by', 'group_by_no_leaf'): if key in ctx: del ctx[key] value = obj._exec_action(act, {}, ctx) if flag in ['blk', 'mf']: self.screen_container.last_active_filter = False clear_domain_ctx() if flag == 'blk': self.search_filter() combo.set_active(0) return True #This section handles shortcut and action creation elif flag in ['sf']: glade2 = glade.XML(common.terp_path("openerp.glade"), 'dia_get_action', gettext.textdomain()) widget = glade2.get_widget('action_name') win = glade2.get_widget('dia_get_action') win.set_icon(common.OPENERP_ICON) lbl = glade2.get_widget('label157') win.set_size_request(300, 165) text_entry = glade2.get_widget('action_name') lbl.set_text('Filter Name:') table = glade2.get_widget('table8') info_lbl = gtk.Label( _('(Any existing filter with the \nsame name will be replaced)' )) table.attach(info_lbl, 1, 2, 2, 3, gtk.FILL, gtk.EXPAND) if self.screen_container.last_active_filter: text_entry.set_text(self.screen_container.last_active_filter) win.show_all() response = win.run() # grab a safe copy of the entered text before destroy() to avoid GTK bug https://bugzilla.gnome.org/show_bug.cgi?id=613241 action_name = widget.get_text() win.destroy() combo.set_active(0) if response == gtk.RESPONSE_OK and action_name: filter_domain = self.filter_widget and self.filter_widget.value.get( 'domain', []) filter_context = self.filter_widget and self.filter_widget.value.get( 'context', {}) values = { 'name': action_name, 'model_id': self.name, 'user_id': rpc.session.uid } if flag == 'sf': domain, context = self.screen_container.get_filter( action_name) for dom in eval(domain): if dom not in filter_domain: filter_domain.append(dom) groupby_list = eval(context).get( 'group_by', []) + filter_context.get('group_by', []) filter_context.update(eval(context)) if groupby_list: filter_context.update({'group_by': groupby_list}) values.update({ 'domain': str(filter_domain), 'context': str(filter_context), }) action_id = rpc.session.rpc_exec_auth( '/object', 'execute', 'ir.filters', 'create_or_replace', values, self.context) self.screen_container.fill_filter_combo( self.name, action_name) else: try: self.screen_container.last_active_filter = action_name filter_domain = flag and tools.expr_eval(flag) clear_domain_ctx() if combo.get_active() >= 0: combo_model = combo.get_model() val = combo_model[combo.get_active()][1] if val: self.old_ctx = eval(val) self.context_init.update(self.old_ctx) self.domain_init += filter_domain or [] if isinstance(self.domain_init, type([])): self.search_filter() self.reload() except Exception: return True
def __init__(self, model, axis, fields, attrs): self.glade = gtk.glade.XML(common.terp_path("openerp.glade"),'widget_view_calendar', gettext.textdomain()) self.widget = self.glade.get_widget('widget_view_calendar') self._label_current = self.glade.get_widget('label_current') self._radio_month = self.glade.get_widget('radio_month') self._radio_week = self.glade.get_widget('radio_week') self._radio_day = self.glade.get_widget('radio_day') self._small_calendar = self.glade.get_widget('calendar_small') self._calendar_treeview = self.glade.get_widget('calendar_treeview') self._radio_month.set_active(True) self.mode = 'month' self.fields = fields self.attrs = attrs self.axis = axis self.screen = None self.cal_model = TinyCalModel() self.cal_view = Calendar.Calendar(self.cal_model) self.cal_view.connect('event-clicked', self._on_event_clicked) self.cal_view.connect('do_month_back_forward', self._back_forward) self.cal_view.connect('day-selected', self._change_small) vbox = self.glade.get_widget('cal_vbox') vbox.pack_start(self.cal_view) vbox.show_all() self.process = False self.glade.signal_connect('on_but_forward_clicked', self._back_forward, 1) self.glade.signal_connect('on_but_back_clicked', self._back_forward, -1) self.glade.signal_connect('on_but_today_clicked', self._today) self.glade.signal_connect('on_calendar_small_day_selected_double_click', self._change_small) self.glade.signal_connect('on_button_day_clicked', self._change_view, 'day') self.glade.signal_connect('on_button_week_clicked', self._change_view, 'week') self.glade.signal_connect('on_button_month_clicked', self._change_view, 'month') self.date = DateTime.today() self.string = attrs.get('string', '') self.date_start = attrs.get('date_start') self.date_delay = attrs.get('date_delay') self.date_stop = attrs.get('date_stop') self.color_field = attrs.get('color') self.day_length = int(attrs.get('day_length', 8)) self.colors = {} self.models = None if self.color_field: model = gtk.ListStore(str, str, str) self._calendar_treeview.set_model(model) self._calendar_treeview.get_selection().set_mode(gtk.SELECTION_NONE) for c in (self.TV_COL_ID, self.TV_COL_COLOR): column = gtk.TreeViewColumn(None, gtk.CellRendererText(), text=c) self._calendar_treeview.append_column(column) column.set_visible(False) renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(None, renderer, text=self.TV_COL_LABEL) col_label = gtk.Label('') col_label.set_markup('<b>%s</b>' % self.fields[self.color_field]['string']) col_label.show() column.set_widget(col_label) column.set_cell_data_func(renderer, self._treeview_setter) self._calendar_treeview.append_column(column)
def __init__(self, model, ids, fields, preload=[], parent=None, context=None): self.glade = glade.XML(common.terp_path("openerp.glade"), 'win_save_as', gettext.textdomain()) self.win = self.glade.get_widget('win_save_as') self.ids = ids self.model = model self.fields_data = {} self.fields = {} if context is None: context = {} self.context = context if parent is None: parent = service.LocalService('gui.main').window self.win.set_transient_for(parent) self.win.set_icon(common.OPENERP_ICON) self.parent = parent self.view1 = gtk.TreeView() self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.glade.get_widget('exp_vp1').add(self.view1) self.view2 = gtk.TreeView() self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.glade.get_widget('exp_vp2').add(self.view2) self.view1.set_headers_visible(False) self.view2.set_headers_visible(False) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Field Name'), cell, text=0, background=2) self.view1.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Field Name'), cell, text=0) self.view2.append_column(column) #for f in preload: # self.model2.set(self.model2.append(), 0, f[1], 1, f[0]) self.wid_import_compatible = self.glade.get_widget('import_compatible') self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.fields_original = fields self.model_populate(self.fields_original) self.view1.set_model(self.model1) self.view2.set_model(self.model2) self.view1.show_all() self.view2.show_all() self.wid_action = self.glade.get_widget('win_saveas_combo') self.wid_write_field_names = self.glade.get_widget( 'add_field_names_cb') action = self.wid_action.set_active(os.name != 'nt') if os.name != 'nt': self.wid_action.remove_text(0) else: try: from win32com.client import Dispatch import pywintypes xlApp = Dispatch("Excel.Application") except Exception, e: if isinstance(e, pywintypes.com_error): action = self.wid_action.set_active( isinstance(e, pywintypes.com_error)) self.wid_action.remove_text(0) else: pass
def __init__(self, model, res_id=False, domain=None, view_type=None, view_ids=None, window=None, context=None, name=False, help={}, limit=100, auto_refresh=False, auto_search=True, search_view=None): if not view_type: view_type = ['form','tree'] if domain is None: domain = [] if view_ids is None: view_ids = [] if context is None: context = {} fields = {} self.model = model self.window = window self.previous_action = None self.glade = glade.XML(common.terp_path("openerp.glade"),'win_form_container',gettext.textdomain()) self.widget = self.glade.get_widget('win_form_container') self.widget.show_all() self.fields = fields self.domain = domain self.context = context self.screen = Screen(self.model, view_type=view_type, context=self.context, view_ids=view_ids, domain=domain,help=help, hastoolbar=options.options['form.toolbar'], hassubmenu=options.options['form.submenu'], show_search=True, window=self.window, limit=limit, readonly=bool(auto_refresh), auto_search=auto_search, search_view=search_view) self.screen.signal_connect(self, 'record-message', self._record_message) self.screen.widget.show() oregistry.add_receiver('misc-message', self._misc_message) if not name: self.name = self.screen.current_view.title else: self.name = name vp = gtk.Viewport() vp.set_shadow_type(gtk.SHADOW_NONE) vp.add(self.screen.widget) vp.show() self.sw = gtk.ScrolledWindow() self.sw.set_shadow_type(gtk.SHADOW_NONE) self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.sw.add(vp) self.sw.show() self.has_backup = False self.backup = {} self.widget.pack_start(self.sw) self.handlers = { 'but_new': self.sig_new, 'but_copy': self.sig_copy, 'but_save': self.sig_save, 'but_save_as': self.sig_save_as, 'but_import': self.sig_import, 'but_print_repeat': self.sig_print_repeat, 'but_remove': self.sig_remove, 'but_search': self.sig_search, 'but_previous': self.sig_previous, 'but_next': self.sig_next, 'but_goto_id': self.sig_goto, 'but_log': self.sig_logs, 'but_print': self.sig_print, 'but_reload': self.sig_reload, 'but_print_html': self.sig_print_html, 'but_action': self.sig_action, 'but_switch': self.sig_switch, 'but_attach': self.sig_attach, 'but_close': self.sig_close, } if 'tree' in view_type: self.handlers['radio_tree'] = self.sig_switch_tree if 'form' in view_type: self.handlers['radio_form'] = self.sig_switch_form if 'graph' in view_type: self.handlers['radio_graph'] = self.sig_switch_graph if 'calendar' in view_type: self.handlers['radio_calendar'] = self.sig_switch_calendar if 'diagram' in view_type: self.handlers['radio_diagram'] = self.sig_switch_diagram if res_id: if isinstance(res_id, (int, long,)): res_id = [res_id] self.screen.load(res_id) else: if self.screen.current_view.view_type == 'form': self.sig_new(autosave=False) if self.screen.current_view.view_type in ('tree', 'graph', 'calendar'): self.screen.search_filter() if auto_refresh and int(auto_refresh): gobject.timeout_add(int(auto_refresh) * 1000, self.sig_reload)
def terp_survey(): if options['survey.position']==SURVEY_VERSION: return False def color_set(widget, name): colour = widget.get_colormap().alloc_color(common.colors.get(name,'white')) widget.modify_bg(gtk.STATE_ACTIVE, colour) widget.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("black")) widget.modify_base(gtk.STATE_NORMAL, colour) widget.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse("black")) widget.modify_text(gtk.STATE_INSENSITIVE, gtk.gdk.color_parse("black")) widnames = ('country','role','industry','employee','hear','system','opensource') winglade = glade.XML(common.terp_path("dia_survey.glade"), "dia_survey", gettext.textdomain()) win = winglade.get_widget('dia_survey') parent = service.LocalService('gui.main').window win.set_transient_for(parent) win.set_icon(OPENERP_ICON) for widname in widnames: wid = winglade.get_widget('combo_'+widname) wid.child.set_editable(False) email_widget = winglade.get_widget('entry_email') want_ebook_widget = winglade.get_widget('check_button_ebook') def toggled_cb(togglebutton, *args): value = togglebutton.get_active() color_set(email_widget, ('normal', 'required')[value]) want_ebook_widget.connect('toggled', toggled_cb) while True: res = win.run() if res == gtk.RESPONSE_OK: email = email_widget.get_text() want_ebook = want_ebook_widget.get_active() if want_ebook and not len(email): color_set(email_widget, 'invalid') else: company = winglade.get_widget('entry_company').get_text() phone = winglade.get_widget('entry_phone').get_text() name = winglade.get_widget('entry_name').get_text() city = winglade.get_widget('entry_city').get_text() result = "\ncompany: "+str(company) result += "\nname: " + str(name) result += "\nphone: " + str(phone) result += "\ncity: " + str(city) for widname in widnames: wid = winglade.get_widget('combo_'+widname) result += "\n" + widname + ": " + wid.child.get_text() result += "\nplan_use: " + str(winglade.get_widget('check_use').get_active()) result += "\nplan_sell: " + str(winglade.get_widget('check_sell').get_active()) result += "\nwant_ebook: " + str(want_ebook) buffer = winglade.get_widget('textview_comment').get_buffer() iter_start = buffer.get_start_iter() iter_end = buffer.get_end_iter() result += "\nnote: " + buffer.get_text(iter_start, iter_end, False) upload_data(email, result, type='SURVEY '+str(SURVEY_VERSION)) options['survey.position']=SURVEY_VERSION options.save() parent.present() win.destroy() common.message(_('Thank you for the feedback !\n\ Your comments have been sent to OpenERP.\n\ You should now start by creating a new database or\n\ connecting to an existing server through the "File" menu.')) break elif res == gtk.RESPONSE_CANCEL or gtk.RESPONSE_DELETE_EVENT: parent.present() win.destroy() common.message(_('Thank you for testing OpenERP !\n\ You should now start by creating a new database or\n\ connecting to an existing server through the "File" menu.')) break return True
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()
def __init__(self, model, ids, fields, preload = [], parent=None, context=None): self.glade = glade.XML(common.terp_path("openerp.glade"), 'win_save_as', gettext.textdomain()) self.win = self.glade.get_widget('win_save_as') self.ids = ids self.model = model self.fields_data = {} if context is None: context = {} self.context = context if parent is None: parent = service.LocalService('gui.main').window self.win.set_transient_for(parent) self.win.set_icon(common.OPENERP_ICON) self.parent = parent self.view1 = gtk.TreeView() self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.glade.get_widget('exp_vp1').add(self.view1) self.view2 = gtk.TreeView() self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.glade.get_widget('exp_vp2').add(self.view2) self.view1.set_headers_visible(False) self.view2.set_headers_visible(False) cell = gtk.CellRendererText() column = gtk.TreeViewColumn('Field name', cell, text=0, background=2) self.view1.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn('Field name', cell, text=0) self.view2.append_column(column) self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) for f in preload: self.model2.set(self.model2.append(), 0, f[1], 1, f[0]) self.fields = {} def model_populate(fields, prefix_node='', prefix=None, prefix_value='', level=2): fields_order = fields.keys() fields_order.sort(lambda x,y: -cmp(fields[x].get('string', ''), fields[y].get('string', ''))) for field in fields_order: self.fields_data[prefix_node+field] = fields[field] if prefix_node: self.fields_data[prefix_node + field]['string'] = '%s%s' % (prefix_value, self.fields_data[prefix_node + field]['string']) st_name = fields[field]['string'] or field node = self.model1.insert(prefix, 0, [st_name, prefix_node+field, (fields[field].get('required', False) and '#ddddff') or 'white']) self.fields[prefix_node+field] = (st_name, fields[field].get('relation', False)) if fields[field].get('relation', False) and level>0: fields2 = rpc.session.rpc_exec_auth('/object', 'execute', fields[field]['relation'], 'fields_get', False, rpc.session.context) fields2.update({'id':{'string':'ID'},'db_id':{'string':'Database ID'}}) model_populate(fields2, prefix_node+field+'/', node, st_name+'/', level-1) fields.update({'id':{'string':'ID'},'db_id':{'string':'Database ID'}}) model_populate(fields) self.view1.set_model(self.model1) self.view2.set_model(self.model2) self.view1.show_all() self.view2.show_all() self.wid_action = self.glade.get_widget('win_saveas_combo') self.wid_write_field_names = self.glade.get_widget('add_field_names_cb') self.wid_import_compatible = self.glade.get_widget('import_compatible') action = self.wid_action.set_active(os.name!='nt') self.glade.signal_connect('on_but_unselect_all_clicked', self.sig_unsel_all) self.glade.signal_connect('on_but_select_all_clicked', self.sig_sel_all) self.glade.signal_connect('on_but_select_clicked', self.sig_sel) self.glade.signal_connect('on_but_unselect_clicked', self.sig_unsel) self.glade.signal_connect('on_but_predefined_clicked', self.add_predef) self.glade.signal_connect('on_but_delpredefined_clicked', self.del_export_list_btn) # Creating the predefined export view self.pref_export = gtk.TreeView() self.pref_export.append_column(gtk.TreeViewColumn('Export name', gtk.CellRendererText(), text=1)) self.pref_export.append_column(gtk.TreeViewColumn('Exported fields', gtk.CellRendererText(), text=2)) self.glade.get_widget('predefined_exports').add(self.pref_export) self.pref_export.connect("row-activated", self.sel_predef) self.pref_export.connect('key_press_event', self.del_export_list_key) # Fill the predefined export tree view and show everything self.fill_predefwin() self.pref_export.show_all()
def __init__(self, model, ids, fields, preload=[], parent=None, context=None): self.glade = glade.XML(common.terp_path("openerp.glade"), 'win_save_as', gettext.textdomain()) self.win = self.glade.get_widget('win_save_as') self.ids = ids self.model = model self.fields_data = {} if context is None: context = {} self.context = context if parent is None: parent = service.LocalService('gui.main').window self.win.set_transient_for(parent) self.win.set_icon(common.OPENERP_ICON) self.parent = parent self.view1 = gtk.TreeView() self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.glade.get_widget('exp_vp1').add(self.view1) self.view2 = gtk.TreeView() self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.glade.get_widget('exp_vp2').add(self.view2) self.view1.set_headers_visible(False) self.view2.set_headers_visible(False) cell = gtk.CellRendererText() column = gtk.TreeViewColumn('Field name', cell, text=0, background=2) self.view1.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn('Field name', cell, text=0) self.view2.append_column(column) self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) for f in preload: self.model2.set(self.model2.append(), 0, f[1], 1, f[0]) self.fields = {} def model_populate(fields, prefix_node='', prefix=None, prefix_value='', level=2): fields_order = fields.keys() fields_order.sort(lambda x, y: -cmp(fields[x].get('string', ''), fields[y].get('string', ''))) for field in fields_order: self.fields_data[prefix_node + field] = fields[field] if prefix_node: self.fields_data[prefix_node + field]['string'] = '%s%s' % ( prefix_value, self.fields_data[prefix_node + field]['string']) st_name = fields[field]['string'] or field node = self.model1.insert(prefix, 0, [ st_name, prefix_node + field, (fields[field].get('required', False) and '#ddddff') or 'white' ]) self.fields[prefix_node + field] = (st_name, fields[field].get( 'relation', False)) if fields[field].get('relation', False) and level > 0: fields2 = rpc.session.rpc_exec_auth( '/object', 'execute', fields[field]['relation'], 'fields_get', False, rpc.session.context) fields2.update({ 'id': { 'string': 'ID' }, 'db_id': { 'string': 'Database ID' } }) model_populate(fields2, prefix_node + field + '/', node, st_name + '/', level - 1) fields.update({ 'id': { 'string': 'ID' }, 'db_id': { 'string': 'Database ID' } }) model_populate(fields) self.view1.set_model(self.model1) self.view2.set_model(self.model2) self.view1.show_all() self.view2.show_all() self.wid_action = self.glade.get_widget('win_saveas_combo') self.wid_write_field_names = self.glade.get_widget( 'add_field_names_cb') self.wid_import_compatible = self.glade.get_widget('import_compatible') action = self.wid_action.set_active(os.name != 'nt') self.glade.signal_connect('on_but_unselect_all_clicked', self.sig_unsel_all) self.glade.signal_connect('on_but_select_all_clicked', self.sig_sel_all) self.glade.signal_connect('on_but_select_clicked', self.sig_sel) self.glade.signal_connect('on_but_unselect_clicked', self.sig_unsel) self.glade.signal_connect('on_but_predefined_clicked', self.add_predef) self.glade.signal_connect('on_but_delpredefined_clicked', self.del_export_list_btn) # Creating the predefined export view self.pref_export = gtk.TreeView() self.pref_export.append_column( gtk.TreeViewColumn('Export name', gtk.CellRendererText(), text=1)) self.pref_export.append_column( gtk.TreeViewColumn('Exported fields', gtk.CellRendererText(), text=2)) self.glade.get_widget('predefined_exports').add(self.pref_export) self.pref_export.connect("row-activated", self.sel_predef) self.pref_export.connect('key_press_event', self.del_export_list_key) # Fill the predefined export tree view and show everything self.fill_predefwin() self.pref_export.show_all()
def execute_action(self, combo): flag = combo.get_active_text() combo_model = combo.get_model() active_id = combo.get_active() action_name = active_id != -1 and flag not in ['mf','blk', 'sf'] and combo_model[active_id][2] # 'mf' Section manages Filters def clear_domain_ctx(): for key in self.old_ctx.keys(): if key in self.context_init: del self.context_init[key] for domain in self.latest_search: if domain in self.domain_init: self.domain_init.remove(domain) #append action domain to filter domain self.domain_init += self.action_domain if flag == 'mf': obj = service.LocalService('action.main') act={'name':'Manage Filters', 'res_model':'ir.filters', 'type':'ir.actions.act_window', 'view_type':'form', 'view_mode':'tree,form', 'domain':'[(\'model_id\',\'=\',\''+self.name+'\'),(\'user_id\',\'=\','+str(rpc.session.uid)+')]'} ctx = self.context.copy() for key in ('group_by','group_by_no_leaf'): if key in ctx: del ctx[key] value = obj._exec_action(act, {}, ctx) if flag in ['blk','mf']: self.screen_container.last_active_filter = False clear_domain_ctx() if flag == 'blk': self.search_filter() combo.set_active(0) return True #This section handles shortcut and action creation elif flag in ['sf']: glade2 = glade.XML(common.terp_path("openerp.glade"),'dia_get_action',gettext.textdomain()) widget = glade2.get_widget('action_name') win = glade2.get_widget('dia_get_action') win.set_icon(common.OPENERP_ICON) lbl = glade2.get_widget('label157') win.set_size_request(300, 165) text_entry = glade2.get_widget('action_name') lbl.set_text('Filter Name:') table = glade2.get_widget('table8') info_lbl = gtk.Label(_('(Any existing filter with the \nsame name will be replaced)')) table.attach(info_lbl,1,2,2,3, gtk.FILL, gtk.EXPAND) if self.screen_container.last_active_filter: text_entry.set_text(self.screen_container.last_active_filter) win.show_all() response = win.run() # grab a safe copy of the entered text before destroy() to avoid GTK bug https://bugzilla.gnome.org/show_bug.cgi?id=613241 action_name = widget.get_text() win.destroy() combo.set_active(0) if response == gtk.RESPONSE_OK and action_name: filter_domain = self.filter_widget and self.filter_widget.value.get('domain',[]) filter_context = self.filter_widget and self.filter_widget.value.get('context',{}) values = {'name':action_name, 'model_id':self.name, 'user_id':rpc.session.uid } if flag == 'sf': domain, context = self.screen_container.get_filter(action_name) for dom in eval(domain): if dom not in filter_domain: filter_domain.append(dom) groupby_list = eval(context).get('group_by',[]) + filter_context.get('group_by',[]) filter_context.update(eval(context)) if groupby_list: filter_context.update({'group_by':groupby_list}) values.update({'domain':str(filter_domain), 'context':str(filter_context), }) action_id = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.filters', 'create_or_replace', values, self.context) self.screen_container.fill_filter_combo(self.name, action_name) else: try: self.screen_container.last_active_filter = action_name filter_domain = flag and tools.expr_eval(flag) clear_domain_ctx() if combo.get_active() >= 0: combo_model = combo.get_model() val = combo_model[combo.get_active()][1] if val: self.old_ctx = eval(val) self.context_init.update(self.old_ctx) self.domain_init += filter_domain or [] if isinstance(self.domain_init,type([])): self.search_filter() self.reload() except Exception: return True