赞
踩
注:Odoo自带全面功能的web客户端
mkdir -p ~/odoo-dev/custom-addons/library_app
touch ~/odoo-dev/custom-addons/library_app/__init__.py
{
# 插件模块标题字符串
'name': 'Library Management',
# 功能描述长文件,通常为RST格式
'description': 'Manage library book catalogue and lending.',
# 作者姓名,本处为一个字符串,可以是逗号分隔的一系列姓名
'author': 'Alan Hou',
# 一个依赖插件模块列表,在模块安装时会先安装这些插件
'depends': ['base'],
# 一个布尔型标记,代表模块是否在应用列表中以APP展现
'application': True,
}
from . import test_book
from odoo.tests.common import TransactionCase
class TestBook(TransactionCase):
def setUp(self, *args, **kwargs):
result = super().setUp(*args, **kwargs)
self.Book = self.env['library.book']
self.book_ode = self.Book.create({
'name': 'Odoo Development Essentials',
'isbn': '879-1-78439-279-6'})
return result
def test_create(self):
"Test Books are active by default"
self.assertEqual(self.book_ode.active, True)
~/odoo-dev/odoo/odoo-bin -d dev12 -u library_app --test-enable
from . import models
from . import library_book.py
(library_book是模型的名字)from odoo import fileds, models
class Book(models.Model):
# 模型的标识符
_name = 'library.book'
_description = 'Book'
name = fields.Char('Title', required=True)
isbn = fields.Char('ISBN')
active = fields.Boolean('Active?', default=True)
date_published = fields.Date()
image = fields.Binary('Cover')
publisher_id = fields.Many2one('res.partner', string='Publisher')
author_ids = fields.Many2many('res.partner', string='Authors')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。