0

我正在尝试在我的数据库中添加一个新模块。我遇到了这个我无法解决的问题。我的init .py 的代码是:

from trytond.pool import Pool

from grh.Employe import *


def register():
    Pool.register(
        Employe,
        module='grh', type_='model')

尝试后的问题是:

  File "/usr/local/bin/trytond", line 5, in <module>
    pkg_resources.run_script('trytond==3.2.2', 'trytond')
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 528, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1394, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/trytond-3.2.2-py2.7.egg/EGG-INFO/scripts/trytond", line 113, in <module>
    trytond.server.TrytonServer(options).run()
  File "/usr/local/lib/python2.7/dist-packages/trytond-3.2.2-py2.7.egg/trytond/server.py", line 123, in run
    Pool(db_name).init(update=update, lang=lang)
  File "/usr/local/lib/python2.7/dist-packages/trytond-3.2.2-py2.7.egg/trytond/pool.py", line 151, in init
    lang=lang)
  File "/usr/local/lib/python2.7/dist-packages/trytond-3.2.2-py2.7.egg/trytond/modules/__init__.py", line 428, in load_modules
    _load_modules()
  File "/usr/local/lib/python2.7/dist-packages/trytond-3.2.2-py2.7.egg/trytond/modules/__init__.py", line 393, in _load_modules
    graph = create_graph(module_list)[0]
  File "/usr/local/lib/python2.7/dist-packages/trytond-3.2.2-py2.7.egg/trytond/modules/__init__.py", line 159, in create_graph
    raise Exception('Module %s not found' % module)

请帮帮我

4

1 回答 1

1

您正在从 /usr/local/lib/python2.7/dist-packages/trytond-3.2.2-py2.7.egg 运行服务器,因此模块必须位于 /usr/local/lib/python2.7/ dist-packages/trytond-3.2.2-py2.7.egg/trytond/modules/ 文件夹或安装在 /usr/local/lib/python2.7/dist-packages/

对于开发建议,我建议您在不安装软件包的情况下从源代码运行。如果你这样做了,你就没有连接到正确的 tryton 实例。

如果您想始终安装您的模块,只需运行 python setup.py install (假设您的自定义模块具有使用正确方法和名称定义的 setup.py 文件)。

您可以在http://hg.tryton.org/tryton-tools/file/b1bf3e9fe771/contrib-module-setup.tmpl找到 setup.py 的模板

于 2014-07-22T09:20:35.003 回答