示例#1
0
    def create_view(self, view_id=False, xpath_expr=None, **kw):

        view_id = int(view_id)

        proxy = rpc.RPCProxy('ir.ui.view')
        res = proxy.read([view_id], ['model', 'type', 'arch'])[0]

        model = res['model']
        view_type = res['type']

        error = None
        record = None

        if view_id:

            doc = xml.dom.minidom.parseString(res['arch'].encode('utf-8'))
            node = utils.xml_locate(xpath_expr, doc)[0]
            new_node = doc.createElement('view')

            if node.localName == 'field':

                data = {
                    'name': res['model'] + '.' +
                    str(random.randint(0, 100000)) + '.inherit',
                    'model': res['model'],
                    'priority': 16,
                    'type': view_type,
                    'inherit_id': view_id
                }

                arch = """<?xml version="1.0"?>
                <field name="%s" position="after">
                </field>""" % (node.getAttribute('name'))

                data['arch'] = arch

                try:
                    view_id = proxy.create(data)
                    record = self.get_node_instance(new_node, model, view_id,
                                                    view_type).get_record()
                    node.setAttribute('position', 'after')
                    record['children'] = [
                        self.get_node_instance(node, model, view_id,
                                               view_type).get_record()
                    ]

                except:
                    error = _("Unable to create inherited view.")
            else:
                error = _("Can't create inherited view here.")

        else:
            error = _("Not implemented yet!")

        try:
            cache.clear()
        except Exception:
            pass

        return dict(record=record, error=error)
示例#2
0
    def create_view(self, view_id=False, xpath_expr=None, **kw):

        view_id = int(view_id)

        proxy = rpc.RPCProxy('ir.ui.view')
        res = proxy.read([view_id], ['model', 'type', 'arch'])[0]

        model = res['model']
        view_type = res['type']

        error = None
        record = None

        if view_id:

            doc = xml.dom.minidom.parseString(res['arch'].encode('utf-8'))
            node = utils.xml_locate(xpath_expr, doc)[0]
            new_node = doc.createElement('view')

            if node.localName == 'field':

                data = {'name' : res['model'] + '.' + str(random.randint(0, 100000)) + '.inherit',
                        'model' : res['model'],
                        'priority' : 16,
                        'type' : view_type,
                        'inherit_id' : view_id}

                arch = """<?xml version="1.0"?>
                <field name="%s" position="after">
                </field>""" % (node.getAttribute('name'))

                data['arch'] = arch

                try:
                    view_id = proxy.create(data)
                    record = self.get_node_instance(new_node, model, view_id, view_type).get_record()
                    node.setAttribute('position', 'after')
                    record['children'] = [self.get_node_instance(node, model, view_id, view_type).get_record()]

                except:
                    error = _("Unable to create inherited view.")
            else:
                error = _("Can't create inherited view here.")

        else:
            error = _("Not implemented yet!")

        try:
            cache.clear()
        except Exception:
            pass

        return dict(record=record, error=error)
示例#3
0
    def remove_view(self, view_id, **kw):

        view_id = int(view_id)

        if view_id:
            rpc.RPCProxy('ir.ui.view').unlink(view_id)

        try:
            cache.clear()
        except Exception:
            pass

        return dict()
示例#4
0
    def remove_view(self, view_id, **kw):

        view_id = int(view_id)

        if view_id:
            rpc.RPCProxy('ir.ui.view').unlink(view_id)

        try:
            cache.clear()
        except Exception:
            pass

        return dict()
示例#5
0
        elif _terp_what == "remove":
            pnode = node.parentNode
            pnode.removeChild(node)

        if _terp_what != 'remove':
            node_instance = self.get_node_instance(new_node or node, model=model, view_id=view_id, view_type=view_type)
            node_instance.children = self.parse(new_node or node, model, view_id, view_type)
            record = node_instance.get_record()

        try:
            proxy.write([view_id], {'arch': doc.toxml(encoding="utf-8")})
        except Exception:
            return dict(error=_("Unable to update the view."))

        try:
            cache.clear()
        except Exception:
            pass

        return dict(record=record)

    @expose(methods=('POST',))
    def update_dashboard(self, view_id, dst, src, ref=None):
        error = None

        view_id = int(view_id)

        views = rpc.RPCProxy('ir.ui.view')
        data = views.read([view_id])[0]

        doc = xml.dom.minidom.parseString(data['arch'].encode('utf-8'))
示例#6
0
 def clear_cache(self):
     cache.clear()
     raise redirect('/')
示例#7
0
 def clear_cache(self):
     cache.clear()
     raise redirect('/')
示例#8
0
        if _terp_what != 'remove':
            node_instance = self.get_node_instance(new_node or node,
                                                   model=model,
                                                   view_id=view_id,
                                                   view_type=view_type)
            node_instance.children = self.parse(new_node or node, model,
                                                view_id, view_type)
            record = node_instance.get_record()

        try:
            proxy.write([view_id], {'arch': doc.toxml(encoding="utf-8")})
        except Exception:
            return dict(error=_("Unable to update the view."))

        try:
            cache.clear()
        except Exception:
            pass

        return dict(record=record)

    @expose(methods=('POST', ))
    def update_dashboard(self, view_id, dst, src, ref=None):
        error = None

        view_id = int(view_id)

        views = rpc.RPCProxy('ir.ui.view')
        data = views.read([view_id])[0]

        doc = xml.dom.minidom.parseString(data['arch'].encode('utf-8'))