Search code examples
pythontryton

can not update in database trytond


i am trying to adding a new module in my database. i faced this problem that i can not any solution. the code of my init.py is:

from trytond.pool import Pool

from grh.Employe import *


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

and the problem after trying is :

  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)

help me please


Solution

  • Your are running the server from /usr/local/lib/python2.7/dist-packages/trytond-3.2.2-py2.7.egg, so the module must be in /usr/local/lib/python2.7/dist-packages/trytond-3.2.2-py2.7.egg/trytond/modules/ folder or installed in /usr/local/lib/python2.7/dist-packages/

    For development proposes I will recommend you running from sources without installing the packages. If you have done this, you're not connecting to the right tryton instance.

    If you want to always install your module, just run python setup.py install (assuming that your custom module have the setup.py file defined with the correct methods and name).

    You can find a template of setup.py on http://hg.tryton.org/tryton-tools/file/b1bf3e9fe771/contrib-module-setup.tmpl