This question has been flagged
1 Reply
4544 Views

Hello, I am trying to create a new model and display a tree view for its records. Right now I am creating a simple hello world, but am having some problems.

My Module's python code is the following:

class SubscriptionBasket(models.Model):
    _name="subscription.basket"

    test1 = fields.Char("test 1", default = "Hello")
    test2 = fields.Char("test 2", default = "World")

And the model's view is:

<?xml version="1.0" encoding="UTF-8"?>
<odoo>

    <record id="subscription_basket_tree_view" model="ir.ui.view">
        <field name="name">subscription.basket.tree</field>
        <field name="model">subscription.basket</field>
        <field name="arch" type="xml">
            <tree string="Test">
                <field name="test1"/>
                <field name="test2"/>
            </tree>
        </field>
    </record>

    <record id="action_show_subscription_basket_tree" model="ir.actions.act_window">
        <field name="name">Items de Cesta</field>
        <field name="res_model">subscription.basket</field>
        <field name="view_type">tree</field>
        <field name="view_mode">tree</field>
        <field name="view_id" ref="subscription_basket_tree_view"/>
        <field name="target">current</field>
    </record>

    <menuitem
        id="subscription_basket_menuitem"
        action="action_show_subscription_basket_tree"
        name="Itens de Cesta"
        parent="stock.menu_stock_root"
        sequence="100"
    />
</odoo>


The menu item with the label "Itens de Cesta" was displayed on the stock module, just as I wanted, but when I click it, expecting to load the model's tree view, I get the following error:

Error:

Uncaught TypeError: Cannot read property 'type' of undefined

http://localhost:8069/web/content/13020-f14d50c/web.assets_backend.js:478

Traceback:

TypeError: Cannot read property 'type' of undefined

    at Class.get_default_view [as _super] (http://localhost:8069/web/content/13020-f14d50c/web.assets_backend.js:478:432)

    at Class.get_default_view (http://localhost:8069/web/content/13020-f14d50c/web.assets_backend.js:2192:227)

    at Class.get_default_view (http://localhost:8069/web/content/12996-d7813a7/web.assets_common.js:3819:371)

    at Class.init (http://localhost:8069/web/content/13020-f14d50c/web.assets_backend.js:472:752)

    at Class.prototype.(anonymous function) [as init] (http://localhost:8069/web/content/12996-d7813a7/web.assets_common.js:3816:488)

    at new Class (http://localhost:8069/web/content/12996-d7813a7/web.assets_common.js:3817:65)

    at Object.widget (http://localhost:8069/web/content/13020-f14d50c/web.assets_backend.js:451:80)

    at http://localhost:8069/web/content/13020-f14d50c/web.assets_backend.js:449:219

    at http://localhost:8069/web/content/12996-d7813a7/web.assets_common.js:802:681

    at fire (http://localhost:8069/web/content/12996-d7813a7/web.assets_common.js:796:299)


Can anyone point out what I am missing here?

Thank you!

Avatar
Discard
Best Answer

Hi,

Please update the record with id action_show_subscription_basket_tree,

<record id="action_show_subscription_basket_tree" model="ir.actions.act_window">
<field name="name">Items de Cesta</field>
<field name="res_model">subscription.basket</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="subscription_basket_tree_view"/>
</record>

Thanks

Avatar
Discard