Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

OpenERP Migration to Centos 6.5 Custom Addons Error

By
cahyo
on 3/10/14, 3:14 AM 1,861 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.

1

Leonardo Donelli

--Leonardo Donelli--
1040
| 5 4 8
Cave, Italy
--Leonardo Donelli--

Physics student and part-time developer.

Leonardo Donelli
On 3/10/14, 5:56 AM

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).

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

cahyo
on 3/11/14, 12:12 AM

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/

Leonardo Donelli
on 4/24/14, 8:54 AM

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

cahyo
on 4/25/14, 12:15 AM

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

Leonardo Donelli
on 4/29/14, 1:07 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/10/14, 3:14 AM
Seen: 1861 times
Last updated: 3/16/15, 8:10 AM