Ai翻译及测试Odoo17开发教程,第一章:架构概览

Chapter 1: Architecture Overview 第一章:架构概览

原文来自:https://www.odoo.com/documentation/17.0/zh_CN/developer/tutorials/server_framework_101/01_architecture.html

使用通义千问翻译。

Multitier application 多层应用程序

Odoo follows a multitier architecture, meaning that the presentation, the business logic and the data storage are separated. More specifically, it uses a three-tier architecture (image from Wikipedia):Odoo遵循多层架构模式,这意味着表示层、业务逻辑层和数据存储层是分离的。更具体地说,它采用三层架构(图片来源于Wikipedia):

Three-tier architecture

在Odoo的架构中,这三个层级分别对应着不同的功能和职责:

  1. 表示层(Presentation Tier):应用的最顶层是用户界面。界面的主要功能是将任务和结果转化为用户能够理解的形式。这是用户与系统交互的部分,通常指的是Odoo的前端界面。表示层负责接收用户的输入,展示数据给用户,并处理与用户相关的所有视觉呈现和交互逻辑。
  2. 应用逻辑层(Application Logic Tier):也称为业务逻辑层或服务层,它包含了应用程序的核心业务规则和流程。这部分处理数据的业务操作,如计算、验证和数据转换。这一层负责协调应用程序,处理命令,做出逻辑判断和评估,并执行计算。它还在这两层之间移动和处理数据。
  3. 数据存储层(Data Storage Tier):这是存放数据的地方,通常是一个关系型数据库管理系统(RDBMS)。在这里,信息从数据库或文件系统中被存储和检索。随后,这些信息被传递回逻辑层进行处理,最终再反馈给用户。

Ai额外给出的一些说明:这种分层的架构设计使得Odoo具有高度的灵活性和可扩展性,每一层都可以独立地进行开发、测试和优化,而不会影响到其他层。同时,这样的设计也便于维护和升级,因为每一层的改动通常不会对其他层产生直接的影响,从而降低了系统的整体复杂度。

此外,Odoo的三层架构还支持分布式部署,允许表示层、应用逻辑层和数据存储层分布在不同的物理服务器上,从而提高了系统的性能和可用性。例如,可以将数据库部署在高可用性的集群中,而将应用服务器部署在多个地理位置,以减少网络延迟并提高用户体验。

The presentation tier is a combination of HTML5, JavaScript and CSS. The logic tier is exclusively written in Python, while the data tier only supports PostgreSQL as an RDBMS.

表示层是由HTML5、JavaScript和CSS组合而成的。逻辑层则完全用Python编写,而数据层仅支持PostgreSQL作为其关系型数据库管理系统(RDBMS)。

Depending on the scope of your module, Odoo development can be done in any of these tiers. Therefore, before going any further, it may be a good idea to refresh your memory if you don’t have an intermediate level in these topics.

根据你的模块范围,Odoo的开发工作可以在这些层级中的任意一层进行。因此,在继续深入之前,如果你在这些主题上没有达到中级水平,复习一下相关知识可能会很有帮助。

In order to go through this tutorial, you will need a very basic knowledge of HTML and an intermediate level of Python. Advanced topics will require more knowledge in the other subjects. There are plenty of tutorials freely accessible, so we cannot recommend one over another since it depends on your background.

为了完成这个教程,你需要具备非常基础的HTML知识,以及Python的中级水平。对于更高级的主题,你将需要在其他领域掌握更多知识。网络上有大量免费的教程资源,所以我们无法推荐某一个特定的教程,因为这取决于你的背景知识。

For reference this is the official Python tutorial.作为参考,这里提供的是官方的Python教程链接。

 注解

Since version 15.0, Odoo is actively transitioning to using its own in-house developed OWL framework as part of its presentation tier. The legacy JavaScript framework is still supported but will be deprecated over time. This will be discussed further in advanced topics.

自15.0版本起,Odoo正积极地将其表示层转向使用自家研发的OWL框架。尽管旧有的JavaScript框架目前仍得到支持,但随着时间推移,它将逐渐被淘汰。这一转变将在更高级的主题中进一步讨论。

Odoo modulesOdoo模块

Both server and client extensions are packaged as modules which are optionally loaded in a database. A module is a collection of functions and data that target a single purpose.

无论是服务器端还是客户端的扩展,都被封装为模块,这些模块可以选择性地在数据库中加载。模块是一组针对单一目的的函数和数据集合。

Odoo modules can either add brand new business logic to an Odoo system or alter and extend existing business logic. One module can be created to add your country’s accounting rules to Odoo’s generic accounting support, while a different module can add support for real-time visualisation of a bus fleet.

Odoo模块既能向系统添加全新的业务逻辑,也能修改和扩展现有的业务逻辑。例如,一个模块可以用来向Odoo的通用会计支持中添加你所在国家的会计规则,而另一个模块则可以增加实时车队位置的可视化功能。

Everything in Odoo starts and ends with modules. 在Odoo中,一切始于模块,也终于模块。

Terminology: developers group their business features in Odoo modules. The main user-facing modules are flagged and exposed as Apps, but a majority of the modules aren’t Apps. Modules may also be referred to as addons and the directories where the Odoo server finds them form the addons_path.

术语说明:开发者将他们的业务功能封装在Odoo的模块中。面向主要用户的模块会被标记并公开为应用(Apps),但是大部分的模块并不直接作为应用存在。模块有时也会被称为插件(addons),而Odoo服务器查找这些模块的目录集合构成了插件路径(addons_path)。

Composition of a module 模块的组成

An Odoo module can contain a number of elements:Business objects

一个Odoo模块可能包含多个元素:

A business object (e.g. an invoice) is declared as a Python class. The fields defined in these classes are automatically mapped to database columns thanks to the ORM layer.Object views

业务对象业务对象(例如,一张发票)是以Python类的形式声明的。这些类中定义的字段会自动通过对象关系映射(ORM)层映射到数据库列上。

Define UI displayData files 定义用户界面的显示方式,

XML or CSV files declaring the model data:这些是声明模型数据的XML或CSV文件,

  • views or reports, 视图或报表,
  • configuration data (modules parametrization, security rules),配置数据(模块参数设置,安全性规则),
  • demonstration data 演示数据,
  • and more以及其他更多内容。

Web controllers Web 控制器

Handle requests from web browsersStatic web data 处理来自网络浏览器的请求静态网络数据。

Images, CSS or JavaScript files used by the web interface or website 网络界面或网站所使用的图片、CSS 或 JavaScript 文件。

None of these elements are mandatory. Some modules may only add data files (e.g. country-specific accounting configuration), while others may only add business objects. During this training, we will create business objects, object views and data files.这些元素都不是强制性的。有些模块可能仅添加数据文件(例如,特定国家的会计配置),而其他模块可能只添加业务对象。在这次培训中,我们将创建业务对象、对象视图和数据文件。

Module structure 模块结构

Each module is a directory within a module directory. Module directories are specified by using the --addons-path option.每个模块都是模块目录中的一个子目录。模块目录通过使用 --addons-path 选项来指定。

An Odoo module is declared by its manifest.Odoo 模块由其清单(manifest)声明。

When an Odoo module includes business objects (i.e. Python files), they are organized as a Python package with a __init__.py file. This file contains import instructions for various Python files in the module.当 Odoo 模块包含业务对象(即 Python 文件)时,它们会被组织成一个 Python 包,并且包含一个 __init__.py 文件。这个文件包含了对模块中各种 Python 文件的导入指令。

Here is a simplified module directory:以下是一个简化的模块目录:

module
├── models
│   ├── *.py
│   └── __init__.py
├── data
│   └── *.xml
├── __init__.py
└── __manifest__.py

Odoo EditionsOdoo 版本

Odoo is available in two versions: Odoo Enterprise (licensed & shared sources) and Odoo Community (open-source). In addition to services such as support or upgrades, the Enterprise version provides extra functionalities to Odoo. From a technical point-of-view, these functionalities are simply new modules installed on top of the modules provided by the Community version.Odoo 提供两个版本:Odoo 企业版(授权并共享源代码)和 Odoo 社区版(开源)。除了提供支持或升级等服务外,企业版还为 Odoo 增添了额外的功能。从技术角度来看,这些功能仅仅是安装在社区版提供的模块之上的新模块。

Ready to start? It is now time to write your own application!准备开始了吗?现在是时候编写你自己的应用程序了!


评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注