Ejemplo n.º 1
0
    def on_start_editing(self, event, widget, path, background_area,
            cell_area, flags):
        
        if not self.__is_visible(widget, cell_area):
            return
        
        if (event is None) or ((event.type == gtk.gdk.BUTTON_PRESS) \
                or (event.type == gtk.gdk.KEY_PRESS \
                    and event.keyval == gtk.keysyms.space)):
            self.clicking = True
            widget.queue_draw()
            gtk.main_iteration()
            model=widget.screen.current_model
            if widget.screen.current_model.validate():
                id = widget.screen.save_current()
                if not self.attrs.get('confirm',False) or \
                        common.sur(self.attrs['confirm']):
                    button_type = self.attrs.get('type', 'workflow')
                    if button_type == 'workflow':
                        result = rpc.session.rpc_exec_auth('/object', 'exec_workflow',
                                                widget.screen.name,
                                                self.attrs['name'], id)
                        if type(result)==type({}):
                            if result['type']== 'ir.actions.act_window_close':
                                widget.screen.window.destroy()
                            else:
                                datas = {}
                                obj = service.LocalService('action.main')
                                obj._exec_action(result,datas)
                    elif button_type == 'object':
                        if not id:
                            return
                        result = rpc.session.rpc_exec_auth(
                            '/object', 'execute',
                            widget.screen.name,
                            self.attrs['name'],
                            [id], model.context_get()
                        )
                        datas = {}
                        obj = service.LocalService('action.main')
                        obj._exec_action(result,datas,context=widget.screen.context)

                    elif button_type == 'action':
                        obj = service.LocalService('action.main')
                        action_id = int(self.attrs['name'])
                        obj.execute(action_id, {'model':widget.screen.name, 'id': id or False,
                            'ids': id and [id] or [], 'report_type': 'pdf'}, context=widget.screen.context)
                    else:
                        raise Exception, 'Unallowed button type'
                    widget.screen.reload()
            else:
                widget.screen.display()
            self.emit("clicked", path)
            def timeout(self, widget):
                self.clicking = False
                widget.queue_draw()
            gobject.timeout_add(60, timeout, self, widget)
Ejemplo n.º 2
0
    def get_button_action(self, screen, id=None, attrs={}):

        """Arguments:
        screen : Screen to be worked upon
        id     : Id of the record for which the button is clicked
        attrs  : Button Attributes
        """
        if not id:
            id = self.id
        if not attrs.get('confirm', False) or common.sur(attrs['confirm']):
            button_type = attrs.get('type', 'workflow')
            obj = service.LocalService('action.main')

            if button_type == 'workflow':
                result = rpc.session.rpc_exec_auth('/object', 'exec_workflow',
                                                   self.resource, attrs['name'], self.id)
                if type(result)==type({}):
                    if result['type']== 'ir.actions.act_window_close':
                        screen.window.destroy()
                    else:
                        datas = {'ids':[id], 'id':id}
                        obj._exec_action(result, datas)
                elif type([]) == type(result):
                    datas = {'ids':[id]}
                    for rs in result:
                        obj._exec_action(rs, datas)

            elif button_type == 'object':
                if not self.id:
                    return
                context = self.context_get()
                if 'context' in attrs:
                    context.update(self.expr_eval(attrs['context'], check_load=False))
                result = rpc.session.rpc_exec_auth('/object', 'execute',
                                                   self.resource,attrs['name'], [id], context)
                if isinstance(result, dict):
                    if not result.get('nodestroy', False):
                        screen.window.destroy()
                    obj._exec_action(result, {}, context=context)

            elif button_type == 'action':
                action_id = int(attrs['name'])
                context = screen.context.copy()
                if 'context' in attrs:
                    context.update(self.expr_eval(attrs['context'], check_load=False))
                datas = {'model':self.resource,
                         'id': id or False,
                         'ids': id and [id] or [],
                         'report_type': 'pdf'
                         }
                obj.execute(action_id, datas, context=context)
            else:
                raise Exception, 'Unallowed button type'
            if screen.current_model and screen.current_view.view_type != 'tree':
                screen.reload()

            del screen
Ejemplo n.º 3
0
 def sig_remove(self, widget=None):
     ids = self.ids_get()
     if len(ids):
         if common.sur(_('Are you sure you want\nto remove this record?')):
             try:
                 rpc.session.rpc_exec_auth('/object', 'execute', self.model, 'unlink', ids)
                 self.sig_reload()
             except xmlrpclib.Fault, err:
                 common.message(_('Error removing resource!'))
Ejemplo n.º 4
0
 def sig_remove(self, widget=None):
     ids = self.ids_get()
     if len(ids):
         if common.sur(_('Are you sure you want\nto remove this record?')):
             try:
                 rpc.session.rpc_exec_auth('/object', 'execute', self.model, 'unlink', ids)
                 self.sig_reload()
             except xmlrpclib.Fault, err:
                 common.message(_('Error removing resource!'))
Ejemplo n.º 5
0
    def on_start_editing(self, event, widget, path, background_area,
            cell_area, flags):
        
        if not self.__is_visible(widget, cell_area):
            return
        
        if (event is None) or ((event.type == gtk.gdk.BUTTON_PRESS) \
                or (event.type == gtk.gdk.KEY_PRESS \
                    and event.keyval == gtk.keysyms.space)):
            self.clicking = True
            widget.queue_draw()
            gtk.main_iteration()
            model=widget.screen.current_model
            if widget.screen.current_model.validate():
                id = widget.screen.save_current()
                if not self.attrs.get('confirm',False) or \
                        common.sur(self.attrs['confirm']):
                    button_type = self.attrs.get('type', 'workflow')
                    if button_type == 'workflow':
                        result = rpc.session.rpc_exec_auth('/object', 'exec_workflow',
                                                widget.screen.name,
                                                self.attrs['name'], id)
                        if type(result)==type({}):
                            if result['type']== 'ir.actions.act_window_close':
                                widget.screen.window.destroy()
                            else:
                                datas = {}
                                obj = service.LocalService('action.main')
                                obj._exec_action(result,datas)
                    elif button_type == 'object':
                        if not id:
                            return
                        result = rpc.session.rpc_exec_auth(
                            '/object', 'execute',
                            widget.screen.name,
                            self.attrs['name'],
                            [id], model.context_get()
                        )
                        datas = {}
                        obj = service.LocalService('action.main')
                        obj._exec_action(result,datas,context=widget.screen.context)

                    elif button_type == 'action':
                        obj = service.LocalService('action.main')
                        action_id = int(self.attrs['name'])
                        obj.execute(action_id, {'model':widget.screen.name, 'id': id or False,
                            'ids': id and [id] or [], 'report_type': 'pdf'}, context=widget.screen.context)
                    else:
                        raise Exception, 'Unallowed button type'
                    widget.screen.reload()
            else:
                widget.screen.display()
            self.emit("clicked", path)
            def timeout(self, widget):
                self.clicking = False
                widget.queue_draw()
            gobject.timeout_add(60, timeout, self, widget)
Ejemplo n.º 6
0
 def _sig_remove(self, *args):
     _, event = args
     if event.type == gtk.gdk.BUTTON_PRESS:
         if self.screen.current_view.view_type == 'form':
             msg = 'Are you sure to remove this record ?'
         else:
             msg = 'Are you sure to remove those records ?'
         if common.sur(msg):
                 self.screen.remove()
                 if not self.screen.models.models:
                     self.screen.current_view.widget.set_sensitive(False)
Ejemplo n.º 7
0
    def get_button_action(self, screen, id=None, attrs={}):

        """Arguments:
        screen : Screen to be worked upon
        id     : Id of the record for which the button is clicked
        attrs  : Button Attributes
        """
        if not id:
            id = self.id
        if not attrs.get("confirm", False) or common.sur(attrs["confirm"]):
            button_type = attrs.get("type", "workflow")
            obj = service.LocalService("action.main")

            if button_type == "workflow":
                result = rpc.session.rpc_exec_auth("/object", "exec_workflow", self.resource, attrs["name"], self.id)
                if type(result) == type({}):
                    if result["type"] == "ir.actions.act_window_close":
                        screen.window.destroy()
                    else:
                        datas = {"ids": [id], "id": id}
                        obj._exec_action(result, datas)
                elif type([]) == type(result):
                    datas = {"ids": [id]}
                    for rs in result:
                        obj._exec_action(rs, datas)

            elif button_type == "object":
                if not self.id:
                    return
                context = self.context_get()
                if "context" in attrs:
                    context.update(self.expr_eval(attrs["context"], check_load=False))
                result = rpc.session.rpc_exec_auth("/object", "execute", self.resource, attrs["name"], [id], context)
                if isinstance(result, dict):
                    if not result.get("nodestroy", False):
                        screen.window.destroy()
                    obj._exec_action(result, {}, context=context)

            elif button_type == "action":
                action_id = int(attrs["name"])
                context = screen.context.copy()
                if "context" in attrs:
                    context.update(self.expr_eval(attrs["context"], check_load=False))
                datas = {"model": self.resource, "id": id or False, "ids": id and [id] or [], "report_type": "pdf"}
                obj.execute(action_id, datas, context=context)
            else:
                raise Exception, "Unallowed button type"
            if screen.current_model and screen.current_view.view_type != "tree":
                screen.reload()

            del screen
Ejemplo n.º 8
0
 def _sig_remove(self, *args):
     lst, event = args
     if event.type == gtk.gdk.BUTTON_PRESS:
         if self.screen.current_view.view_type == 'form':
             msg = _('Are you sure to remove this record ?')
         else:
             msg = _('Are you sure to remove those records ?')
         if common.sur(msg):
                 model = self.screen.current_model
                 model.signal('record-changed', model.parent)
                 self.screen.remove()
                 self.pager.reset_pager()
                 if not self.screen.models.models:
                     self.screen.current_view.widget.set_sensitive(False)
Ejemplo n.º 9
0
 def _sig_remove(self, *args):
     lst, event = args
     if event.type == gtk.gdk.BUTTON_PRESS:
         if self.screen.current_view.view_type == 'form':
             msg = _('Are you sure to remove this record ?')
         else:
             msg = _('Are you sure to remove those records ?')
         if common.sur(msg):
             model = self.screen.current_model
             model.signal('record-changed', model.parent)
             self.screen.remove()
             self.pager.reset_pager()
             if not self.screen.models.models:
                 self.screen.current_view.widget.set_sensitive(False)
Ejemplo n.º 10
0
 def sig_remove(self, widget=None):
     if not self.id_get():
         msg = _('Record is not saved ! \n Do you want to clear current record ?')
     else:
         if self.screen.current_view.view_type == 'form':
             msg = _('Are you sure to remove this record ?')
         else:
             msg = _('Are you sure to remove those records ?')
     if common.sur(msg):
         id = self.screen.remove(unlink=True)
         if not id:
             self.message_state(_('Resources cleared.'), color='darkgreen')
         else:
             self.message_state(_('Resources successfully removed.'), color='darkgreen')
     self.sig_reload()
Ejemplo n.º 11
0
 def sig_remove(self, widget=None):
     if not self.id_get():
         msg = _('Record is not saved ! \n Do You want to Clear Current Record ?')
     else:
         if self.screen.current_view.view_type == 'form':
             msg = _('Are you sure to remove this record ?')
         else:
             msg = _('Are you sure to remove those records ?')
     if common.sur(msg):
         id = self.screen.remove(unlink=True)
         if not id:
             self.message_state(_('Resources cleared.'), color='darkgreen')
         else:
             self.message_state(_('Resources successfully removed.'), color='darkgreen')
     self.sig_reload()
Ejemplo n.º 12
0
    def button_clicked(self, widget):
        model = self.form.screen.current_model
        self.form.set_value()
        button_type = self.attrs.get('special', '')

        if button_type == 'cancel':
            self.form.screen.window.destroy()
            if 'name' in self.attrs.keys():
                type_button = self.attrs.get('type', 'object')

                if type_button == 'action':
                    obj = service.LocalService('action.main')
                    action_id = int(self.attrs['name'])

                    context_action = self.form.screen.context.copy()

                    if 'context' in self.attrs:
                        context_action.update(
                            self.form.screen.current_model.expr_eval(
                                self.attrs['context'], check_load=False))

                    obj.execute(action_id, {
                        'model': self.form.screen.name,
                        'id': False,
                        'ids': [],
                        'report_type': 'pdf'
                    },
                                context=context_action)

                elif type_button == 'object':
                    result = rpc.session.rpc_exec_auth('/object', 'execute',
                                                       self.form.screen.name,
                                                       self.attrs['name'], [],
                                                       model.context_get())
                    datas = {}
                    obj = service.LocalService('action.main')
                    obj._exec_action(result,
                                     datas,
                                     context=self.form.screen.context)
                else:
                    raise Exception, 'Unallowed button type'

        elif model.validate():
            id = self.form.screen.save_current()
            if not self.attrs.get('confirm',False) or \
                    common.sur(self.attrs['confirm']):
                button_type = self.attrs.get('type', 'workflow')
                if button_type == 'workflow':
                    result = rpc.session.rpc_exec_auth('/object',
                                                       'exec_workflow',
                                                       self.form.screen.name,
                                                       self.attrs['name'], id)
                    if type(result) == type({}):
                        if result['type'] == 'ir.actions.act_window_close':
                            self.form.screen.window.destroy()
                        else:
                            datas = {'ids': [id]}
                            obj = service.LocalService('action.main')
                            obj._exec_action(result, datas)
                    elif type([]) == type(result):
                        datas = {
                            'ids': [id],
                            'model': self.form.screen.name,
                        }
                        obj = service.LocalService('action.main')
                        for rs in result:
                            obj._exec_action(rs, datas)

                elif button_type == 'object':
                    if not id:
                        return
                    context = model.context_get()
                    if 'context' in self.attrs:
                        context.update(
                            self.form.screen.current_model.expr_eval(
                                self.attrs['context'], check_load=False))

                    result = rpc.session.rpc_exec_auth('/object', 'execute',
                                                       self.form.screen.name,
                                                       self.attrs['name'],
                                                       [id], context)
                    if type(result) == type({}):
                        self.form.screen.window.destroy()
                        datas = {
                            'ids': [id],
                            'model': self.form.screen.name,
                        }
                        obj = service.LocalService('action.main')
                        obj._exec_action(result,
                                         datas,
                                         context=self.form.screen.context)

                elif button_type == 'action':
                    obj = service.LocalService('action.main')
                    action_id = int(self.attrs['name'])

                    context = self.form.screen.context.copy()

                    if 'context' in self.attrs:
                        context.update(
                            self.form.screen.current_model.expr_eval(
                                self.attrs['context'], check_load=False))

                    obj.execute(action_id, {
                        'model': self.form.screen.name,
                        'id': id or False,
                        'ids': id and [id] or [],
                        'report_type': 'pdf'
                    },
                                context=context)

                else:
                    raise Exception, 'Unallowed button type'
                self.form.screen.reload()
                self.warn('misc-message', '')
        else:
            self.warn('misc-message', _('Invalid form, correct red fields !'),
                      "red")
            self.form.screen.display()
Ejemplo n.º 13
0
    def button_clicked(self, widget):
        model = self.form.screen.current_model
        self.form.set_value()
        button_type = self.attrs.get('special', '')

        if button_type=='cancel':
            self.form.screen.window.destroy()
            if 'name' in self.attrs.keys():
                type_button = self.attrs.get('type','object')

                if type_button == 'action':
                    obj = service.LocalService('action.main')
                    action_id = int(self.attrs['name'])

                    context_action = self.form.screen.context.copy()
                    
                    if 'context' in self.attrs:
                        context_action.update(self.form.screen.current_model.expr_eval(self.attrs['context'], check_load=False))

                    obj.execute(action_id, {'model':self.form.screen.name, 'id': False, 'ids': [], 'report_type': 'pdf'}, context=context_action)

                elif type_button == 'object':
                    result = rpc.session.rpc_exec_auth(
                                '/object', 'execute',
                                self.form.screen.name,
                                self.attrs['name'],[], model.context_get())
                    datas = {}
                    obj = service.LocalService('action.main')
                    obj._exec_action(result,datas,context=self.form.screen.context)
                else:
                    raise Exception, 'Unallowed button type'
                
        elif model.validate():
            id = self.form.screen.save_current()
            if not self.attrs.get('confirm',False) or \
                    common.sur(self.attrs['confirm']):
                button_type = self.attrs.get('type', 'workflow')
                if button_type == 'workflow':
                    result = rpc.session.rpc_exec_auth('/object', 'exec_workflow',
                                            self.form.screen.name,
                                            self.attrs['name'], id)
                    if type(result)==type({}):
                        if result['type']== 'ir.actions.act_window_close':
                            self.form.screen.window.destroy()
                        else:
                            datas = {'ids':[id]}
                            obj = service.LocalService('action.main')
                            obj._exec_action(result, datas)
                    elif type([]) == type(result):
                        datas = {'ids' : [id], 'model' : self.form.screen.name, }
                        obj = service.LocalService('action.main')
                        for rs in result:
                            obj._exec_action(rs, datas)

                elif button_type == 'object':
                    if not id:
                        return
                    context = model.context_get()
                    if 'context' in self.attrs:
                        context.update(self.form.screen.current_model.expr_eval(self.attrs['context'], check_load=False))

                    result = rpc.session.rpc_exec_auth(
                        '/object', 'execute',
                        self.form.screen.name,
                        self.attrs['name'],
                        [id], context
                    )
                    if type(result)==type({}):
                        self.form.screen.window.destroy()
                        datas = {'ids' : [id], 'model' : self.form.screen.name, }
                        obj = service.LocalService('action.main')
                        obj._exec_action(result,datas,context=self.form.screen.context)

                elif button_type == 'action':
                    obj = service.LocalService('action.main')
                    action_id = int(self.attrs['name'])

                    context = self.form.screen.context.copy()

                    if 'context' in self.attrs:
                        context.update(self.form.screen.current_model.expr_eval(self.attrs['context'], check_load=False))

                    obj.execute(action_id, {'model':self.form.screen.name, 'id': id or False, 'ids': id and [id] or [], 'report_type': 'pdf'}, context=context)

                else:
                    raise Exception, 'Unallowed button type'
                self.form.screen.reload()
                self.warn('misc-message', '')
        else:
            common.warning(_('Invalid form, correct red fields !'), _('Error !') )
            self.warn('misc-message', _('Invalid form, correct red fields !'), "red")
            self.form.screen.display()
Ejemplo n.º 14
0
    def get_button_action(self, screen, id=None, attrs={}):
        """Arguments:
        screen : Screen to be worked upon
        id     : Id of the record for which the button is clicked
        attrs  : Button Attributes
        """
        if not id:
            id = self.id
        if not attrs.get('confirm', False) or common.sur(attrs['confirm']):
            button_type = attrs.get('type', 'workflow')
            obj = service.LocalService('action.main')

            if button_type == 'workflow':
                result = rpc.session.rpc_exec_auth('/object', 'exec_workflow',
                                                   self.resource,
                                                   attrs['name'], self.id)
                if type(result) == type({}):
                    if result['type'] == 'ir.actions.act_window_close':
                        screen.window.destroy()
                    else:
                        datas = {'ids': [id], 'id': id}
                        obj._exec_action(result, datas)
                elif type([]) == type(result):
                    datas = {'ids': [id]}
                    for rs in result:
                        obj._exec_action(rs, datas)

            elif button_type == 'object':
                if not self.id:
                    return
                context = self.context_get()
                if 'context' in attrs:
                    context.update(
                        self.expr_eval(attrs['context'], check_load=False))
                result = rpc.session.rpc_exec_auth('/object', 'execute',
                                                   self.resource,
                                                   attrs['name'], [id],
                                                   context)
                if isinstance(result, dict):
                    if not result.get('nodestroy', False):
                        screen.window.destroy()
                    obj._exec_action(result, {}, context=context)

            elif button_type == 'action':
                action_id = int(attrs['name'])
                context = screen.context.copy()
                if 'context' in attrs:
                    context.update(
                        self.expr_eval(attrs['context'], check_load=False))
                datas = {
                    'model': self.resource,
                    'id': id or False,
                    'ids': id and [id] or [],
                    'report_type': 'pdf'
                }
                obj.execute(action_id, datas, context=context)
            else:
                raise Exception, 'Unallowed button type'
            if screen.current_model and screen.current_view.view_type != 'tree':
                screen.reload()

            del screen