【发布时间】:2015-09-04 10:19:13
【问题描述】:
我是 odoo 和 python 的新手,想知道是否可以帮助我加载我的模块。我一直在密切关注 odoo 8 文档,并且在本地模块部分中没有任何内容。 (是的,我点击了刷新/更新模块列表)。
我还确保在我的 odoo-server.conf 文件中放置了正确的路径,并确保它们没有冲突。
下面是代码:
Models.py
Created on 4 Sep 2015
@author:
'''
# -*- coding: utf-8 -*-
from openerp import models, fields, api
# class test(model.Model):
# _name = 'test.test'
# name = fields.Char()
__init__.py
from . import controllers
from . import models
__openerp__.py file
{
'name': "models",
'version': '1.0',
'depends': ['base'],
'author': "Elliot",
'category': 'Category',
'description': """
My first working module.
""",
'installable': True,
'auto_install': False,
'data': [
'templates.xml',
],
'xml': [
'xml.xml'
],
}
controllers.py
from openerp import http
# class test_mod(http.Controller):
# @http.route('/test_mod/model/', auth='public')
# def index(self, **kw):
# return "Hello, world"
# @http.route('/test_mod/model/objects/', auth='public')
# def list(self, **kw):
# return http.request.render('test_mod.listing', {
# 'root': '/Test_mod/Test_mod',
# 'objects': http.request.env['test_mod.model'].search([]),
# })
# @http.route('/test_mod/model/objects/<model("test_mod.model"):obj>/', auth= 'public')
# def object(self, obj, **kw):
# return http.request.render('test_mod.object', {
# 'object': obj
# })
and templates.xml
<openerp>
<data>
<!-- <template id="listing"> -->
<!-- <ul> -->
<!-- <li t-foreach="objects" t-as="object"> -->
<!-- <a t-attf-href="{{ root }}/objects/{{ object.id }}"> -->
<!-- <t t-esc="object.display_name"/> -->
<!-- </a> -->
<!-- </li> -->
<!-- </ul> -->
<!-- </template> -->
<!-- <template id="object"> -->
<!-- <h1><t t-esc="object.display_name"/></h1> -->
<!-- <dl> -->
<!-- <t t-foreach="object._fields" t-as="field"> -->
<!-- <dt><t t-esc="field"/></dt> -->
<!-- <dd><t t-esc="object[field]"/></dd> -->
<!-- </t> -->
<!-- </dl> -->
<!-- </template> -->
</data>
</openerp>
【问题讨论】: