介绍待办事项清单项目

阅读(524) 最后更新: 2019年4月18日 08:48

上一页 技术要求 | 基本概念 下一页

翻译进度 100%

自助翻译

TodoMVC 项目通过在每个框架中实现相同的简单待办应用程序来对比多个JavaScript框架。


The TodoMVC (http://todomvc.com/) project provides a comparison between multiple JavaScript frameworks by implementing the same simple to-do application in each of them.

受此启发,我们将通过Odoo构建一个简单的待办应用程序。


Inspired by this, we will go through the experience of building a simple to-do application with Odoo.

它应该允许我们添加新的待办事项,然后将其标记为已完成。例如,您可以将待办事项添加到列表中,例如购买鸡蛋,然后在完成后选中“完成”框。To-do 项目应仅对当前用户可见,因而每个人可以获取自己的 to-do 列表。


It should allow us to add new to-do items, and then mark them as completed.For example, you could add to-do items to the list, such as Buy eggs, and then check an Is Done?box once they are completed.The To-do Items should be private to the current user, so that you will only be able to access your own to-do items.

对于一个简易待办应用程序这已足够,但为增加点趣味性,我们还将允许 to-do 列表项目包含一组和任务相关的用户,即工作小组。


This should be enough for a simple to-do application, but to make it a little more interesting we will introduce a couple of complications.Our to-do list items should be able to include a list of people involved in the task, the work team.

通过以下几个层来考虑我们的应用程序。

数据层 通过模型实现

逻辑层  通过自动化代码实现

表示层 通过数据层的视图实现

对于数据层,我们需要一个待办项目模型,我们也将利用内置的合作伙伴(或联系人)模型来支持工作组特性。当然还要记得在新的模型中配置访问权限。


It is useful to think about our application by considering several layers involved: The data tier: Implemented through models The logic tier: Implemented through automation code The presentation tier: Implemented through views For the data tier, we need a To-do Item model.We will also make use of the built-in partner (or contacts) model to support the work team feature.We must not forget to configure the access control security for our new model.

逻辑层中我们使用框架处理增删改查(CRUD)基本操作,要使用框架的全部功能,我们需要在开发的模块中编写Python 代码。对于初学者,可以使用用户界面开发者菜单自动化工具来实现业务逻辑,后面的例子中会进行说明。


The logic tier used here will be the basic CRUD operations handled by the framework, and we don't have in our requirements any additional automation to support.To access the full power of the framework, we need to use Python code in developer modules.While we can't do that yet, the developer menu does provide some tools for us to implement some business logic from the user interface, the automate actions.We will work on a simple example of how to use them.

最后,对于表示层,我们将为应用程序添加菜单选项,为待办事项模型添加视图。业务应用的基本视图有用于查看已有记录的列表视图、深入查看记录细节的表单视图。为增强易用性,我们还可以在列表视图中的搜索框预置过滤项。可用搜索选项也被视为一个视图,因此可以通过搜索视图来完成。


Finally, for the presentation tier we will add the menu option for our application, and the views for the to-do item model.The essential views for a business application are the list view, where we can browse the existing records, and the form view, where we can zoom in to a record and see all the details.For better usability, we can also add preconfigured filters to the search box, available in the list view.The available search options are also considered a view, so this can be done through a search view.

以下是创建 to-do 列表应用的步骤

首先,我们将为待办事项创建一个新模型,然后添加一个顶部菜单让其对用户可见。


The following are the steps to create a to-do list: First, we will create a new model for to-do items, and then make it available to1.
接下来,我们将为待办事项模型创建列表和表单视图。
Next, we will create the list and form views for the To-do Items model.This new2.

新的模型应该包含如下字段

Description: 文本类型字段

Is Done:标记(布尔型字段)

我们的应用程序功能包括能够选择将要处理该任务的人员列表,因此我们需要一个模型来表示人员。所幸 Odoo 自带就有这样的模型 – 合作伙伴模型(res.Partner是它的技术名称),它可用于存储个人、公司和地址等信息。


model should have these fields: Description text field Is Done?flag (a Boolean field) Our specification for the application includes the ability to select a list of people that will be working on the task, so we need a Model to represent people.Fortunately, Odoo includes out of the box a model for this—the partner model (res.partner is its technical name), used to store individual people, companies, and addresses.

并且仅有指定的人可被选择加入工作团队,因此我们需要修改 partner 模型添加Is Work Team?标记。


And only particular persons are selectable for this work team.This means that we need to modify the partner model to add this new Is Work Team?flag.

因此,待办事项模型还应该包括工作组字段,可以列出人员列表。


So, the To-do Items model should also include the work team field, with a list of people.

在添加了Is Work Team?标记后这些关联用户可在合作伙伴/联系人中进行选取。


The linked people are selectable from the partners/contacts that have the Is Work Team?flag enabled.

综上,我们需要做的有:

为 partner 模型和表单视图添加字段创建一个 to-do 项模型创建一个 to-do 应用菜单项创建 to-do 项用户界面:列表、表单视图以及 UI 中的搜索选项创建访问权限:组、权限控制列表(ACL)和记录规则在进入实际实现之前,我们将先讨论一些关于Odoo框架的基本概念,然后学习如何准备工作环境。


As a summary, this is what we will need to do: Add a field to the partner model and form view Create a To-do Item model Create a to-do application menu item Create a to-do Item user interface: List and form view, and UI search options Create access security: Group, access control lists (ACL), and Record Rules Before we go into the actual implementation, we will first discuss a few basic concepts about the Odoo framework, and then learn how to prepare an environment to work with.

odoo技术交流2 群号 625337975

http://www.odoogo.com/post/58/Odoo开发视频教程

文档不断更新中,添加微信odoogo,获取最新视频课程和模块

留言提问