SlideShare une entreprise Scribd logo
1  sur  35
www.cybrosys.com
HOW TO CREATE A MODULE IN
ODOO
INTRODUCTION
• For those who are in starting stage of Odoo development, it is a tough task for creating
a new module. In this section let us look how to create a new module in the Odoo.
• There are mainly four files required for creating a new module (.py or .xml can be excluded as
per the need).
• The main four files are :-
 __init__.py
 __manifest__.py
 model.py
 view.xml
• This is based on v10, in the v9 and v8 we have to use __openerp__.py instead of the
__manifest__.py. The above four files should be inside a folder, let the folder name be school
• __init__.py
In the __init__.py file we have to import all the python files that we are going to use. Suppose as
described above we have a python file called model.py in our module. The first thing we have to
do is, import the model.py in the __init__.py file.
So our __init__.py file will be like this,
import model
 _manifest__.py
In the __manifest__.py, We have to mention the module name, the author name, version ,
description, company , category etc. Now let us see what all these things for,
• Name – Name of the module to be displayed
• Author – The name of one who created the module
• Version – version of the released module, is it v10,v9 or v8
• company – The company which developer module
• website – the website address of the company
• Category – Category of the module, whether it is sales, purchase, point of sale etc.
• Depends – Suppose if our module depends on any other modules, we have to mention
that name in the depends. As we are going to create a new module and as it is not
depending on any other modules, just add depends as base
• Data – In the data section we have to specify all the .xml files here. In our case we have
to mention the view.xml here
• So our __manifest__.py file will be like this
{
'name': 'Student Record',
'summary': """This module will add a record to store student details""",
'version': '10.0.1.0.0',
'description': """This module will add a record to store student details""",
'author': 'Niyas Raphy',
'company': 'Cybrosys Techno Solutions',
'website': 'http://www.cybrosys.com',
'category': 'Tools',
'depends': ['base'],
'license': 'AGPL-3',
'data': [
'view.xml',
],
'demo': [],
'installable': True,
'auto_install': False,
}
If the installable is not as set as True, the module will not have an install button when
we see it in the apps list. If we set the the auto_install as True, the module will
automatically get installed in the time of creation of the new database.
• model.py
In this file, we have to design a new model to store the values of the student, let it be
student.student. On creating a new model, a table will get generated in the database.
Inside the model, we have to declare all the fields that we are going to use in this table.
The different types of fields are,
* char
* float
* Int
* Boolean
* many2one
* many2many etc,
* selection
• The model.py in our case is, from odoo import models, fields
class StudentRecord(models.Model):
_name = "student.student"
name = fields.Char(string='Name', required=True)
middle_name = fields.Char(string='Middle Name', required=True)
last_name = fields.Char(string='Last Name', required=True)
photo = fields.Binary(string='Photo')
student_age = fields.Integer(string='Age')
student_dob = fields.Date(string="Date of Birth")
student_gender = fields.Selection([('m', 'Male'), ('f', 'Female'), ('o', 'Other')], string='Gender')
student_blood_group = fields.Selection(
[('A+', 'A+ve'), ('B+', 'B+ve'), ('O+', 'O+ve'), ('AB+', 'AB+ve'),
('A-', 'A-ve'), ('B-', 'B-ve'), ('O-', 'O-ve'), ('AB-', 'AB-ve')],
string='Blood Group')
nationality = fields.Many2one('res.country', string='Nationality')
• First of all we have to import the models and fields from the odoo.
(After importing the required packages give two line space before class ).
Then we have to define a new class StudentRecord with the name as the student.student. Now
a table will get generated , next we have to define the fields inside this table,(leave one line
space between model name and fields) in the above we can see that the fields are name,
student_photo, student_age etc.
• Now let us look what is the type of the each field,
* name – name is defined as a char field.
* middle_name – middle name is also char field
* last_name – char field
* student_photo – This a binary field where we can store the image of the student.
* student_age – Integer field to store the age of student
* student_dob – Date field to record the date of birth of the student
* student_gender – It is selection field from which the gender of the student can be
selected
* student_blood_group- This is also a selection field, from this the blood group o f can be
selected
*student_nationality – This is a many2one field of the res.country, all the * nations list will
be displayed and we can select the required one
name = fields.Char(string='Name', required=True)
IMP :- While giving the name for the fields, give it properly so that one can easily
understand why this field is for on seeing its name.
student_age = fields.Integer(string='Age') , The word that we have given inside the string
attribute will displayed in the form , tree views.
We can define the above fields like this also,
student_age = fields.Integer('Age'), without string=”Age”, we can directly give 'Age' inside
the bracket. But giving with string is recommended.
• view.xml
As we have defined all the needed fields in the model.py file now we have to create view
for this. How should user see this, where must be the name field ? Such thing can be
defined in the view.xml file.
Right now we have created a table in the database, here we have to define how it should
be in the user interface and under which menu it should be etc. In our case, let us create
a new menu called school and under the school we can create a sub menu called
students and on clicking the students menu we can display the student record.
• Let us first look, how to create a new menus,
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<menuitem id="menu_school" name="School"/>
<menuitem id="school_student" name="Students" parent="menu_school"
action="action_view_students"/>
</data>
</odoo>
This is how we can create new menus, In the first menu we can see only the id and
name, where as we can see two extra attributes in second menu, ie, action and parent.
As first menu does not have a parent the menu will get created a new menu in top bar.
For the second menu parent is set as the first menu, you can see that in the parent of
the second the id of the first menu is given. So the second menu will be the submenu
of the first menu.
The string that we have given in the name attribute will be displayed as the name of
the menu.
IMP : The menu that is created without having any action will not get displayed in the
UI
• Now let us look what does the action in the student menu is for,
Creating the action record,
The action which takes place on clicking the menu is based on what we have defined in the
action record.
Let us look how our action record “ action_view_students” will be,
<record model="ir.actions.act_window" id="action_view_students">
<field name="name">Students</field>
<field name="res_model">student.student</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Create new student
</p>
</field>
</record>
• Here , we have to give which all views should be there, in the above i have given two
views ie, tree and form view. In the res_model we have to specify the model, our model
name is student.student, the name that we have given while creation of the class in the
model.py.
The domain is for , suppose if we have to filter the records on clicking the menu we can give
the filter condition here.
<field name="domain">[('student_age', '>', 23)]</field>, if we give such a domain then
student those who have age greater than 23 will ve displayed.
<p class="oe_view_nocontent_create">Create new student
</p> . This will get displayed if no record in the corresponding model is created. If there is no
students created then it will display like this, create new student.
• Now we have to create form view and tree view for model,
Tree view :-
<record id="view_student_tree" model="ir.ui.view">
<field name="name">student.student.tree</field>
<field name="model">student.student</field>
<field name="priority" eval="8" />
<field name="arch" type="xml">
<tree string="Student">
<field name="name" />
<field name="middle_name" />
<field name="last_name" />
<field name="student_gender" />
<field name="student_age" />
<field name="student_dob" />
<field name="student_blood_group" />
<field name="lang" />
</tree>
</field>
</record>
• In the id we have to give id for tree view, in the model we have to give our model ie,
student.student. The attribute tree will identify this as tree view
Form view :-
<record id="view_student_form" model="ir.ui.view">
<field name="name">student.student.form</field>
<field name="model">student.student</field>
<field name="priority" eval="8" />
<field name="arch" type="xml">
<form string="Student">
<sheet>
<field name="photo" widget="image" class="oe_left oe_avatar" />
<div class="oe_title">
<h1>
<table>
<tr>
<td style="padding-right:10px;"><field name="name" required="1" placeholder="First Name" /></td>
<td style="padding-right:10px;"><field name="middle_name" placeholder="Middle Name" /></td>
<td style="padding-right:10px;"><field name="last_name" placeholder="Last Name" /></td>
</tr>
</table>
</h1>
</div>
<notebook colspan="4">
<page name="personal_information"
string="Personal Information">
<group col="4" colspan="4"
name="personal_detail">
<field name="student_gender" />
<field name="student_age" />
<field name="student_dob" />
<field name="student_gender" />
<field name="student_blood_group" />
<field name="nationality" />
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
On giving sheet tag inside the form, a sheet will appear inside the form, it will make the form
more beautiful.
IMP: If the fields are not given inside the group tag, the string for the field given in the
model.py will not get displayed in the form view.
To display the fields in two sides of a form, we can use group tag inside group tag,
<group>
<group>
<field name="student_age" />
</group>
<group>
<field name="student_blood_group" />
</group>
<group>
• Now let us look the whole code, that we have written
* __init__.py
import model
* __manifest__.py
{
'name': 'Student Record',
'summary': """This module will add a record to store student details""",
'version': '10.0.1.0.0',
'description': """This module will add a record to store student details""",
'author': 'Niyas Raphy',
'company': 'Cybrosys Techno Solutions',
'website': 'http://www.cybrosys.com',
'category': 'Tools',
'depends': ['base'],
'license': 'AGPL-3',
'data': [
'data/view.xml',
],
'demo': [],
'installable': True,
'auto_install': False,
}
* model.py
from odoo import models, fields
class StudentRecord(models.Model):
_name = "student.student"
name = fields.Char(string='Name', required=True)
middle_name = fields.Char(string='Middle Name', required=True)
last_name = fields.Char(string='Last Name', required=True)
photo = fields.Binary(string='Photo')
student_age = fields.Integer(string='Age')
student_dob = fields.Date(string="Date of Birth")
student_gender = fields.Selection([('m', 'Male'), ('f', 'Female'), ('o', 'Other')], string='Gender')
student_blood_group = fields.Selection(
[('A+', 'A+ve'), ('B+', 'B+ve'), ('O+', 'O+ve'), ('AB+', 'AB+ve'),
('A-', 'A-ve'), ('B-', 'B-ve'), ('O-', 'O-ve'), ('AB-', 'AB-ve')],
string='Blood Group')
*view.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="view_student_tree" model="ir.ui.view">
<field name="name">student.student.tree</field>
<field name="model">student.student</field>
<field name="priority" eval="8" />
<field name="arch" type="xml">
<tree string="Student">
<field name="name" />
<field name="middle_name" />
<field name="last_name" />
<field name="student_gender" />
<field name="student_age" />
<field name="student_dob" />
<field name="student_blood_group" />
</tree>
</field>
</record>
<record id="view_student_form" model="ir.ui.view">
<field name="name">student.student.form</field>
<field name="model">student.student</field>
<field name="priority" eval="8" />
<field name="arch" type="xml">
<form string="Student">
<sheet>
<field name="photo" widget="image" class="oe_left oe_avatar" />
<div class="oe_title">
<h1>
<table>
<tr>
<td style="padding-right:10px;"><field name="name"
required="1" placeholder="First Name" /></td>
<td style="padding-right:10px;"><field
name="middle_name" placeholder="Middle Name" /></td>
<td style="padding-right:10px;"><field name="last_name"
placeholder="Last Name" /></td>
</tr>
</table>
</h1>
</div>
<notebook colspan="4">
<page name="personal_information"
string="Personal Information">
<group col="4" colspan="4"
name="personal_detail">
<field name="student_gender" />
<field name="student_age" />
<field name="student_dob" />
<field name="student_gender" />
<field name="student_blood_group" />
<field name="nationality" />
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_view_students">
<field name="name">Students</field>
<field name="res_model">student.student</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Create new student
</p>
</field>
</record>
<menuitem id="menu_school" name="School"/>
<menuitem id="school_student" name="Students"
parent="menu_school" action="action_view_students"/>
</data>
</odoo>
• The module is now completed, make sure that the newly created module is inside
the proper addons path. Then Go to Odoo, activate developer mode. Then Apps ->
update apps list -> click on update.
• The technical name of our module is the folder name (ie, school in our case) and the
name is Student Record which is given in the manifest file.
• Now after updating the apps list, you can search for the module based on either of
those name.
• This is now the structure of the module, school
-- __init__.py
-- __manifest__.py
-- model.py
-- view.xml
-- static
--- description
--icon.png
** Bold ones is folders
Extra tips
* For giving icon image for the newly created module, create a folder named static
inside the school, then inside the static folder create a description folder and inside
that add a image in name icon and it is format should be png.
* We can use MVC concept in creation of the module. So that the all .py file should be
added inside the models folder and all the .xml file should be added in views folder.
If we are using the above concept we have to change the module structure like this,
school
-- __init__.py
-- __manifest__.py
-- models
-- __init__.py
-- model.py
-- views
-- view.xml
-- static
--- description
--icon.png
• In the main __init__.py file we have to import the models folder,
main __init__.py
import models
In the __init__.py file inside the models folder,
import model
As the view.xml is moved to the views folder, the manifest file also has to be
changed.
__manifest__.py
{
'name': 'Student Record',
'summary': """This module will add a record to store student details""",
'version': '10.0.1.0.0',
'description': """This module will add a record to store student details""",
'author': 'Niyas Raphy',
'company': 'Cybrosys Techno Solutions',
'website': 'http://www.cybrosys.com',
'category': 'Tools',
'depends': ['base'],
'license': 'AGPL-3',
'data': [
'views/view.xml',
],
'demo': [],
'installable': True,
'auto_install': False,
}
This is how we can create a module in
Odoo…..
Refer this link for more:
https://www.cybrosys.com/blog/how-create-module-odoo
Thank You !
Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park,
Kakkancherry,
Calicut University P.O.
Calicut
Kerala, India - 673635.
Cybrosys Ltd
15, ST Antonys Road,
Forest Gate, London
England,
E79QA.
Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, Kerala,
India-682030.

Contenu connexe

Tendances

Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo
 
An in Depth Journey into Odoo's ORM
An in Depth Journey into Odoo's ORMAn in Depth Journey into Odoo's ORM
An in Depth Journey into Odoo's ORMOdoo
 
Owl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOwl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOdoo
 
scaffold method odoo 16
scaffold method odoo 16scaffold method odoo 16
scaffold method odoo 16Celine George
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)sroo galal
 
Object Relation Mapping in Odoo 16
Object Relation Mapping in Odoo 16Object Relation Mapping in Odoo 16
Object Relation Mapping in Odoo 16Celine George
 
External dependencies ,pre init hook &amp; post init hook in odoo
External dependencies ,pre init hook &amp; post init hook in odooExternal dependencies ,pre init hook &amp; post init hook in odoo
External dependencies ,pre init hook &amp; post init hook in odooCeline George
 
Empower your App by Inheriting from Odoo Mixins
Empower your App by Inheriting from Odoo MixinsEmpower your App by Inheriting from Odoo Mixins
Empower your App by Inheriting from Odoo MixinsOdoo
 
Oracle Retro pay by element
Oracle Retro pay by elementOracle Retro pay by element
Oracle Retro pay by elementrunjithrocking
 
Asynchronous JS in Odoo
Asynchronous JS in OdooAsynchronous JS in Odoo
Asynchronous JS in OdooOdoo
 
Defining Kanban View in Odoo15 | Advanced Views
Defining Kanban View in Odoo15 | Advanced ViewsDefining Kanban View in Odoo15 | Advanced Views
Defining Kanban View in Odoo15 | Advanced ViewsCeline George
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptBirukMarkos
 
Payroll costing details Oracle Fusion Cloud HCM
Payroll costing details Oracle Fusion Cloud HCMPayroll costing details Oracle Fusion Cloud HCM
Payroll costing details Oracle Fusion Cloud HCMFeras Ahmad
 
Oracle EBS R 12 Core hr user manual
Oracle EBS R 12 Core hr user manualOracle EBS R 12 Core hr user manual
Oracle EBS R 12 Core hr user manualFeras Ahmad
 
Fast formula queries for functions, contexts, db is and packages
Fast formula queries for functions, contexts, db is and packagesFast formula queries for functions, contexts, db is and packages
Fast formula queries for functions, contexts, db is and packagesFeras Ahmad
 
Check element entry value on particular effective date
Check element entry value on particular effective dateCheck element entry value on particular effective date
Check element entry value on particular effective dateFeras Ahmad
 
odoo json rpc.docx
odoo json rpc.docxodoo json rpc.docx
odoo json rpc.docxloufgxrtvct
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJames Casey
 
Actions and menus in odoo 16
Actions and menus in odoo 16Actions and menus in odoo 16
Actions and menus in odoo 16Celine George
 
Odoo - Backend modules in v8
Odoo - Backend modules in v8Odoo - Backend modules in v8
Odoo - Backend modules in v8Odoo
 

Tendances (20)

Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new api
 
An in Depth Journey into Odoo's ORM
An in Depth Journey into Odoo's ORMAn in Depth Journey into Odoo's ORM
An in Depth Journey into Odoo's ORM
 
Owl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOwl: The New Odoo UI Framework
Owl: The New Odoo UI Framework
 
scaffold method odoo 16
scaffold method odoo 16scaffold method odoo 16
scaffold method odoo 16
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
 
Object Relation Mapping in Odoo 16
Object Relation Mapping in Odoo 16Object Relation Mapping in Odoo 16
Object Relation Mapping in Odoo 16
 
External dependencies ,pre init hook &amp; post init hook in odoo
External dependencies ,pre init hook &amp; post init hook in odooExternal dependencies ,pre init hook &amp; post init hook in odoo
External dependencies ,pre init hook &amp; post init hook in odoo
 
Empower your App by Inheriting from Odoo Mixins
Empower your App by Inheriting from Odoo MixinsEmpower your App by Inheriting from Odoo Mixins
Empower your App by Inheriting from Odoo Mixins
 
Oracle Retro pay by element
Oracle Retro pay by elementOracle Retro pay by element
Oracle Retro pay by element
 
Asynchronous JS in Odoo
Asynchronous JS in OdooAsynchronous JS in Odoo
Asynchronous JS in Odoo
 
Defining Kanban View in Odoo15 | Advanced Views
Defining Kanban View in Odoo15 | Advanced ViewsDefining Kanban View in Odoo15 | Advanced Views
Defining Kanban View in Odoo15 | Advanced Views
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).ppt
 
Payroll costing details Oracle Fusion Cloud HCM
Payroll costing details Oracle Fusion Cloud HCMPayroll costing details Oracle Fusion Cloud HCM
Payroll costing details Oracle Fusion Cloud HCM
 
Oracle EBS R 12 Core hr user manual
Oracle EBS R 12 Core hr user manualOracle EBS R 12 Core hr user manual
Oracle EBS R 12 Core hr user manual
 
Fast formula queries for functions, contexts, db is and packages
Fast formula queries for functions, contexts, db is and packagesFast formula queries for functions, contexts, db is and packages
Fast formula queries for functions, contexts, db is and packages
 
Check element entry value on particular effective date
Check element entry value on particular effective dateCheck element entry value on particular effective date
Check element entry value on particular effective date
 
odoo json rpc.docx
odoo json rpc.docxodoo json rpc.docx
odoo json rpc.docx
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Actions and menus in odoo 16
Actions and menus in odoo 16Actions and menus in odoo 16
Actions and menus in odoo 16
 
Odoo - Backend modules in v8
Odoo - Backend modules in v8Odoo - Backend modules in v8
Odoo - Backend modules in v8
 

Similaire à HOW TO CREATE A MODULE IN ODOO

Building a Module in Odoo 16
Building a Module in Odoo 16Building a Module in Odoo 16
Building a Module in Odoo 16Celine George
 
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxAgusto Sipahutar
 
How to Build a Module in Odoo 15 Scaffold Method
How to Build a Module in Odoo 15 Scaffold MethodHow to Build a Module in Odoo 15 Scaffold Method
How to Build a Module in Odoo 15 Scaffold MethodCeline George
 
Forms, Getting Your Money's Worth
Forms, Getting Your Money's WorthForms, Getting Your Money's Worth
Forms, Getting Your Money's WorthAlex Gaynor
 
Django fixture
Django fixtureDjango fixture
Django fixtureAmitHadole
 
Tasks In this assignment you are required to design and imp.pdf
Tasks In this assignment you are required to design and imp.pdfTasks In this assignment you are required to design and imp.pdf
Tasks In this assignment you are required to design and imp.pdfacsmadurai
 
student application form Java Netbeans
student application form Java Netbeansstudent application form Java Netbeans
student application form Java Netbeansreshmajohney
 
Odoo 15 Composition of Module
Odoo 15 Composition of ModuleOdoo 15 Composition of Module
Odoo 15 Composition of ModuleCeline George
 
Implementation Your program shall contain at least the follo.pdf
Implementation Your program shall contain at least the follo.pdfImplementation Your program shall contain at least the follo.pdf
Implementation Your program shall contain at least the follo.pdfADITIEYEWEAR
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeCeline George
 
Django tutorial
Django tutorialDjango tutorial
Django tutorialKsd Che
 
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxAgusto Sipahutar
 
Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classesFajar Baskoro
 
SQLite Database Tutorial In Android
SQLite Database Tutorial In AndroidSQLite Database Tutorial In Android
SQLite Database Tutorial In AndroidAndroid 5
 
Cis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacesCis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacessdjdskjd9097
 
Odoo 13 e learning module
Odoo 13 e learning moduleOdoo 13 e learning module
Odoo 13 e learning modulePlanetOdoo
 
Step 1 In this assignment, you will modify the student information.pdf
Step 1 In this assignment, you will modify the student information.pdfStep 1 In this assignment, you will modify the student information.pdf
Step 1 In this assignment, you will modify the student information.pdfaman05bhatia1
 
Odoo (open erp) creating a module
Odoo (open erp) creating a moduleOdoo (open erp) creating a module
Odoo (open erp) creating a moduleTarun Behal
 

Similaire à HOW TO CREATE A MODULE IN ODOO (20)

Building a Module in Odoo 16
Building a Module in Odoo 16Building a Module in Odoo 16
Building a Module in Odoo 16
 
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptx
 
How to Build a Module in Odoo 15 Scaffold Method
How to Build a Module in Odoo 15 Scaffold MethodHow to Build a Module in Odoo 15 Scaffold Method
How to Build a Module in Odoo 15 Scaffold Method
 
Forms, Getting Your Money's Worth
Forms, Getting Your Money's WorthForms, Getting Your Money's Worth
Forms, Getting Your Money's Worth
 
Django fixture
Django fixtureDjango fixture
Django fixture
 
Tasks In this assignment you are required to design and imp.pdf
Tasks In this assignment you are required to design and imp.pdfTasks In this assignment you are required to design and imp.pdf
Tasks In this assignment you are required to design and imp.pdf
 
student application form Java Netbeans
student application form Java Netbeansstudent application form Java Netbeans
student application form Java Netbeans
 
Linq
LinqLinq
Linq
 
Odoo 15 Composition of Module
Odoo 15 Composition of ModuleOdoo 15 Composition of Module
Odoo 15 Composition of Module
 
Implementation Your program shall contain at least the follo.pdf
Implementation Your program shall contain at least the follo.pdfImplementation Your program shall contain at least the follo.pdf
Implementation Your program shall contain at least the follo.pdf
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using Code
 
Django tutorial
Django tutorialDjango tutorial
Django tutorial
 
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptx
 
Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classes
 
SQLite Database Tutorial In Android
SQLite Database Tutorial In AndroidSQLite Database Tutorial In Android
SQLite Database Tutorial In Android
 
Project3
Project3Project3
Project3
 
Cis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacesCis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfaces
 
Odoo 13 e learning module
Odoo 13 e learning moduleOdoo 13 e learning module
Odoo 13 e learning module
 
Step 1 In this assignment, you will modify the student information.pdf
Step 1 In this assignment, you will modify the student information.pdfStep 1 In this assignment, you will modify the student information.pdf
Step 1 In this assignment, you will modify the student information.pdf
 
Odoo (open erp) creating a module
Odoo (open erp) creating a moduleOdoo (open erp) creating a module
Odoo (open erp) creating a module
 

Plus de Celine George

What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
How to Manage Engineering to Order in Odoo 17
How to Manage Engineering to Order in Odoo 17How to Manage Engineering to Order in Odoo 17
How to Manage Engineering to Order in Odoo 17Celine George
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleCeline George
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Celine George
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPCeline George
 
How to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineHow to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineCeline George
 
How to create _name_search function in odoo 17
How to create _name_search function in odoo 17How to create _name_search function in odoo 17
How to create _name_search function in odoo 17Celine George
 
Views in Odoo 17 - Kanban View in odoo 17
Views in Odoo 17 - Kanban View  in odoo 17Views in Odoo 17 - Kanban View  in odoo 17
Views in Odoo 17 - Kanban View in odoo 17Celine George
 
The Shop Floor Overview in the Odoo 17 ERP
The Shop Floor Overview in the Odoo 17 ERPThe Shop Floor Overview in the Odoo 17 ERP
The Shop Floor Overview in the Odoo 17 ERPCeline George
 
What is Property Fields in Odoo 17 ERP Module
What is Property Fields in Odoo 17 ERP ModuleWhat is Property Fields in Odoo 17 ERP Module
What is Property Fields in Odoo 17 ERP ModuleCeline George
 
How to Share Dashboard in the Odoo 17 ERP
How to Share Dashboard in the Odoo 17 ERPHow to Share Dashboard in the Odoo 17 ERP
How to Share Dashboard in the Odoo 17 ERPCeline George
 
What are the Basic Fields in the Odoo 17 ERP
What are the Basic Fields in the Odoo 17 ERPWhat are the Basic Fields in the Odoo 17 ERP
What are the Basic Fields in the Odoo 17 ERPCeline George
 

Plus de Celine George (20)

What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
How to Manage Engineering to Order in Odoo 17
How to Manage Engineering to Order in Odoo 17How to Manage Engineering to Order in Odoo 17
How to Manage Engineering to Order in Odoo 17
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP Module
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERP
 
How to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineHow to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command Line
 
How to create _name_search function in odoo 17
How to create _name_search function in odoo 17How to create _name_search function in odoo 17
How to create _name_search function in odoo 17
 
Views in Odoo 17 - Kanban View in odoo 17
Views in Odoo 17 - Kanban View  in odoo 17Views in Odoo 17 - Kanban View  in odoo 17
Views in Odoo 17 - Kanban View in odoo 17
 
The Shop Floor Overview in the Odoo 17 ERP
The Shop Floor Overview in the Odoo 17 ERPThe Shop Floor Overview in the Odoo 17 ERP
The Shop Floor Overview in the Odoo 17 ERP
 
What is Property Fields in Odoo 17 ERP Module
What is Property Fields in Odoo 17 ERP ModuleWhat is Property Fields in Odoo 17 ERP Module
What is Property Fields in Odoo 17 ERP Module
 
How to Share Dashboard in the Odoo 17 ERP
How to Share Dashboard in the Odoo 17 ERPHow to Share Dashboard in the Odoo 17 ERP
How to Share Dashboard in the Odoo 17 ERP
 
What are the Basic Fields in the Odoo 17 ERP
What are the Basic Fields in the Odoo 17 ERPWhat are the Basic Fields in the Odoo 17 ERP
What are the Basic Fields in the Odoo 17 ERP
 

Dernier

Pitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deckPitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deckHajeJanKamps
 
Guide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDFGuide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDFChandresh Chudasama
 
Unveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesUnveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesDoe Paoro
 
Healthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterHealthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterJamesConcepcion7
 
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckHajeJanKamps
 
Onemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring CapabilitiesOnemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring CapabilitiesOne Monitar
 
Entrepreneurship lessons in Philippines
Entrepreneurship lessons in  PhilippinesEntrepreneurship lessons in  Philippines
Entrepreneurship lessons in PhilippinesDavidSamuel525586
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfJamesConcepcion7
 
PSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationPSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationAnamaria Contreras
 
Driving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon HarmerDriving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon HarmerAggregage
 
TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024Adnet Communications
 
20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdf20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdfChris Skinner
 
Excvation Safety for safety officers reference
Excvation Safety for safety officers referenceExcvation Safety for safety officers reference
Excvation Safety for safety officers referencessuser2c065e
 
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdfChris Skinner
 
Technical Leaders - Working with the Management Team
Technical Leaders - Working with the Management TeamTechnical Leaders - Working with the Management Team
Technical Leaders - Working with the Management TeamArik Fletcher
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdfShaun Heinrichs
 
Buy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy Verified Accounts
 
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...ssuserf63bd7
 

Dernier (20)

Pitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deckPitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deck
 
Guide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDFGuide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDF
 
Unveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesUnveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic Experiences
 
Healthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterHealthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare Newsletter
 
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
 
Onemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring CapabilitiesOnemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
 
Entrepreneurship lessons in Philippines
Entrepreneurship lessons in  PhilippinesEntrepreneurship lessons in  Philippines
Entrepreneurship lessons in Philippines
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdf
 
PSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationPSCC - Capability Statement Presentation
PSCC - Capability Statement Presentation
 
Driving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon HarmerDriving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon Harmer
 
TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024
 
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptxThe Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
 
20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdf20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdf
 
Excvation Safety for safety officers reference
Excvation Safety for safety officers referenceExcvation Safety for safety officers reference
Excvation Safety for safety officers reference
 
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf
 
Technical Leaders - Working with the Management Team
Technical Leaders - Working with the Management TeamTechnical Leaders - Working with the Management Team
Technical Leaders - Working with the Management Team
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf
 
Buy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail Accounts
 
Corporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information TechnologyCorporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information Technology
 
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...
 

HOW TO CREATE A MODULE IN ODOO

  • 2. INTRODUCTION • For those who are in starting stage of Odoo development, it is a tough task for creating a new module. In this section let us look how to create a new module in the Odoo.
  • 3. • There are mainly four files required for creating a new module (.py or .xml can be excluded as per the need). • The main four files are :-  __init__.py  __manifest__.py  model.py  view.xml
  • 4. • This is based on v10, in the v9 and v8 we have to use __openerp__.py instead of the __manifest__.py. The above four files should be inside a folder, let the folder name be school • __init__.py In the __init__.py file we have to import all the python files that we are going to use. Suppose as described above we have a python file called model.py in our module. The first thing we have to do is, import the model.py in the __init__.py file. So our __init__.py file will be like this, import model
  • 5.  _manifest__.py In the __manifest__.py, We have to mention the module name, the author name, version , description, company , category etc. Now let us see what all these things for, • Name – Name of the module to be displayed • Author – The name of one who created the module • Version – version of the released module, is it v10,v9 or v8 • company – The company which developer module • website – the website address of the company • Category – Category of the module, whether it is sales, purchase, point of sale etc. • Depends – Suppose if our module depends on any other modules, we have to mention that name in the depends. As we are going to create a new module and as it is not depending on any other modules, just add depends as base • Data – In the data section we have to specify all the .xml files here. In our case we have to mention the view.xml here
  • 6. • So our __manifest__.py file will be like this { 'name': 'Student Record', 'summary': """This module will add a record to store student details""", 'version': '10.0.1.0.0', 'description': """This module will add a record to store student details""", 'author': 'Niyas Raphy', 'company': 'Cybrosys Techno Solutions', 'website': 'http://www.cybrosys.com',
  • 7. 'category': 'Tools', 'depends': ['base'], 'license': 'AGPL-3', 'data': [ 'view.xml', ], 'demo': [], 'installable': True, 'auto_install': False, } If the installable is not as set as True, the module will not have an install button when we see it in the apps list. If we set the the auto_install as True, the module will automatically get installed in the time of creation of the new database.
  • 8. • model.py In this file, we have to design a new model to store the values of the student, let it be student.student. On creating a new model, a table will get generated in the database. Inside the model, we have to declare all the fields that we are going to use in this table. The different types of fields are, * char * float * Int * Boolean * many2one * many2many etc, * selection
  • 9. • The model.py in our case is, from odoo import models, fields class StudentRecord(models.Model): _name = "student.student" name = fields.Char(string='Name', required=True) middle_name = fields.Char(string='Middle Name', required=True) last_name = fields.Char(string='Last Name', required=True) photo = fields.Binary(string='Photo') student_age = fields.Integer(string='Age') student_dob = fields.Date(string="Date of Birth") student_gender = fields.Selection([('m', 'Male'), ('f', 'Female'), ('o', 'Other')], string='Gender') student_blood_group = fields.Selection( [('A+', 'A+ve'), ('B+', 'B+ve'), ('O+', 'O+ve'), ('AB+', 'AB+ve'), ('A-', 'A-ve'), ('B-', 'B-ve'), ('O-', 'O-ve'), ('AB-', 'AB-ve')], string='Blood Group') nationality = fields.Many2one('res.country', string='Nationality')
  • 10. • First of all we have to import the models and fields from the odoo. (After importing the required packages give two line space before class ). Then we have to define a new class StudentRecord with the name as the student.student. Now a table will get generated , next we have to define the fields inside this table,(leave one line space between model name and fields) in the above we can see that the fields are name, student_photo, student_age etc.
  • 11. • Now let us look what is the type of the each field, * name – name is defined as a char field. * middle_name – middle name is also char field * last_name – char field * student_photo – This a binary field where we can store the image of the student. * student_age – Integer field to store the age of student * student_dob – Date field to record the date of birth of the student * student_gender – It is selection field from which the gender of the student can be selected * student_blood_group- This is also a selection field, from this the blood group o f can be selected *student_nationality – This is a many2one field of the res.country, all the * nations list will be displayed and we can select the required one name = fields.Char(string='Name', required=True)
  • 12. IMP :- While giving the name for the fields, give it properly so that one can easily understand why this field is for on seeing its name. student_age = fields.Integer(string='Age') , The word that we have given inside the string attribute will displayed in the form , tree views. We can define the above fields like this also, student_age = fields.Integer('Age'), without string=”Age”, we can directly give 'Age' inside the bracket. But giving with string is recommended.
  • 13. • view.xml As we have defined all the needed fields in the model.py file now we have to create view for this. How should user see this, where must be the name field ? Such thing can be defined in the view.xml file. Right now we have created a table in the database, here we have to define how it should be in the user interface and under which menu it should be etc. In our case, let us create a new menu called school and under the school we can create a sub menu called students and on clicking the students menu we can display the student record.
  • 14. • Let us first look, how to create a new menus, <?xml version="1.0" encoding="UTF-8"?> <odoo> <data> <menuitem id="menu_school" name="School"/> <menuitem id="school_student" name="Students" parent="menu_school" action="action_view_students"/> </data> </odoo> This is how we can create new menus, In the first menu we can see only the id and name, where as we can see two extra attributes in second menu, ie, action and parent.
  • 15. As first menu does not have a parent the menu will get created a new menu in top bar. For the second menu parent is set as the first menu, you can see that in the parent of the second the id of the first menu is given. So the second menu will be the submenu of the first menu. The string that we have given in the name attribute will be displayed as the name of the menu. IMP : The menu that is created without having any action will not get displayed in the UI
  • 16. • Now let us look what does the action in the student menu is for, Creating the action record, The action which takes place on clicking the menu is based on what we have defined in the action record. Let us look how our action record “ action_view_students” will be, <record model="ir.actions.act_window" id="action_view_students"> <field name="name">Students</field> <field name="res_model">student.student</field> <field name="view_type">form</field> <field name="view_mode">tree,form</field> <field name="domain">[]</field> <field name="help" type="html"> <p class="oe_view_nocontent_create">Create new student </p> </field> </record>
  • 17. • Here , we have to give which all views should be there, in the above i have given two views ie, tree and form view. In the res_model we have to specify the model, our model name is student.student, the name that we have given while creation of the class in the model.py. The domain is for , suppose if we have to filter the records on clicking the menu we can give the filter condition here. <field name="domain">[('student_age', '>', 23)]</field>, if we give such a domain then student those who have age greater than 23 will ve displayed. <p class="oe_view_nocontent_create">Create new student </p> . This will get displayed if no record in the corresponding model is created. If there is no students created then it will display like this, create new student.
  • 18. • Now we have to create form view and tree view for model, Tree view :- <record id="view_student_tree" model="ir.ui.view"> <field name="name">student.student.tree</field> <field name="model">student.student</field> <field name="priority" eval="8" /> <field name="arch" type="xml"> <tree string="Student"> <field name="name" /> <field name="middle_name" /> <field name="last_name" /> <field name="student_gender" /> <field name="student_age" /> <field name="student_dob" /> <field name="student_blood_group" /> <field name="lang" /> </tree> </field> </record>
  • 19. • In the id we have to give id for tree view, in the model we have to give our model ie, student.student. The attribute tree will identify this as tree view Form view :- <record id="view_student_form" model="ir.ui.view"> <field name="name">student.student.form</field> <field name="model">student.student</field> <field name="priority" eval="8" /> <field name="arch" type="xml"> <form string="Student"> <sheet> <field name="photo" widget="image" class="oe_left oe_avatar" /> <div class="oe_title"> <h1> <table> <tr>
  • 20. <td style="padding-right:10px;"><field name="name" required="1" placeholder="First Name" /></td> <td style="padding-right:10px;"><field name="middle_name" placeholder="Middle Name" /></td> <td style="padding-right:10px;"><field name="last_name" placeholder="Last Name" /></td> </tr> </table> </h1> </div> <notebook colspan="4"> <page name="personal_information" string="Personal Information"> <group col="4" colspan="4" name="personal_detail"> <field name="student_gender" /> <field name="student_age" /> <field name="student_dob" /> <field name="student_gender" /> <field name="student_blood_group" /> <field name="nationality" />
  • 21. </group> </page> </notebook> </sheet> </form> </field> </record> On giving sheet tag inside the form, a sheet will appear inside the form, it will make the form more beautiful. IMP: If the fields are not given inside the group tag, the string for the field given in the model.py will not get displayed in the form view.
  • 22. To display the fields in two sides of a form, we can use group tag inside group tag, <group> <group> <field name="student_age" /> </group> <group> <field name="student_blood_group" /> </group> <group>
  • 23. • Now let us look the whole code, that we have written * __init__.py import model * __manifest__.py { 'name': 'Student Record', 'summary': """This module will add a record to store student details""", 'version': '10.0.1.0.0', 'description': """This module will add a record to store student details""", 'author': 'Niyas Raphy', 'company': 'Cybrosys Techno Solutions', 'website': 'http://www.cybrosys.com', 'category': 'Tools', 'depends': ['base'], 'license': 'AGPL-3', 'data': [ 'data/view.xml',
  • 24. ], 'demo': [], 'installable': True, 'auto_install': False, } * model.py from odoo import models, fields class StudentRecord(models.Model): _name = "student.student" name = fields.Char(string='Name', required=True) middle_name = fields.Char(string='Middle Name', required=True) last_name = fields.Char(string='Last Name', required=True) photo = fields.Binary(string='Photo') student_age = fields.Integer(string='Age') student_dob = fields.Date(string="Date of Birth")
  • 25. student_gender = fields.Selection([('m', 'Male'), ('f', 'Female'), ('o', 'Other')], string='Gender') student_blood_group = fields.Selection( [('A+', 'A+ve'), ('B+', 'B+ve'), ('O+', 'O+ve'), ('AB+', 'AB+ve'), ('A-', 'A-ve'), ('B-', 'B-ve'), ('O-', 'O-ve'), ('AB-', 'AB-ve')], string='Blood Group') *view.xml <?xml version="1.0" encoding="UTF-8"?> <odoo> <data> <record id="view_student_tree" model="ir.ui.view"> <field name="name">student.student.tree</field> <field name="model">student.student</field> <field name="priority" eval="8" /> <field name="arch" type="xml"> <tree string="Student">
  • 26. <field name="name" /> <field name="middle_name" /> <field name="last_name" /> <field name="student_gender" /> <field name="student_age" /> <field name="student_dob" /> <field name="student_blood_group" /> </tree> </field> </record> <record id="view_student_form" model="ir.ui.view"> <field name="name">student.student.form</field> <field name="model">student.student</field> <field name="priority" eval="8" /> <field name="arch" type="xml"> <form string="Student"> <sheet> <field name="photo" widget="image" class="oe_left oe_avatar" /> <div class="oe_title">
  • 27. <h1> <table> <tr> <td style="padding-right:10px;"><field name="name" required="1" placeholder="First Name" /></td> <td style="padding-right:10px;"><field name="middle_name" placeholder="Middle Name" /></td> <td style="padding-right:10px;"><field name="last_name" placeholder="Last Name" /></td> </tr> </table> </h1> </div> <notebook colspan="4"> <page name="personal_information" string="Personal Information"> <group col="4" colspan="4" name="personal_detail"> <field name="student_gender" /> <field name="student_age" /> <field name="student_dob" /> <field name="student_gender" /> <field name="student_blood_group" /> <field name="nationality" />
  • 28. </group> </page> </notebook> </sheet> </form> </field> </record> <record model="ir.actions.act_window" id="action_view_students"> <field name="name">Students</field> <field name="res_model">student.student</field> <field name="view_type">form</field> <field name="view_mode">tree,form</field> <field name="domain">[]</field> <field name="help" type="html"> <p class="oe_view_nocontent_create">Create new student </p> </field> </record> <menuitem id="menu_school" name="School"/> <menuitem id="school_student" name="Students" parent="menu_school" action="action_view_students"/> </data> </odoo>
  • 29. • The module is now completed, make sure that the newly created module is inside the proper addons path. Then Go to Odoo, activate developer mode. Then Apps -> update apps list -> click on update. • The technical name of our module is the folder name (ie, school in our case) and the name is Student Record which is given in the manifest file. • Now after updating the apps list, you can search for the module based on either of those name. • This is now the structure of the module, school -- __init__.py -- __manifest__.py -- model.py -- view.xml -- static --- description --icon.png ** Bold ones is folders
  • 30. Extra tips * For giving icon image for the newly created module, create a folder named static inside the school, then inside the static folder create a description folder and inside that add a image in name icon and it is format should be png. * We can use MVC concept in creation of the module. So that the all .py file should be added inside the models folder and all the .xml file should be added in views folder. If we are using the above concept we have to change the module structure like this, school -- __init__.py -- __manifest__.py -- models -- __init__.py -- model.py -- views -- view.xml
  • 31. -- static --- description --icon.png • In the main __init__.py file we have to import the models folder, main __init__.py import models In the __init__.py file inside the models folder, import model As the view.xml is moved to the views folder, the manifest file also has to be changed.
  • 32. __manifest__.py { 'name': 'Student Record', 'summary': """This module will add a record to store student details""", 'version': '10.0.1.0.0', 'description': """This module will add a record to store student details""", 'author': 'Niyas Raphy', 'company': 'Cybrosys Techno Solutions', 'website': 'http://www.cybrosys.com', 'category': 'Tools', 'depends': ['base'], 'license': 'AGPL-3', 'data': [ 'views/view.xml', ], 'demo': [], 'installable': True, 'auto_install': False, }
  • 33. This is how we can create a module in Odoo…..
  • 34. Refer this link for more: https://www.cybrosys.com/blog/how-create-module-odoo
  • 35. Thank You ! Cybrosys Technologies Pvt. Ltd. Neospace, Kinfra Techno Park, Kakkancherry, Calicut University P.O. Calicut Kerala, India - 673635. Cybrosys Ltd 15, ST Antonys Road, Forest Gate, London England, E79QA. Cybrosys Technologies Pvt. Ltd. 1st Floor, Thapasya Building, Infopark, Kakkanad, Kochi, Kerala, India-682030.