3
votes

I have recently installed Odoo 9.0. However, I need a module that is only available for Odoo 8.0.

I was wondering if it is possible to apply minor changes to this module to make it compatible for Odoo 9.0? The new module is just a calendar which is simply just using web interface: Link to the module

Here is the error when instaling

Odoo Server Error
Traceback (most recent call last):
  File "/odoo/odoo-server/openerp/http.py", line 643, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/odoo/odoo-server/openerp/http.py", line 680, in dispatch
    result = self._call_function(**self.params)
  File "/odoo/odoo-server/openerp/http.py", line 316, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/odoo/odoo-server/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/odoo/odoo-server/openerp/http.py", line 309, in checked_call
    result = self.endpoint(*a, **kw)
  File "/odoo/odoo-server/openerp/http.py", line 959, in __call__
    return self.method(*args, **kw)
  File "/odoo/odoo-server/openerp/http.py", line 509, in response_wrap
    response = f(*args, **kw)
  File "/odoo/odoo-server/addons/web/controllers/main.py", line 896, in call_button
    action = self._call_kw(model, method, args, {})
  File "/odoo/odoo-server/addons/web/controllers/main.py", line 884, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/odoo/odoo-server/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/odoo/odoo-server/openerp/addons/base/module/module.py", line 459, in button_immediate_install
    return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
  File "/odoo/odoo-server/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/odoo/odoo-server/openerp/addons/base/module/module.py", line 533, in _button_immediate_function
    registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
  File "/odoo/odoo-server/openerp/modules/registry.py", line 386, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/odoo/odoo-server/openerp/modules/loading.py", line 338, in load_modules
    loaded_modules, update_module)
  File "/odoo/odoo-server/openerp/modules/loading.py", line 237, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/odoo/odoo-server/openerp/modules/loading.py", line 156, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
  File "/odoo/odoo-server/openerp/modules/loading.py", line 98, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "/odoo/odoo-server/openerp/tools/convert.py", line 851, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/odoo/odoo-server/openerp/tools/convert.py", line 938, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
  File "/odoo/odoo-server/openerp/tools/convert.py", line 801, in parse
    self.parse(rec, mode)
  File "/odoo/odoo-server/openerp/tools/convert.py", line 804, in parse
    self._tags[rec.tag](self.cr, rec, de, mode=mode)
  File "/odoo/odoo-server/openerp/tools/convert.py", line 777, in _tag_template
    return self._tag_record(cr, record, data_node)
  File "/odoo/odoo-server/openerp/tools/convert.py", line 708, in _tag_record
    id = self.pool['ir.model.data']._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "/odoo/odoo-server/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/odoo/odoo-server/openerp/addons/base/ir/ir_model.py", line 1142, in _update
    res_id = model_obj.create(cr, uid, values, context=context)
  File "/odoo/odoo-server/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/odoo/odoo-server/openerp/addons/base/ir/ir_ui_view.py", line 351, in create
    context=context)
  File "/odoo/odoo-server/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/odoo/odoo-server/openerp/api.py", line 354, in old_api
    result = method(recs, *args, **kwargs)
  File "/odoo/odoo-server/openerp/models.py", line 4151, in create
    record = self.browse(self._create(old_vals))
  File "/odoo/odoo-server/openerp/api.py", line 248, in wrapper
    return new_api(self, *args, **kwargs)
  File "/odoo/odoo-server/openerp/api.py", line 490, in new_api
    result = method(self._model, cr, uid, *args, **old_kwargs)
  File "/odoo/odoo-server/openerp/models.py", line 4342, in _create
    recs._validate_fields(vals)
  File "/odoo/odoo-server/openerp/api.py", line 248, in wrapper
    return new_api(self, *args, **kwargs)
  File "/odoo/odoo-server/openerp/models.py", line 1271, in _validate_fields
    raise ValidationError('\n'.join(errors))
ParseError: "Invalid view definition

Error details:
Element '<xpath expr="//script[@src='/web/static/src/js/formats.js']">' cannot be located in parent view

Error context:
View `persian_calendar`
[view_id: 853, xml_id: n/a, model: n/a, parent_id: 159]
None" while parsing None:6, near
<data inherit_id="web.assets_backend">

            <xpath expr="//script[@src='/web/static/src/js/formats.js']" position="replace">
                <script type="text/javascript" src="/persian_calendar/static/src/js/formats.js"/>
            </xpath>
        </data>
3
Odoo 8 and 9 uses the same api, if the module is in Api 8 it should work in 9, thing is, if that module uses api 7 (works in 8), it wont work in 9. What you should do is changue the api 7 functions / fields to 8.dccdany
And, to be honest, it may even works with old api. The only thing that can break is, if it inherits from a base module that odoo changed for odoo 9, you may have to change that function.dccdany
@dccdany Then how come this module cannot be installed on Odoo 9? It might be Odoo 7 module, as opposed to the specification. In that case, should I ask another question of how to convert from O7 to O9?orezvani
@dccdany here is the error that I get when installing this module.orezvani
Theres a xml in the module thats searching for a xpath xpression that isnt in the module that it inherits (the one with id "web.assets_backend")dccdany

3 Answers

4
votes

What you are facing is a particular case. A lot of things have changed in the front-end of Odoo 9 (like using less). There are no definite way to upgrade a module from v8 to v9. Here are some recommandations though :

  • use the new API, as the old API is definitely gone in Odoo v10. This will make upgrading to it later a lot easier.
  • a lot of things have changed in the front-end, most of your template/view inheritance will need a refresh. The fastest way is still to try to install it and resolve issues as they arise
  • model logic did not change a lot. The ones who got big revamps are accounting in Odoo 9 and manufacturing in Odoo 10. Most of the logics that you use now will still work

Concerning your issue, it may not be easy. I upgraded a module displaying custom dashboards I created with Highcharts on Odoo 9 and a lot of steps were required to make it work.

1
votes

there is not a tool to convert a module from Odoo 8 to Odoo 9, However the problem is that odoo 8 use the old Api , you can convert the code using the official documentation to see the difference For example in function : In old Api we have the declare cr, uid, ids, context in Arguments, but in the new Api we don't have to do it ;)

0
votes

Steps to convert a module:

  1. Scaffold new module in the version
  2. Copy al .py file and run (chck for errors)
  3. Copyy views and run again (not inherited)
  4. Rewrite inhetied views and check all xpath are present (like this case)
  5. Rewrite permissions