Odoo开发教程¶
入门教程
Setup guide
Adapt the environment for the tutorials
Run the server
Launch with odoo-bin
Log in to Odoo
Enable the developer mode
Extra tools
Useful Git commands
Code Editor
Administrator tools for PostgreSQL
Python Debugging
Server framework 101
Chapter 1: Architecture Overview
Multitier application
Odoo modules
Composition of a module
Module structure
Odoo Editions
Chapter 2: A New Application
The Real Estate Advertisement module
Prepare the addon directory
Chapter 3: Models And Basic Fields
Object-Relational Mapping
Model fields
Types
Common Attributes
Automatic Fields
Chapter 4: Security - A Brief Introduction
Data Files (CSV)
Access Rights
Chapter 5: Finally, Some UI To Play With
Data Files (XML)
Actions
Menus
Fields, Attributes And View
Some New Attributes
Default Values
Reserved Fields
Chapter 6: Basic Views
List
Form
Search
Domains
Chapter 7: Relations Between Models
Many2one
Many2many
One2many
Chapter 8: Computed Fields And Onchanges
Computed Fields
Dependencies
Inverse Function
Additional Information
Onchanges
Additional Information
How to use them?
Chapter 9: Ready For Some Action?
Object Type
Action Type
Chapter 10: Constraints
SQL
Python
Chapter 11: Add The Sprinkles
Inline Views
Widgets
List Order
Model
View
Manual
Attributes and options
Form
List
Search
Stat Buttons
Chapter 12: Inheritance
Python Inheritance
Model Inheritance
View Inheritance
Chapter 13: Interact With Other Modules
Concrete Example: Account Move
Link Module
Invoice Creation
Chapter 14: A Brief History Of QWeb
Concrete Example: A Kanban View
Chapter 15: The final word
Coding guidelines
Test on the runbot
Discover the web framework
Chapter 1: Owl components
Example: a Counter component
1. Displaying a counter
2. Extract Counter in a sub component
3. A simple Card component
4. Using markup to display html
5. Props validation
6. The sum of two Counter
7. A todo list
8. Use dynamic attributes
9. Adding a todo
Theory: Component lifecycle and hooks
10. Focusing the input
11. Toggling todos
12. Deleting todos
13. Generic Card with slots
14. Minimizing card content
Chapter 2: Build a dashboard
1. A new Layout
Theory: Services
2. Add some buttons for quick navigation
3. Add a dashboard item
4. Call the server, add some statistics
5. Cache network calls, create a service
6. Display a pie chart
7. Real life update
8. Lazy loading the dashboard
9. Making our dashboard generic
10. Making our dashboard extensible
11. Add and remove dashboard items
12. Going further
Setup
Content
Master the web framework
Chapter 1: Build a Clicker game
1. Create a systray item
2. Count external clicks
3. Create a client action
4. Move the state to a service
5. Use a custom hook
6. Humanize the displayed value
7. Add a tooltip in ClickValue component
8. Buy ClickBots
9. Refactor to a class model
10. Notify when a milestone is reached
11. Add BigBots
12. Add a new type of resource: power
13. Define some random rewards
14. Provide a reward when opening a form view
15. Add commands in command palette
16. Add yet another resource: trees
17. Use a dropdown menu for the systray item
18. Use a Notebook component
19. Persist the game state
20. Introduce state migration system
21. Add another type of trees
Chapter 2: Create a Gallery View
1. Make a hello world view
2. Use the Layout component
3. Parse the arch
4. Load some data
5. Solve the concurrency problem
6. Reorganize code
7. Make the view extensible
8. Display images
9. Switch to form view on click
10. Add an optional tooltip
11. Add pagination
12. Validating views
13. Uploading an image
14. Advanced tooltip template
Chapter 3: Customize a kanban view
1. Create a new kanban view
2. Create a CustomerList component
3. Load and display data
4. Update the main kanban view
5. Only display customers which have an active order
6. Add a search bar to the customer list
7. Refactor the code to use t-model
8. Paginate customers!
Setup
Content
Define module data
Data Types
Master Data
Demo Data
Data Declaration
Manifest
CSV
XML
Data Extension
ref
eval
search
function
Add X2many fields
Accessing the data
Advanced
What is the XML id?
No update
Import as SQL
Restrict access to data
Groups
Access Rights
Record Rules
Security Override
Bypassing Security
Programmatically checking security
Multi-company security
Visibility != security
Safeguard your code with unit tests
Running Tests
Integration Bots
Runbot
Robodoo
Mergebot
Modules
Writing a test
Write importable modules
Problem statement
Module structure
Deploying the module
Models and basic fields
Default values
Security
Views
Relations
Many-to-one
Many-to-many
One-to-many
Computed and related fields
Computed fields
Related fields
Code and business logic
Server actions
Overriding Python models
Via UI elements
Via automation rules
Website controllers
A sprinkle of JavaScript
Reuse code with mixins
Build PDF Reports
File Structure
Basic Report
Report Data
Minimal Template
Report Action
Make a Report
Sub-templates
Report Inheritance
Additional Features
Translations
Reports are web pages
Barcodes
Learn the server and web frameworks
Expand your knowledge on the server framework
常见问题指导
Write lean easy-to-maintain CSS
Browser defaults
HTML tags
Utility classes
Handling utility-classes verbosity
Customize a field
Subclass an existing field component
Create a new field component
Customize a view type
Subclass an existing view
Create a new view from scratch
Create a client action
Create a standalone Owl application
Overview
1. Root component
2. Creating an assets bundle containing our code
3. XML view that calls the assets bundle
4. Controller that renders the view
Use Owl components on the portal and website
Overview
1. Creating the Owl component
2. Adding your component to the web.assets_frontend bundle
3. Adding an
Points of caution
Layout shift
Poorer indexing by search engines
When to use Owl components on the portal and website
When you don’t care about SEO
When you need strong interactivity
Website themes
Setup
Install
Databases
Structure
Models
Fields
Classic fields
Relational fields
Views
Backend vs. Frontend
Static vs. Dynamic
Standard vs. Inherited
Import an existing database
Dump
Odoo SaaS
Odoo.sh
Move filestore
Database setup
Getting started
Running Odoo
Shell script
Sign in
Developer mode
Theming
Theme module
Technical naming
File structure
Initialization
Declaration
Default options
Odoo variables
Global
Fonts
Google fonts
Custom fonts
Colors
Gradients
Bootstrap variables
Font sizes
Text style
Sizing classes
Heading and body text
Display headings
Website settings
Views
Presets
Assets
Styles
Interactivity
Layout
Default
XPath
Expressions
Position
QWeb
Custom fields
Declaration
Back-end
Front-end
Background
Colors
Image/pattern
Header
Standard
Desktop template
Mobile template
Custom
Components
Logo
Menu
Sign in
User dropdown
Language selector
Call to action
Navbar toggler
Footer
Standard
Custom
Copyright
Drop zone
Responsive
Font sizes
Column sizes
Visibility conditions
Navigation
Default
Menu item
New window
External Links
Anchor
Dropdown menu
Mega menu
Custom template
Pages
Default pages
Theme pages
noupdate attribute
Header overlay
Page templates
Media
Images
Declaration
Use
Regular images
Background images
Company logo
Videos
Icons
Building blocks
File structure
Layout
Wrapper
Elements
Sizing
Colors
Features
Non-editable areas
Backgrounds
Text highlights
Grid layout
Use
Items in a grid
Grid item padding
Compatibility system
Custom snippet
Template
1. Declaration
2. Group creation
3. Snippet addition
Inner content snippet
Options
Template
Binding
data-selector
data-target
data-exclude
data-drop-in
data-drop-near
data-js
Layout & fields
Methods
Built-in methods
Selection
Events
Custom methods
Dynamic Content templates
Call the template
Examples
Shapes
Background shapes
Standard
Colors mapping
Switch colors mapping
Add extra colors mapping
Custom
Attachment
SCSS
Add the option
Use it into your pages
Gradients
Standard
Custom
Animations
On appearance
On scroll
On hover
Forms
Default form
Actions
Success
Translations
Frontend
Default pages
Translatable strings
t-att- / t-attf-
Exception: t-value / t-valuef
Mixing translatable and non-translatable
Backend
Export
PO file
Import
Going live
Module import
Odoo SaaS
Odoo.sh
What’s next?
Web Services
XML-RPC Library
JSON-RPC Library
Multi-company Guidelines
Company-dependent fields
Multi-company consistency
Default company
Views
Security rules
Create customized reports
Create a model
Populate the model
Use the model
Extra tips
Accounting localization
Installation procedure
Building a localization module
Chart of Accounts
Account tags
Accounts
Account groups
Taxes
Tax Report
Fiscal positions
Final steps
Accounting reports
Translating Modules
Exporting translatable term
Implicit exports
Explicit exports
Context
Variables
Blocks
Plural
Read vs Run Time
Connect with a device
Detect Devices
Interface
Driver
Communicate With Devices
Actions
Longpolling
升级私有云Odoo数据库
Step 1: Stop the developments
Step 2: Request an upgraded database
Step 3: Empty database
Make custom modules installable
Test and fixes
Clean the code
Standard tests
Step 4: Upgraded database
Migrate the data
Running and testing upgrade scripts
Test the custom modules
Step 5: Testing and rehearsal
Step 6: Production upgrade
Frontend development
Server-side development
Custom development
开发手册
Server framework
ORM API
Changelog
Odoo version 18.0
Odoo Online version 17.4
Odoo Online version 17.3
Odoo Online version 17.2
Odoo Online version 17.1
Odoo version 17.0
Odoo Online version 16.4
Odoo Online version 16.3
Odoo Online version 16.2
Odoo version 16.0
Odoo Online version 15.4
Odoo Online version 15.3
Odoo Online version 15.2
Models
AbstractModel
Model
TransientModel
Fields
Basic Fields
Advanced Fields
Date(time) Fields
Relational Fields
Pseudo-relational fields
Computed Fields
Related fields
Automatic fields
Access Log fields
Reserved Field names
Recordsets
Field access
Record cache and prefetching
Method decorators
Environment
Useful environment methods
Altering the environment
SQL Execution
Common ORM methods
Create/update
Search/Read
Fields
Search domains
Unlink
Record(set) information
Operations
Filter
Map
Sort
Grouping
Inheritance and extension
Classical inheritance
Extension
Delegation
Fields Incremental Definition
Error management
Data Files
Structure
Core operations
record
field
delete
function
Shortcuts
menuitem
template
CSV data files
Actions
Bindings
Window Actions (ir.actions.act_window)
URL Actions (ir.actions.act_url)
Server Actions (ir.actions.server)
State fields
Evaluation context
Report Actions (ir.actions.report)
Client Actions (ir.actions.client)
Scheduled Actions (ir.cron)
Advanced use: Batching
Advanced use: Triggers
Security
QWeb Reports
Report template
Minimal viable template
Translatable Templates
Barcodes
Useful Remarks
Paper Format
Custom Reports
Custom fonts
Reports are web pages
Module Manifests
Manifest
Security in Odoo
Access Rights
Record Rules
Global rules versus group rules
Field Access
Security Pitfalls
Unsafe Public Methods
Bypassing the ORM
SQL injections
Unescaped field content
Creating safe content using Markup
Escaping vs Sanitizing
Evaluating content
Accessing object attributes
Performance
Profiling
Enable the profiler
Analyse the results
Collectors
SQL collector
Periodic collector
QWeb collector
Sync collector
Performance pitfalls
Good practices
Batch operations
Reduce the algorithmic complexity
Use indexes
Testing Odoo
Testing Python code
Running tests
Test selection
Invocation
Special tags
Examples
Testing JS code
Qunit test suite
Testing Infrastructure
Modularity and testing
Adding a new test case
Helper functions and specialized assertions
Best Practices
Tips
Integration Testing
Writing a test tour
Structure
Javascript
Python
Writing an onboarding tour
Structure
Javascript
XML
Running onboarding tours
Tour recorder
Debugging tips
Observing test tours in a browser
watch=True
debug=True
Run via browser
Screenshots and screencasts during browser_js tests
Introspecting / debugging steps
Performance Testing
Query counts
Web Controllers
Controllers
API
Routing
Request
Response
Mixins and Useful Classes
Messaging features
Messaging integration
Basic messaging system
Logging changes
Subtypes
Customizing notifications
Overriding defaults
Mail alias
Aliases vs. Incoming Mail Gateway
Alias support integration
Activities tracking
Website features
Visitor tracking
Website visibility
Website metadata
Others
Customer Rating
Adding rating on your model
Send rating requests by e-mail
Web framework
Framework Overview
Introduction
Code structure
WebClient Architecture
Environment
Building Blocks
Registries
Services
Components and Hooks
Context
User Context
Action Context
Python Interpreter
Domains
Bus
Browser Object
Debug mode
Assets mode
Tests mode
Assets
Asset types
Bundles
Operations
append
prepend
before
after
include
remove
replace
Loading order
Lazy loading
The asset model (ir.asset)
Javascript Modules
Plain Javascript files
Native Javascript Modules
Aliased modules
Limitations
Odoo Module System
Defining a module
Owl components
Using Owl components
Best practices
Reference List
ActionSwiper
Location
Description
Props
Example: Extending existing components
CheckBox
Location
Description
Props
ColorList
Location
Description
Props
Dropdown
Location
Description
Dropdown Props
DropdownItem Props
Nested Dropdown
Controlled Dropdown
DropdownGroup
Notebook
Location
Description
Props
Pager
Location
Description
Props
SelectMenu
Location
Description
Props
TagsList
Location
Description
Props
Registries
Registry API
Reference List
Effect registry
Formatter registry
Main components registry
Parser registry
Service registry
Systray registry
Usermenu registry
Services
Defining a service
Using a service
Reference List
Cookie service
Overview
API
Effect service
Overview
API
Available effects
RainbowMan
How to add an effect
Example
Http Service
Overview
API
Example
Notification service
Overview
API
Examples
Router Service
Overview
API
RPC service
Overview
API
Error Handling
Scroller service
Overview
API
Title Service
Overview
API
User service
Overview
API
Hooks
useAssets
Location
Description
useAutofocus
Location
Description
API
useBus
Location
Description
API
usePager
Location
Description
API
usePosition
Location
Description
API
useSpellCheck
Location
Description
API
Patching code
Description
Patching a simple object
Patching a javascript class
Patching a component
Removing a patch
Applying the same patch to multiple objects
Error handling
Errors in JavaScript
The Error class
Anything can be thrown
Promise rejections are errors
error events are not errors
Lifecycle of errors within the Odoo JS framework
Throwing an error at the top-level of a module
The error service
The error_handlers registry
Throwing an error in an Owl component
Marking errors as handled
onError
Handler in the error_handlers registry
Avoid throwing errors as much as possible
Errors are expensive
Throwing errors makes debugging harder
Throwing breaks the normal flow of the code
Catching errors
Error free control flow
Return null or undefined
Return an object or array
When to throw errors
Javascript Reference
Overview
Web client
Single Page Application
Overview of web client JS code
What to do if a file is not loaded/updated
Loading Javascript Code
Patching classes
Registries
Services
Using services
Talking to the server
Notifications
Displaying notifications
Systray
Adding a new Systray Item
Translation management
Session
Adding information to the session
Views
Fields
Decorations
Non-relational fields
Relational fields
Widgets
Client actions
Adding a client action
Mobile JavaScript
Introduction
How does it work?
How to use it?
Methods
Show Toast in device
Vibrating device
Show snackbar with action
Showing notification
Create contact in device
Scanning barcodes
Switching account in device
QWeb Templates
Data output
Conditionals
Loops
attributes
setting variables
calling sub-templates
Advanced Output
Python
forcing double-escaping
Deprecated output directives
Python
Exclusive directives
Asset bundles
“smart records” fields formatting
Debugging
Rendering cache:
Why and when to use t-cache?
What if there is a t-cache inside a t-cache?
What is t-nocache used for?
The base of t-cache
t-cache and scoped values (t-set, t-foreach…)
The base of t-nocache
t-nocache and scoped root values (t-set, t-foreach…)
t-nocache-* add some primitive values in the cache
Helpers
Request-based
View-based
Javascript
Exclusive directives
Defining templates
Template inheritance
Old inheritance mechanism (deprecated)
debugging
Helpers
API
Odoo Editor
Powerbox
Modifying the Powerbox
Opening a custom Powerbox
Filtering commands
开发手册
Category
Command
Options
User interface
View records
Generic structure
View types
Fields
Inheritance
View resolution
Inheritance specs
Inheritance position
Model commons
View architectures
Generic architecture
Python expression
Form
Root attributes
Semantic components
field: display field values
label: display field labels
button: display action buttons
Chatter widget
Attachments preview widget
Structural components
group: define columns layouts
sheet: make the layout responsive
notebook & page: add tabbed sections
newline: start new group rows
separator: add horizontal spacing
header: display workflow buttons and a status
footer: display dialog buttons
Buttons container
Title container
Settings
Components
app: declare the application
block: declare a group of settings
setting: declare the setting
List
Root attributes
Components
field: display field values
button: display action buttons
groupby: define group headers
header: display workflow buttons
control & create: add inline create buttons
Search
Components
field: filter based on field values
filter: create pre-defined filters
separator: separate groups of filters
group: separate groups of filters
searchpanel: display search panels
Search defaults
Kanban
Root attributes
Components
templates: define cards structure
Fields
Rendering Context
Buttons and links
Widgets
Layouts
field: declare more fields to fetch
header: display buttons in the control panel
progressbar: show progress bars on top of columns
QWeb
Graph
Pivot
Calendar
Model Commons
Activity
Cohort
Grid
Limitations
Schema
Server interactions
Server Hooks
ACL
Context Keys
Gantt
Map
API
Structural components
SCSS inheritance
Overview
SCSS’s !default directive
Odoo’s SCSS inheritance system
UI icons
Icons
RTL adaptations
Standard modules
Accounting
Account Tag
Account
Fiscal Position
Account Group
Report
Report Line
Taxes
Tax Repartitions
Payment
Payment Method
Payment Provider
Payment Token
Payment Transaction
Command-line interface (CLI)
Help & version
Running the server
Testing Configuration
Database
Emails
Internationalisation
Advanced Options
Developer features
HTTP
Logging
Multiprocessing
Configuration file
Shell
Neutralize
Scaffolding
Database population
Cloc
Command-line options
Processed files
With the --database option
With the --path option
Identifying Extra Modules
Error Handling
Max file size exceeded
Syntax Error
TSConfig Generator
Upgrades
Upgrade scripts
Writing upgrade scripts
Phases of upgrade scripts
Upgrade utils
Installation
Using upgrade utils
Util functions
Modules
Models
Fields
Records
ORM
SQL
Misc
External API
Connection
Configuration
API Keys
Test database
Logging in
Calling methods
List records
Pagination
Count records
Read records
List record fields
Search and read
Create records
Update records
Delete records
Inspection and introspection
ir.model
ir.model.fields
Extract API
Overview
Version
Flow
Parse
Routes
Request
Response
Get results
Routes
Request
Response
Common fields
feature_result
candidate
Invoices
invoice_lines feature
Bank statements
bank_statement_lines feature
Expense
Applicant
Integration Testing
本开发教程为确保更为精准,将主要使用英文。欢迎来到 Odoo 开发者文档!无论您是经验丰富的开发者还是刚刚入门,这里都有您开发 Odoo 应用所需的所有技术指导和资源。浏览我们丰富的教程、操作指南和参考资料,以实现您的开发目标。
Odoo 的开发生态系统建立在一个模块化和可扩展的架构上,允许您扩展现有应用程序或创建新的应用程序以满足现代企业的特定需求。您可以利用 Odoo 提供的工具和框架,专注于快速启动和运行您的 Web 应用程序,而无需重新发明轮子或担心底层基础设施。
如果您是 Odoo 或 Web 应用开发的新手,请从 Server framework 101 教程开始。
TutorialsTutorials take you by the hand through hands-on exercises to build skills and familiarity in
Odoo development.
How-to guidesRecipes that provide a step-by-step guide for addressing real-world problems and use-cases.
ReferenceTechnical descriptions and factual information on the frameworks and APIs of Odoo.
更多内容
开发指南:贡献代码
Odoo开发者社区