Odoo product analysis (5) -- custom section (2) -- custom odoo for business (1)

View Odoo Product Analysis Series - Catalog


In this chapter, you'll learn how to set up "developer mode" and back up the database; then learn how to add fields to the database and display them in forms and views.

1 Understand the architecture of odoo

Each application has three important components, model (model), view (view), action (action).

1.1 Model

In odoo, models are used to hold and manage the data that make up the application. When saving a sales order, the data in the sales order header is saved to a model named sale.order. Individual data items such as order date and customer address are called fields. In the following introduction,
you will learn to add fields to the sale.order model.

1.2 View

The model itself does not display any information to the end user, it only saves and manages data for the application in the background. Data stored from these models will be displayed in the application using views. Views allow the information in the sale.order model to be displayed in different ways. You can also customize the view you want in odoo.

1.3 Action

Actions are triggers that trigger the corresponding view or perform a specific action on the model. For example, when you select a quotation in a sale, you are triggering an action that tells the odoo framework to display the corresponding sale.order view. Without an action , the odoo framework doesn't know which view to display. Another example is to send or confirm a sales order, when you click OK, the odoo framework will call the corresponding function sale.order will be updated.

2 Developer Mode

The first step in customizing odoo is to activate developer mode. When this mode is entered, odoo displays more information on the screen. This mode also allows you to make changes to the database and store that information in a file.

2.1 Activate developer mode

In the main menu of settings, there is a link to "Activate developer mode" on the right side of the interface:
write picture description here
click "Activate developer mode", and then you can start customizing your own odoo business. To determine if you are in developer mode, see if ?debug is added to the URL on your browser:
write picture description here
Also, when you hover over a field in a form, the field information is displayed. For example, when viewing a sales order in developer mode, placing the mouse on the order date field will display the field details:
write picture description here
as you can see in the screenshot, the field name of the order date field is date_order, and the field belongs to the sale.order model object (In fact, it also represents the database corresponding to the form). Additionally, the field is of type datatime and a decorator is assigned to the field. This information will go a long way in customizing odoo.

2.1 Exit developer mode

After the customization is complete, you need to exit the developer mode and use odoo to start work. Clicking the Settings menu has a "Deactivate Developer Mode" link where it turns on developer mode. Click it to view the URL of the browser, no debug in the URL means the exit was successful:
write picture description here

3 Database backup and recovery

When changes are made systematically in developer mode, those changes are written to the database associated with the company. A major advantage of this approach is that you don't have to write code in Python or create custom modules for easy customization. However, one of the main drawbacks is that you risk making an undesirable and perhaps difficult to reverse change.
Therefore, it is important to back up the database before making changes to the data. And the database should be backed up frequently.

3.1 Backup of the database

To back up the database, you first need to log out of odoo:
write picture description here
after logging out, click the "Database Management" link (if the "Website Builder" module is installed, you may not see this link, at this time click the "Select" button, and then in the displayed database Click the "Database Management" link below the list).
write picture description here
write picture description here
Click on "Manage databases":
write picture description here

(You can click the link to set a password for the system to manage the database)
write picture description here

After each database can choose to "backup", "copy" or "delete" the current database. Click "backup":
write picture description here
you can choose to backup as a .zip file or pg_dump file. The ZIP file will be larger because it will contain an encrypted copy of the stored file. The pg_dump file just contains all the data saved in the POSTGRESQL database. Once selected, click the Backup button.
After clicking backup, odoo will save the backup file locally. If pg_dump is selected for backup, the file extension will be .dump, and the zip format will be .zip suffix. The default name is the database name plus the backup time, such as:
write picture description here

3.2 Recovery of the database

To restore the backed up database, click the "Restore Database" button: you
write picture description here
need to fill in three pieces of information, namely the management password, file path and database name:
write picture description here
click "Continue" to complete the database recovery.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325828454&siteId=291194637