Home > database >  Creating your own "view" without auxiliary tags - ODOO
Creating your own "view" without auxiliary tags - ODOO

Time:07-15

I have a question - is it possible to make my own view without using auxiliary tags? For example, I want to make my own table (or multiple tables on the same page) Is it possible to implement this without using the "tree" tag?

CodePudding user response:

Yes you can, The Odoo team talked about it in one of their livestreams.

You basically inherit the ir.ui.view model
and under /static/src/js you define the view like:

odoo.define('hello_world_view.HelloWorldView', function (require) {
"use strict";

var HelloWorldRenderer = AbstractRenderer.extend({
    className: "o_hello_world_view",
    _render: function () {
        //render code
    }
}

You will also need to extend the rest of the js methods
Then you will need to import the js file:

<template id="assets_backend" name="hello world assets" inherit_id="web.assets_backend">
    <xpath expr="." position="inside">
        <script type="text/javascript" src="/hello_world_view/static/src/js/hello_world_view.js"/>
        <link rel="stylesheet" type="text/scss" href="/hello_world_view/static/src/scss/hello_world_view.scss"/>
    </xpath>
</template>

And finally you can call your view like:

 <record model="ir.actions.act_window" id="first_hello_world_view">
        <field name="name">Hello World</field>
        <field name="res_model">res.partner</field>
        <field name="view_mode">hello_world</field>
        <field name="view_id" ref="hello_world_view_1"/>
    </record>

If you need to go into detail you can watch the stream here

And this is a link to the github repo for for the full code of this example.

  • Related