Skip to Content
Menu
This question has been flagged
2 Replies
1817 Views


Avatar
Discard
Author

how to create own custom field in cutom modual like this 'test' : fields.custom('string')

Best Answer

Hello Nikunj,


Py File:-

class custom_class(models.Model):

     _name = 'custom.class'


     name = fields.Char('Name')


XML file :-

<?xml version="1.0" encoding="utf-8"?>

<odoo> 

     <record id="custom_class_form_view" model="ir.ui.view">

         <field name="name">custom.class.form.view</field>

        <field name="model">custom.class</field>

         <field name="arch" type="xml">

             <form>

                 <sheet>

                     <group>

                         <field name="name"/>

                     </group>

                 </sheet>

             </form>

         </field>

     </record>


    <record id="custom_class_tree_view" model="ir.ui.view">

         <field name="name">custom.class.treeview</field>

        <field name="model">custom.class</field>

         <field name="arch" type="xml">

             <tree>

                 <field name="name"/>

             </tree>

         </field>

     </record>


    <record id="action_custom_class" model="ir.actions.act_window">

        <field name="name">Custom Class</field>

        <field name="res_model">custom.class</field>

        <field name="view_type">form</field>

        <field name="view_mode">tree,form</field>

    </record>


    <menuitem name="Custom Class" id="custom_class_menu" action="action_custom_class"/>


</odoo>



Hope it works for you.

Thanks,

Avatar
Discard

No its not works add the parent tag also in the menuitem

also add the menuitem tag first ,then add the parent

Best Answer

Refer Odoo Documentaion

https://www.odoo.com/documentation/8.0/

Avatar
Discard