Thursday 29 September 2016

How To create simple module in odoo

How To create simple module in odoo


If you are new in odoo/openerp developer then you can easily develop your own module using below step

Create One folder and give proper name like student
1)You have to create __openerp__.py file.
In that you have to just copy below code and change as per your requirements.
{
    "name": "Demo Student",
    "version": "8.0",
    "author": "Module Author Name",
    "website": "Write your company website",
    "category": "Write module category like sale,project, hr etc.",
    "description": """ Write Your module description here.""",
    "depends": ['base','sale'],
    "data": [
            "student_view.xml",
    ],
    'demo': [],

    'test': [ ],

    "installable": True,
    "auto_install": False,
    "application": True,
}
2) You have to create simple __init__.py file
In that you have to include some file which in that you have to defines fields or some other code.
import student

Example
File name is student.py
Copy below code in your file
from openerp import models, api, fields

class student_student(models.Model):
_name = 'student.student'

fname = fields.Char('First Name')
mname = fields.Char('Middle Name')
lname = fields.Char('Last Name')

3) Create simple view file like below
<?xml version="1.0" encoding="utf-8"?>
<openerp>
   <data>

    <record id="student_form_view" model="ir.ui.view">
           <field name="name">student.form</field>
           <field name="model">student.student</field>
           <field name="arch" type="xml">
               <form string="Student">
                   <sheet>
                    <group>
                        <field name="fname" class="oe_inline"/>
                        <field name="mname" class="oe_inline"/>
                        <field name="lname" class="oe_inline"/>
                       </group>
                   </sheet>
               </form>
           </field>
       </record>

       <record id="student_action" model="ir.actions.act_window">
           <field name="name">Student</field>
           <field name="type">ir.actions.act_window</field>
           <field name="res_model">student.student</field>
           <field name="view_mode">tree,form</field>
           <field name="view_type">form</field>
           <field name="view_id" ref="student_form_view"/>
       </record>

       <menuitem action="student_action"
           id="menu_student_action"
           parent="base.menu_product" sequence="1"/>
</data>
</openerp>


4) Now you can update list of module in setting page and search your module and install it.

5) You can see your menu name sale->products->Student

5 comments:

  1. Read more about how to create modules in odoo: http://learnopenerp.blogspot.com/2016/03/how-to-create-and-install-modules-in.html

    ReplyDelete
  2. Can You Please Guide How i can Add New Field To Existing Module...

    I want to add permanent field with changes in code files.
    Not By Web Interface [x_field]

    ReplyDelete
  3. Seems like you are fond of writing since a long, therefore your posted content is well formulated in a proper way of writing. It's an amazing experience to read your blog post as you have shared a piece of meaningful and required information with the use of proper statics and beautiful words. Thanks for sharing!!
    Hire Odoo developers India

    ReplyDelete
  4. Great Post!!!!!

    Thank you so much for sharing this basic code of odoo module, It is very helpful for beginners, Keep sharing. Odoo Support

    ReplyDelete
  5. default sale top menu list??? then how

    ReplyDelete

Odoo 17 New Features

  Odoo 17 new Features 1) Duplicate  multiple records from List view. Please have look below screenshots first you need to select records th...