Some basic concepts of odoo

overview

Three-tier architecture, the presentation layer is a combination of HTML5, JavaScript and CSS, the logic layer is written exclusively in Python, and the data layer only supports PostgreSQL as the RDBMS.
Both server and client extensions are packaged as modules, which are optionally loaded into the database. A module is a collection of functions and data for a single purpose. Everything in Odoo starts and ends with a module

Enable debug mode

http://localhost:8069/web?debug=1

Odoo module composition

A module must contain two files, manifest.py and init.py

  • The _manifest.py file must describe our module and cannot be empty. The only field it needs is the name, but it usually contains more information. It is equivalent to the settings file, which is actually the configuration file corresponding to each module
  • The init.py file can now remain empty.

The following files increase or decrease as the case may be

  • models: specific models
    • Classes and methods are defined, and the database and its required fields are generated
    • All data orm is placed inside
  • security: secure folder
    • Manage permissions to add, delete, modify and query odoo models (read, write, create, unlink)
  • views: view folder, used for front-end display
  • controllers folder
    • Inside you can store your own routing method
    • You can write some flexible interface methods or view interfaces in it
  • demo folder
    • Some test data can be written in it, and the demo data will be automatically written when the module is installed
  • views folder
    • Put the template template and the view of the view in it, and the usage of the view view will be explained in detail later

    • insert image description here
      The complete structure of tree view, from view and search view is as follows:
      insert image description here

Addition, deletion, modification and query of Odoo

1) create function: (increase)

create(vals_list)
如:XXXX.create({‘name’: “New Name”})

2) unlink function: (delete)

unlink()

3) write function: (change)

create(vals_list)
如:XXXX.create({‘name’: “New Name”})

4) read, search, and search_read function functions: (check)

Query all data in the model
course_list = self.env['student_achieve_manage_sys.course'].search([])

Query specified condition data
XXX.search([('is_company', '=', True), ('customer', '=', True)])

Query the first 2 data
search([
('name', '=', attachment_name),
('res_model', '=', self.model),
('res_id', '=', record.id)
], limit =2)
The Read function queries a piece of data
. The search_read function is used as follows
search_read(domain,fields) # domain query condition, fields display field name

Guess you like

Origin blog.csdn.net/weixin_44141284/article/details/129416532