SlideShare a Scribd company logo
Tips and Trick
Odoo Development
By Agusto Xaverius PS
Background Scenario
1. Infinys already have 3 (three) successfully go-live and still on-going projects that
using Odoo ERP as backend system
2. Meanwhile on development process. We are fun to meet all the new stuff around
developing using Odoo ERP and keep always learning by doing
3. Within this slide, we will try to cover all that we know about tips on trick how to
develop on Odoo, like how to create a module, create a view, button, and etc.
4. All this development on this slide will be using Pyhton as language
TOC
1. Module Structure
2. Create a new Table / Inherit Table in database
3. Create Menu Items CRUD for our model
4. Create master-detail
5. Create model from multiple models
6. Create Button
7. Send Email via API and using Odoo Email Template
8. Create Job Schedule
Module Structure
Module Structure
• data folder: it contains css and xml files which hold to predefined
information into the system like a list of colours, counties, states name
data.
• models folder: it contains all python (.py) files. These hold models that
newly created or inherit from other existing models, objects and the
business logic as well. In part 2, we will introduce it more detail.
• security directory: it contains two files, Access control .csv file, Record rule
.xml files. Access control: ir.model.access.csv must be there and used for
holding access rights of model. Record Rules: security.xml that can declare
the the prohibited operations like create, update and delete. This access
control is applied in single record, so you need to specify which record is
going to be applied.
• views directory: it contains all .xml files where we declare the form views,
menu, action, Qweb template and so on for our business objects.
•_init__.py it is utilized to specify the directories or packages need to
imported.
Module Structure
• __manifest__.py this file is crucial in Odoo module. This module should be
located at the root of the module. It lets you describe essential information
of your module like name, version, description, dependencies, data files,
etc.
– Name – module name
– Description – Brief description of your module
– Version – Version of your module
– License – License of your module
– Author – Author name of your module
– Website – Website URL of your module author or company
– Category – Indicate the category name.
– Depends – Specifies a list of modules which need to install before this module. This is
important. Without this declaration, you may get warning or error during module
installation
– Data – Data files which are always installed or updated with the module.
– demo – Data files which are installed or updated in active demonstration mode.
Sample
Module
Structure
Create a new Table /
Inherit Table in
database
Create a new table in database
1. Create a ClassName make sure using Camel namespace
2. _name , representative to the table name that will be stored in database
_description = “the table description”
3. All that fields that belong to this table
This below how will be look like in odoo database once this module installed
Create extra fields in existing module
Make sure put _Inherit for extend the
existing table
Create Menu Items
CRUD for our model
Menu CRUD for our model
Todo :
1. Create a model
2. Create a permission level on the folder security
3. Create a view for the model, tree view and form
view (optional)
1. Model – event.log.bytrack
2. Permission
access_event_log_bytrack_all,event_log_bytrack,model_event_log_bytrack,,1,1,1,1
access_event_chat_bytrack,event_chat_bytrack,model_event_chat_bytrack,base.group_user,1
,1,1,1
3. Create View
1)
<record id="action_event_log_bytrack" model="ir.actions.act_window">
<field name="name">List Of Event Log By Track action</field>
<field name="res_model">event.log.bytrack</field>
<field name="view_mode">tree,form</field>
</record>
2)
<!-- explicit list menuitem definition -->
<menuitem id="event_main_register" name="Register"
parent="event.event_main_menu" sequence="50">
<menuitem id="event_log_bytrack" name="List Of Event Log By Track"
sequence="3" action="action_event_log_bytrack" />
</menuitem>
3)
<record model="ir.ui.view" id="event_log_bytrack_view">
<field name="name">event_log_bytrack_view.form</field>
<field name="model">event.log.bytrack</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="eventid"/>
<field name="trackid"/>
<field name="partnerid"/>
<field name="submitteddate"/>
<field name="is_active"/>
</group>
</sheet>
</form>
</field>
</record>
Create master-detail
Sample Master-Detail
Todo :
1. Create model for detail
2. Create permission on security
folder
3. Create View, inherit from master
view
1. Create model for table detail
document_id = fields.Many2one('event.sponsor', string='Documents', required=True,
ondelete='cascade')
2. Create Permission
access_infinys_event_organization_event_sponsor_document,event.sponsor.document,infinys
_event_organization.model_event_sponsor_document,,1,1,1,1
3. Update the view
<page string="Videos" name="video_kits">
<field name ="video_line_ids">
<tree>
<field name="name" />
<field name="is_document_file" />
<field name="document_file_name" />
<field name="document_link" widget="url" />
<field name="create_date" />
</tree>
<form>
<group>
<field name="name" />
<field name="is_document_file" />
<field name="document_file" filename="document_file_name" />
<field name="document_file_name" invisible="1"/>
<field name="document_link" widget="url"
placeholder="Youtube / Web Video Link Link..." />
</group>
</form>
</field>
</page>
Create model from
multiple models
Sample Query
SELECT
ROW_NUMBER () OVER (ORDER BY eq.id) AS id,
eq.event_id AS event_id,
eq.id AS question_id,
eq.title AS name,
eq.question_type AS question_type,
eq.sequence AS question_sequence,
eq.once_per_order AS once_per_order,
eqa.id AS answer_id,
eqa.name AS answer_name,
eqa.sequence AS sequence_choice
FROM event_question AS eq
LEFT JOIN event_question_answer AS eqa ON eq.id = eqa.question_id
Todo :
1. Create a new model
2. Create permission
3. Create View (if needed)
4. Then you able to using this
model, on you view, odoo report,
or API
1. Create Model
ROW_NUMBER () OVER
(ORDER BY eq.id) AS id
Because we need to access
via API, makes sure the ID is
unique
2. Create Permission
access_contact_cv_verification,contact_cv_verification,model_contact_cv_verification,bas
e.group_user,1,1,1,1
access_contact_cv_verification_all,contact_cv_verification,model_contact_cv_verification
,,1,0,0,0
Testing On API
Create button
Sample
Todo :
1. Create button on the view
2. Create function on the model, since the
button type using object
1. Create button on view
<xpath expr="//field[@name='stage_id']" position="before">
<button type="object" name="action_generate_certification" string="Test Certification" class="btn btn-secondary"
attrs="{'invisible': [('is_certificate', '=', False)]}"/>
</xpath>
2. Create Function
def action_generate_certification(self):
return {
'type': 'ir.actions.act_url',
'target': 'new',
'url': "/api/certificate/generate/test?event_id=" + str(self.id) + "&partner_id=" + str(self.env.user.partner_id.id),
}
Send Email via API and
using Odoo Email
Template
Sample
Todo :
1. Email template and
choose the model will
applies to
2. Testing using API
Access template email using API
#Send Email Registration
email_template_obj = request.env['mail.template']
template_id = email_template_obj.sudo().search([('name','=','Registration Acqalm Account Created'),('model_id.model',
'=', 'res.partner')])
template_id.send_mail(_partner_id, force_send=True)
_logger.info("send Email Succeed")
Create Job Schedule
Sample
Todo :
1. Creating the automated
action (Create XML
template inside folder
data)
2. Create a function base on
model that you will be
used
3. Register the xml on file
_manifest_.py
1. Create XML Data
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<record id="cancel_sales_order_scheduler" model="ir.cron">
<field name="name">Cancel Sales Order</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall">0</field>
<field name="model_id" ref="model_sale_order"/>
<field name="code">model.cancel_old_sales_order()</field>
<field name="priority">10</field>
</record>
</odoo>
2. Create Function
from odoo import api, fields, models, _
from datetime import datetime, timedelta
class SalesOrder(models.Model):
_inherit = 'sale.order'
def cancel_old_sales_order(self):
limit = 7
# tanggal hari ini
date_today = datetime.today()
# tanggal yang seharusnya sudah boleh dicancel
cancel_date = date_today - timedelta(days = limit)
# cari sales order yang tanggalnya sesuai dan belum di confirm
old_order = self.env['sale.order'].search([('date_order', '<', cancel_date), ('state','in', ['draft','sent'])])
# cancel sales order yang sesuai kriteria
old_order.action_cancel()
3. Register the xml data
{
"name": "Tutorial Scheduler",
"author": "agusto",
"version": "1.0.0",
"category": "",
"website": "",
"summary": "",
"description": """
""",
"depends": [
"base",
"sale"
],
"data": [
"data/ir_cron.xml"
],
"license": 'LGPL-3',
"installable": True
}
Knowledge Base
1. https://www.odoo.com/
2. https://www.genkiware.com/2020/05/03/how-to-write-a-module-in-odoo-part-i-
module-structure/
3. https://en.ngasturi.id/
4. https://www.youtube.com/c/OdooMates

More Related Content

Similar to Tips On Trick Odoo Add-On.pptx

Connecting your Python App to OpenERP through OOOP
Connecting your Python App to OpenERP through OOOPConnecting your Python App to OpenERP through OOOP
Connecting your Python App to OpenERP through OOOP
raimonesteve
 
Django tutorial
Django tutorialDjango tutorial
Django tutorial
Ksd Che
 
Odoo 15 Composition of Module
Odoo 15 Composition of ModuleOdoo 15 Composition of Module
Odoo 15 Composition of Module
Celine George
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
sroo galal
 
6. safe users-guide
6.  safe users-guide6.  safe users-guide
6. safe users-guide
ALAN QUISPE CORONEL
 
Uploading files using selenium web driver
Uploading files using selenium web driverUploading files using selenium web driver
Uploading files using selenium web driver
Pankaj Biswas
 
Yii in action
Yii in actionYii in action
Yii in action
KeaNy Chu
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical MementoOdoo
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
Giuliano Iacobelli
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development
Mage Guru
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
Celine George
 
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docxCS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
mydrynan
 
Arena tutorial
Arena tutorialArena tutorial
Arena tutorial
Amey Kulkarni
 
How to create a simple module in Magento 2.0
How to create a simple module in Magento 2.0How to create a simple module in Magento 2.0
How to create a simple module in Magento 2.0
MageWorld
 
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxCASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
keturahhazelhurst
 
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocialIBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
IBM Connections Developers
 
JMP103 : Extending Your App Arsenal With OpenSocial
JMP103 : Extending Your App Arsenal With OpenSocialJMP103 : Extending Your App Arsenal With OpenSocial
JMP103 : Extending Your App Arsenal With OpenSocial
Ryan Baxter
 
Develop an App with the Odoo Framework
Develop an App with the Odoo FrameworkDevelop an App with the Odoo Framework
Develop an App with the Odoo Framework
Odoo
 
Module Structure in Odoo 15
Module Structure in Odoo 15Module Structure in Odoo 15
Module Structure in Odoo 15
Celine George
 
Developing Dynamic PeopleSoft Field Security Applications:A PeopleSoft Develo...
Developing Dynamic PeopleSoft Field Security Applications:A PeopleSoft Develo...Developing Dynamic PeopleSoft Field Security Applications:A PeopleSoft Develo...
Developing Dynamic PeopleSoft Field Security Applications:A PeopleSoft Develo...guest96f6c68d
 

Similar to Tips On Trick Odoo Add-On.pptx (20)

Connecting your Python App to OpenERP through OOOP
Connecting your Python App to OpenERP through OOOPConnecting your Python App to OpenERP through OOOP
Connecting your Python App to OpenERP through OOOP
 
Django tutorial
Django tutorialDjango tutorial
Django tutorial
 
Odoo 15 Composition of Module
Odoo 15 Composition of ModuleOdoo 15 Composition of Module
Odoo 15 Composition of Module
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
 
6. safe users-guide
6.  safe users-guide6.  safe users-guide
6. safe users-guide
 
Uploading files using selenium web driver
Uploading files using selenium web driverUploading files using selenium web driver
Uploading files using selenium web driver
 
Yii in action
Yii in actionYii in action
Yii in action
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical Memento
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docxCS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
 
Arena tutorial
Arena tutorialArena tutorial
Arena tutorial
 
How to create a simple module in Magento 2.0
How to create a simple module in Magento 2.0How to create a simple module in Magento 2.0
How to create a simple module in Magento 2.0
 
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxCASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
 
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocialIBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
 
JMP103 : Extending Your App Arsenal With OpenSocial
JMP103 : Extending Your App Arsenal With OpenSocialJMP103 : Extending Your App Arsenal With OpenSocial
JMP103 : Extending Your App Arsenal With OpenSocial
 
Develop an App with the Odoo Framework
Develop an App with the Odoo FrameworkDevelop an App with the Odoo Framework
Develop an App with the Odoo Framework
 
Module Structure in Odoo 15
Module Structure in Odoo 15Module Structure in Odoo 15
Module Structure in Odoo 15
 
Developing Dynamic PeopleSoft Field Security Applications:A PeopleSoft Develo...
Developing Dynamic PeopleSoft Field Security Applications:A PeopleSoft Develo...Developing Dynamic PeopleSoft Field Security Applications:A PeopleSoft Develo...
Developing Dynamic PeopleSoft Field Security Applications:A PeopleSoft Develo...
 

More from Agusto Sipahutar

KONG-APIGateway.pptx
KONG-APIGateway.pptxKONG-APIGateway.pptx
KONG-APIGateway.pptx
Agusto Sipahutar
 
Data Lost Prevention (DLP).pdf
Data Lost Prevention (DLP).pdfData Lost Prevention (DLP).pdf
Data Lost Prevention (DLP).pdf
Agusto Sipahutar
 
Infinys Odoo CRM Presentation.pptx
Infinys Odoo CRM Presentation.pptxInfinys Odoo CRM Presentation.pptx
Infinys Odoo CRM Presentation.pptx
Agusto Sipahutar
 
High Cloud Computing Backbone Technology.pptx
High Cloud Computing Backbone Technology.pptxHigh Cloud Computing Backbone Technology.pptx
High Cloud Computing Backbone Technology.pptx
Agusto Sipahutar
 
Secure File Sharring-owncloud.pptx
Secure File Sharring-owncloud.pptxSecure File Sharring-owncloud.pptx
Secure File Sharring-owncloud.pptx
Agusto Sipahutar
 
Software Team Roles
Software Team RolesSoftware Team Roles
Software Team Roles
Agusto Sipahutar
 
Easy to manage docker with portainer
Easy to manage docker with portainerEasy to manage docker with portainer
Easy to manage docker with portainer
Agusto Sipahutar
 
[Slides] how to integrated managed service dengan it department
[Slides] how to integrated managed service dengan it department[Slides] how to integrated managed service dengan it department
[Slides] how to integrated managed service dengan it department
Agusto Sipahutar
 
RPA with UIPath and Flaui
RPA with UIPath and FlauiRPA with UIPath and Flaui
RPA with UIPath and Flaui
Agusto Sipahutar
 
[Slides] key considerations to look for in managed services
[Slides] key considerations to look for in managed services[Slides] key considerations to look for in managed services
[Slides] key considerations to look for in managed services
Agusto Sipahutar
 
[Slides] Infinys Cloud Manage Service
[Slides] Infinys Cloud Manage Service[Slides] Infinys Cloud Manage Service
[Slides] Infinys Cloud Manage Service
Agusto Sipahutar
 
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and SwaggerIntroduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
Agusto Sipahutar
 
Sharepoint 2019 Training
Sharepoint 2019 TrainingSharepoint 2019 Training
Sharepoint 2019 Training
Agusto Sipahutar
 
Intro to power apps
Intro to power appsIntro to power apps
Intro to power apps
Agusto Sipahutar
 
Slides leverage your work from home level now
Slides leverage your work from home level now Slides leverage your work from home level now
Slides leverage your work from home level now
Agusto Sipahutar
 
Slides m365 file management and collaboration (infinys)
Slides m365 file management and collaboration (infinys)Slides m365 file management and collaboration (infinys)
Slides m365 file management and collaboration (infinys)
Agusto Sipahutar
 

More from Agusto Sipahutar (16)

KONG-APIGateway.pptx
KONG-APIGateway.pptxKONG-APIGateway.pptx
KONG-APIGateway.pptx
 
Data Lost Prevention (DLP).pdf
Data Lost Prevention (DLP).pdfData Lost Prevention (DLP).pdf
Data Lost Prevention (DLP).pdf
 
Infinys Odoo CRM Presentation.pptx
Infinys Odoo CRM Presentation.pptxInfinys Odoo CRM Presentation.pptx
Infinys Odoo CRM Presentation.pptx
 
High Cloud Computing Backbone Technology.pptx
High Cloud Computing Backbone Technology.pptxHigh Cloud Computing Backbone Technology.pptx
High Cloud Computing Backbone Technology.pptx
 
Secure File Sharring-owncloud.pptx
Secure File Sharring-owncloud.pptxSecure File Sharring-owncloud.pptx
Secure File Sharring-owncloud.pptx
 
Software Team Roles
Software Team RolesSoftware Team Roles
Software Team Roles
 
Easy to manage docker with portainer
Easy to manage docker with portainerEasy to manage docker with portainer
Easy to manage docker with portainer
 
[Slides] how to integrated managed service dengan it department
[Slides] how to integrated managed service dengan it department[Slides] how to integrated managed service dengan it department
[Slides] how to integrated managed service dengan it department
 
RPA with UIPath and Flaui
RPA with UIPath and FlauiRPA with UIPath and Flaui
RPA with UIPath and Flaui
 
[Slides] key considerations to look for in managed services
[Slides] key considerations to look for in managed services[Slides] key considerations to look for in managed services
[Slides] key considerations to look for in managed services
 
[Slides] Infinys Cloud Manage Service
[Slides] Infinys Cloud Manage Service[Slides] Infinys Cloud Manage Service
[Slides] Infinys Cloud Manage Service
 
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and SwaggerIntroduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
 
Sharepoint 2019 Training
Sharepoint 2019 TrainingSharepoint 2019 Training
Sharepoint 2019 Training
 
Intro to power apps
Intro to power appsIntro to power apps
Intro to power apps
 
Slides leverage your work from home level now
Slides leverage your work from home level now Slides leverage your work from home level now
Slides leverage your work from home level now
 
Slides m365 file management and collaboration (infinys)
Slides m365 file management and collaboration (infinys)Slides m365 file management and collaboration (infinys)
Slides m365 file management and collaboration (infinys)
 

Recently uploaded

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 

Recently uploaded (20)

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 

Tips On Trick Odoo Add-On.pptx

  • 1. Tips and Trick Odoo Development By Agusto Xaverius PS
  • 2. Background Scenario 1. Infinys already have 3 (three) successfully go-live and still on-going projects that using Odoo ERP as backend system 2. Meanwhile on development process. We are fun to meet all the new stuff around developing using Odoo ERP and keep always learning by doing 3. Within this slide, we will try to cover all that we know about tips on trick how to develop on Odoo, like how to create a module, create a view, button, and etc. 4. All this development on this slide will be using Pyhton as language
  • 3. TOC 1. Module Structure 2. Create a new Table / Inherit Table in database 3. Create Menu Items CRUD for our model 4. Create master-detail 5. Create model from multiple models 6. Create Button 7. Send Email via API and using Odoo Email Template 8. Create Job Schedule
  • 5. Module Structure • data folder: it contains css and xml files which hold to predefined information into the system like a list of colours, counties, states name data. • models folder: it contains all python (.py) files. These hold models that newly created or inherit from other existing models, objects and the business logic as well. In part 2, we will introduce it more detail. • security directory: it contains two files, Access control .csv file, Record rule .xml files. Access control: ir.model.access.csv must be there and used for holding access rights of model. Record Rules: security.xml that can declare the the prohibited operations like create, update and delete. This access control is applied in single record, so you need to specify which record is going to be applied. • views directory: it contains all .xml files where we declare the form views, menu, action, Qweb template and so on for our business objects. •_init__.py it is utilized to specify the directories or packages need to imported.
  • 6. Module Structure • __manifest__.py this file is crucial in Odoo module. This module should be located at the root of the module. It lets you describe essential information of your module like name, version, description, dependencies, data files, etc. – Name – module name – Description – Brief description of your module – Version – Version of your module – License – License of your module – Author – Author name of your module – Website – Website URL of your module author or company – Category – Indicate the category name. – Depends – Specifies a list of modules which need to install before this module. This is important. Without this declaration, you may get warning or error during module installation – Data – Data files which are always installed or updated with the module. – demo – Data files which are installed or updated in active demonstration mode.
  • 8. Create a new Table / Inherit Table in database
  • 9. Create a new table in database
  • 10. 1. Create a ClassName make sure using Camel namespace 2. _name , representative to the table name that will be stored in database _description = “the table description” 3. All that fields that belong to this table This below how will be look like in odoo database once this module installed
  • 11. Create extra fields in existing module Make sure put _Inherit for extend the existing table
  • 12.
  • 13. Create Menu Items CRUD for our model
  • 14. Menu CRUD for our model Todo : 1. Create a model 2. Create a permission level on the folder security 3. Create a view for the model, tree view and form view (optional)
  • 15. 1. Model – event.log.bytrack
  • 18. 1) <record id="action_event_log_bytrack" model="ir.actions.act_window"> <field name="name">List Of Event Log By Track action</field> <field name="res_model">event.log.bytrack</field> <field name="view_mode">tree,form</field> </record> 2) <!-- explicit list menuitem definition --> <menuitem id="event_main_register" name="Register" parent="event.event_main_menu" sequence="50"> <menuitem id="event_log_bytrack" name="List Of Event Log By Track" sequence="3" action="action_event_log_bytrack" /> </menuitem>
  • 19. 3) <record model="ir.ui.view" id="event_log_bytrack_view"> <field name="name">event_log_bytrack_view.form</field> <field name="model">event.log.bytrack</field> <field name="arch" type="xml"> <form> <sheet> <group> <field name="eventid"/> <field name="trackid"/> <field name="partnerid"/> <field name="submitteddate"/> <field name="is_active"/> </group> </sheet> </form> </field> </record>
  • 21. Sample Master-Detail Todo : 1. Create model for detail 2. Create permission on security folder 3. Create View, inherit from master view
  • 22. 1. Create model for table detail document_id = fields.Many2one('event.sponsor', string='Documents', required=True, ondelete='cascade')
  • 24. 3. Update the view <page string="Videos" name="video_kits"> <field name ="video_line_ids"> <tree> <field name="name" /> <field name="is_document_file" /> <field name="document_file_name" /> <field name="document_link" widget="url" /> <field name="create_date" /> </tree> <form> <group> <field name="name" /> <field name="is_document_file" /> <field name="document_file" filename="document_file_name" /> <field name="document_file_name" invisible="1"/> <field name="document_link" widget="url" placeholder="Youtube / Web Video Link Link..." /> </group> </form> </field> </page>
  • 26. Sample Query SELECT ROW_NUMBER () OVER (ORDER BY eq.id) AS id, eq.event_id AS event_id, eq.id AS question_id, eq.title AS name, eq.question_type AS question_type, eq.sequence AS question_sequence, eq.once_per_order AS once_per_order, eqa.id AS answer_id, eqa.name AS answer_name, eqa.sequence AS sequence_choice FROM event_question AS eq LEFT JOIN event_question_answer AS eqa ON eq.id = eqa.question_id Todo : 1. Create a new model 2. Create permission 3. Create View (if needed) 4. Then you able to using this model, on you view, odoo report, or API
  • 27. 1. Create Model ROW_NUMBER () OVER (ORDER BY eq.id) AS id Because we need to access via API, makes sure the ID is unique
  • 31. Sample Todo : 1. Create button on the view 2. Create function on the model, since the button type using object 1. Create button on view <xpath expr="//field[@name='stage_id']" position="before"> <button type="object" name="action_generate_certification" string="Test Certification" class="btn btn-secondary" attrs="{'invisible': [('is_certificate', '=', False)]}"/> </xpath>
  • 32. 2. Create Function def action_generate_certification(self): return { 'type': 'ir.actions.act_url', 'target': 'new', 'url': "/api/certificate/generate/test?event_id=" + str(self.id) + "&partner_id=" + str(self.env.user.partner_id.id), }
  • 33. Send Email via API and using Odoo Email Template
  • 34. Sample Todo : 1. Email template and choose the model will applies to 2. Testing using API
  • 35. Access template email using API #Send Email Registration email_template_obj = request.env['mail.template'] template_id = email_template_obj.sudo().search([('name','=','Registration Acqalm Account Created'),('model_id.model', '=', 'res.partner')]) template_id.send_mail(_partner_id, force_send=True) _logger.info("send Email Succeed")
  • 37. Sample Todo : 1. Creating the automated action (Create XML template inside folder data) 2. Create a function base on model that you will be used 3. Register the xml on file _manifest_.py
  • 38. 1. Create XML Data <?xml version='1.0' encoding='utf-8'?> <odoo> <record id="cancel_sales_order_scheduler" model="ir.cron"> <field name="name">Cancel Sales Order</field> <field name="user_id" ref="base.user_root" /> <field name="interval_number">1</field> <field name="interval_type">days</field> <field name="numbercall">-1</field> <field name="doall">0</field> <field name="model_id" ref="model_sale_order"/> <field name="code">model.cancel_old_sales_order()</field> <field name="priority">10</field> </record> </odoo>
  • 39. 2. Create Function from odoo import api, fields, models, _ from datetime import datetime, timedelta class SalesOrder(models.Model): _inherit = 'sale.order' def cancel_old_sales_order(self): limit = 7 # tanggal hari ini date_today = datetime.today() # tanggal yang seharusnya sudah boleh dicancel cancel_date = date_today - timedelta(days = limit) # cari sales order yang tanggalnya sesuai dan belum di confirm old_order = self.env['sale.order'].search([('date_order', '<', cancel_date), ('state','in', ['draft','sent'])]) # cancel sales order yang sesuai kriteria old_order.action_cancel()
  • 40. 3. Register the xml data { "name": "Tutorial Scheduler", "author": "agusto", "version": "1.0.0", "category": "", "website": "", "summary": "", "description": """ """, "depends": [ "base", "sale" ], "data": [ "data/ir_cron.xml" ], "license": 'LGPL-3', "installable": True }
  • 41. Knowledge Base 1. https://www.odoo.com/ 2. https://www.genkiware.com/2020/05/03/how-to-write-a-module-in-odoo-part-i- module-structure/ 3. https://en.ngasturi.id/ 4. https://www.youtube.com/c/OdooMates