This question has been flagged
1 Reply
4530 Views

I have problem when i migrate my OpenERP addons to centos 6.5, Previously the addons runs well in Ubuntu 12.04 and Debian 7 But for now I have an error like this:

2014-03-06 03:28:35,223 21557 ERROR bac-erp openerp.tools.safe_eval: Cannot eval '#\r\n{\r\n    \'name\'          : \'Project Task Detail\',\r\n    \'category\'      : \'Project Task Detail\',\r\n    \'version\'       : \'1.0\',\r\n    \'depends\'       : ["base","project"],\r\n    \'author\'        : \'Cahyo Bagus L\',\r\n    \'description\'   : \'\'\'Project Task Detail\'\'\',\r\n    \'init_xml\'      : [],\r\n    \'update_xml\'    : [\'bac_project_task_detail_view.xml\'],\r\n    \'installable\'   : True,\r\n    \'active\'        : False,\r\n}\r\n'
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/tools/safe_eval.py", line 241, in safe_eval
    return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/tools/safe_eval.py", line 107, in test_expr
    code_obj = compile(expr, "", mode)
  File "<string>", line 2
     {
^
 SyntaxError: invalid syntax
2014-03-06 03:28:35,224 21557 ERROR bac-erp openerp.netsvc: invalid syntax
('', 2, 2, '{\r\n')

    2014-03-06 02:14:20,121 21145 ERROR bac-erp openerp.netsvc: invalid syntax
    ('', 2, 1, '\r\n')
    Traceback (most recent call last):
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/netsvc.py", line 292, in dispatch_rpc
        result = ExportService.getService(service_name).dispatch(method, params)
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/service/web_services.py", line 433, in dispatch
        return fn(*params)
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/service/web_services.py", line 444, in exp_authenticate
        res_users = pooler.get_pool(db).get('res.users')
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/pooler.py", line 49, in get_pool
        return get_db_and_pool(db_name, force_demo, status, update_module)[1]
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/pooler.py", line 33, in get_db_and_pool
        registry = RegistryManager.get(db_name, force_demo, status, update_module)
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/modules/registry.py", line 203, in get
        update_module)
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/modules/registry.py", line 233, in new
        openerp.modules.load_modules(registry.db, force_demo, status, update_module)
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/modules/loading.py", line 350, in load_modules
        force, status, report, loaded_modules, update_module)
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/modules/loading.py", line 254, in load_marked_modules
        graph.add_modules(cr, module_list, force)
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/modules/graph.py", line 102, in add_modules
        info = openerp.modules.module.load_information_from_description_file(module)
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/modules/module.py", line 344, in load_information_from_description_file
        info.update(eval(f.read()))
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/tools/safe_eval.py", line 241, in safe_eval
        return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
      File "/usr/lib/python2.6/site-packages/openerp-7.0_20140226_002804-py2.6.egg/openerp/tools/safe_eval.py", line 107, in test_expr
        code_obj = compile(expr, "", mode)
      File "<string>", line 2

        ^
     SyntaxError: invalid syntax

This is the Detail spec of my server. Python 2.6 Centos 6.5 openerp-7 latest form nightly build. This Error happen only to custom addons i made, not addons included in openerp like hr,sale,purchase. and here is my addons.

# __openerp__.py
    {
        'name'          : 'Project Task Detail',
        'category'      : 'Project Task Detail',
        'version'       : '1.0',
        'depends'       : ["base","project"],
        'author'        : 'Author Name',
        'description'   : '''Project Task Detail''',
        'init_xml'      : [],
        'update_xml'    : ['bac_project_task_detail_view.xml'],
        'installable'   : True,
        'active'        : False,
    }

from openerp.osv import fields, osv
from openerp import netsvc

class bac_project_task_detail(osv.osv):
    _name = "project.task.work"
    _inherit = "project.task.work"
    def _get_project(self, cr, uid, ids, name, args, context=None):
        task_work = self.browse(cr, uid, ids, context=context)
        x = {}

        for line in task_work:
            x[line.id] = line.task_id.project_id.name

        return x
    def _get_description(self, cr, uid, ids, name, args, context=None):
        task_work = self.browse(cr, uid, ids, context=context)
        x = {}

        for line in task_work:
            x[line.id] = line.task_id.description

        return x
    _columns = {
        'project_id': fields.function(_get_project, type="char", string='Project'),
        'description': fields.function(_get_description, type="text", string='Task Description'),
        'category' : fields.many2one(
      'bac.task.work.category',
      'Task Category'),
    }
bac_project_task_detail()

class bac_task_work_category(osv.osv):
    _name = "bac.task.work.category"
    _description = "bac.task.work.category"
    _columns = {
        'name': fields.char('Name', size=64)
    }
bac_task_work_category()

Do you know why this happen? and what solution i can do to fix the problem? Please advice. Thanks Before.

Avatar
Discard
Best Answer

Check line endings

It's probably an error due to the line endings in the __openerp__.py file being converted to dos line endings (\r\n). I had the same error in the same situation, and I solved it by changing them back to Unix file endings (\n)

You can check file endings using file __openerp__.py, if it returns something with with CRLF line terminators it means the file has DOS file endings.

You can change them back to unix, using your text editor/IDE most of the time, or you can use the command set ff=unix in Vim or the utility dos2unix in bash (you may need to install it).

Avatar
Discard
Author

Hi After change it to unix the problem disappear. Thank you very much.

Happy to hear that. You should accept the answer, see: http://help.openerp.com/question/1477/meta-add-to-the-faq-explanation-on-why-to-accept-answers/

Author

How i accept the answer? i already vote for this answer and click check too.

It's the "check" thing, it is now accepted.