Пример #1
0
 def add_predef(self, widget):
     name = common.ask(_('What is the name of this export?'))
     if not name:
         return
     iter = self.model2.get_iter_root()
     fields = []
     while iter:
         field_name = self.model2.get_value(iter, 1)
         fields.append(field_name)
         iter = self.model2.iter_next(iter)
     try:
         new_id, = RPCExecute('model', 'ir.export', 'create', [{
                 'name': name,
                 'resource': self.model,
                 'export_fields': [('create', [{
                                     'name': x,
                                     } for x in fields])],
                 }])
     except RPCException:
         return
     self.predef_model.append((
         new_id,
         fields,
         name))
     self.pref_export.set_model(self.predef_model)
 def run(self):
     "Run the window"
     if not self.win:
         return False
     res = False
     while True:
         if self.win.run() == gtk.RESPONSE_OK:
             if self.screen.current_record.validate():
                 vals = copy.copy(self.screen.get(get_modifiedonly=True))
                 if "password" in vals:
                     password = common.ask(_("Current Password:"******"model", "res.user", "set_preferences", vals, password)
                 except RPCException:
                     continue
                 res = True
                 break
         else:
             break
     self.parent.present()
     self.win.destroy()
     return res
Пример #3
0
    def addreplace_predef(self, widget):
        iter = self.model2.get_iter_first()
        fields = []
        while iter:
            field_name = self.model2.get_value(iter, 1)
            fields.append(field_name)
            iter = self.model2.iter_next(iter)
        if not fields:
            return

        selection = self.pref_export.get_selection().get_selected()
        if selection is None:
            return
        model, iter_ = selection
        if iter_ is None:
            pref_id = None
            name = common.ask(_('What is the name of this export?'))
            if not name:
                return
        else:
            pref_id = model.get_value(iter_, 0)
            name = model.get_value(iter_, 2)
            override = common.sur(_("Override '%s' definition?") % name)
            if not override:
                return
        try:
            if not pref_id:
                pref_id, = RPCExecute(
                    'model',
                    'ir.export',
                    'create', [{
                        'name':
                        name,
                        'resource':
                        self.model,
                        'export_fields': [('create', [{
                            'name': x,
                        } for x in fields])],
                    }],
                    context=self.context)
            else:
                RPCExecute('model',
                           'ir.export',
                           'update', [pref_id],
                           fields,
                           context=self.context)
        except RPCException:
            return
        clear_cache('model.%s.view_toolbar_get' % self.model)
        if iter_ is None:
            self.predef_model.append((pref_id, fields, name))
        else:
            model.set_value(iter_, 0, pref_id)
            model.set_value(iter_, 1, fields)
Пример #4
0
 def response(self, win, response_id):
     if response_id == gtk.RESPONSE_OK:
         if self.screen.current_record.validate():
             vals = copy.copy(self.screen.get())
             if "password" in vals:
                 password = common.ask(_("Current Password:"******"model", "res.user", "set_preferences", vals, password)
             except RPCException:
                 return
     self.parent.present()
     self.destroy()
     self.callback()
Пример #5
0
 def response(self, win, response_id):
     if response_id == gtk.RESPONSE_OK:
         if self.screen.current_record.validate():
             vals = copy.copy(self.screen.get())
             if 'password' in vals:
                 password = common.ask(_('Current Password:'******'model', 'res.user', 'set_preferences', vals,
                            password)
             except RPCException:
                 return
     self.parent.present()
     self.destroy()
     self.callback()
Пример #6
0
 def icon_press(self, widget, icon_pos, event):
     if icon_pos == 1:
         icon_stock = self.search_entry.get_icon_stock(icon_pos)
         model_name = self.screen.model_name
         if icon_stock == 'tryton-unstar':
             text = self.get_text()
             if not text:
                 return
             name = common.ask(_('Bookmark Name:'))
             if not name:
                 return
             domain = self.screen.domain_parser.parse(text)
             common.VIEW_SEARCH.add(model_name, name, domain)
             self.set_text(self.screen.domain_parser.string(domain))
         elif icon_stock == 'tryton-star':
             id_ = self.bookmark_match()
             common.VIEW_SEARCH.remove(model_name, id_)
         # Refresh icon and bookmark button
         self.bookmark_match()
Пример #7
0
    def addreplace_predef(self, widget):
        iter = self.model2.get_iter_root()
        fields = []
        while iter:
            field_name = self.model2.get_value(iter, 1)
            fields.append(field_name)
            iter = self.model2.iter_next(iter)
        if not fields:
            return

        selection = self.pref_export.get_selection().get_selected()
        if selection is None:
            return
        model, iter_ = selection
        if iter_ is None:
            pref_id = None
            name = common.ask(_("What is the name of this export?"))
            if not name:
                return
        else:
            pref_id = model.get_value(iter_, 0)
            name = model.get_value(iter_, 2)
            override = common.sur(_("Override '%s' definition?") % name)
            if not override:
                return
        try:
            new_id, = RPCExecute(
                "model",
                "ir.export",
                "create",
                [{"name": name, "resource": self.model, "export_fields": [("create", [{"name": x} for x in fields])]}],
                context=self.context,
            )
            if pref_id:
                RPCExecute("model", "ir.export", "delete", [pref_id], context=self.context)
        except RPCException:
            return
        if iter_ is None:
            self.predef_model.append((new_id, fields, name))
        else:
            model.set_value(iter_, 0, new_id)
            model.set_value(iter_, 1, fields)
Пример #8
0
 def icon_press(self, widget, icon_pos, event):
     if icon_pos == 1:
         icon_stock = self.search_entry.get_icon_stock(icon_pos)
         model_name = self.screen.model_name
         if icon_stock == 'tryton-unstar':
             text = self.get_text()
             if not text:
                 return
             name = common.ask(_('Bookmark Name:'))
             if not name:
                 return
             domain = self.screen.domain_parser.parse(text)
             common.VIEW_SEARCH.add(model_name, name, domain)
             self.set_text(self.screen.domain_parser.string(domain))
         elif icon_stock == 'tryton-star':
             id_ = self.bookmark_match()
             common.VIEW_SEARCH.remove(model_name, id_)
         # Refresh icon and bookmark button
         self.bookmark_match()
         self.but_bookmark.set_sensitive(bool(list(self.bookmarks())))
Пример #9
0
 def icon_press(self, widget, icon_pos, event):
     if icon_pos == gtk.ENTRY_ICON_PRIMARY:
         self.search_box(widget)
     elif icon_pos == gtk.ENTRY_ICON_SECONDARY:
         model_name = self.screen.model_name
         id_ = self.bookmark_match()
         if not id_:
             text = self.get_text()
             if not text:
                 return
             name = common.ask(_('Bookmark Name:'))
             if not name:
                 return
             domain = self.screen.domain_parser.parse(text)
             common.VIEW_SEARCH.add(model_name, name, domain)
             self.set_text(self.screen.domain_parser.string(domain))
         else:
             common.VIEW_SEARCH.remove(model_name, id_)
         # Refresh icon and bookmark button
         self.bookmark_match()
         self.but_bookmark.set_sensitive(bool(list(self.bookmarks())))
Пример #10
0
 def add_predef(self, widget):
     name = common.ask(_('What is the name of this export?'))
     if not name:
         return
     iter = self.model2.get_iter_root()
     fields = []
     while iter:
         field_name = self.model2.get_value(iter, 1)
         fields.append(field_name)
         iter = self.model2.iter_next(iter)
     try:
         new_id, = RPCExecute('model', 'ir.export', 'create', [{
             'name':
             name,
             'resource':
             self.model,
             'export_fields': [('create', [{
                 'name': x,
             } for x in fields])],
         }])
     except RPCException:
         return
     self.predef_model.append((new_id, fields, name))
     self.pref_export.set_model(self.predef_model)