转:odoo10模块升级到odoo12遇到的一个坑(raise ValidationError(_('Invalid view %s definition in %s') % (view.name, view.arch_fs)))

odoo10模块升级到odoo12遇到的一个坑(raise ValidationError(_('Invalid view %s definition in %s') % (view.name, view.arch_fs)))


今天在把一个odoo10模块在odoo12中安装时,总是报错:

 

Traceback (most recent call last):

  File "F:\Odoo\GOdoo12_Ent\source\odoo\http.py", line 653, in _handle_exception

    return super(JsonRequest, self)._handle_exception(exception)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\http.py", line 312, in _handle_exception

    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

  File "F:\Odoo\GOdoo12_Ent\source\odoo\tools\pycompat.py", line 87, in reraise

    raise value

  File "F:\Odoo\GOdoo12_Ent\source\odoo\http.py", line 695, in dispatch

    result = self._call_function(**self.params)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\http.py", line 344, in _call_function

    return checked_call(self.db, *args, **kwargs)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\service\model.py", line 97, in wrapper

    return f(dbname, *args, **kwargs)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\http.py", line 337, in checked_call

    result = self.endpoint(*a, **kw)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\http.py", line 938, in __call__

    return self.method(*args, **kw)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\http.py", line 517, in response_wrap

    response = f(*args, **kw)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\addons\web\controllers\main.py", line 966, in call_button

    action = self._call_kw(model, method, args, {})

  File "F:\Odoo\GOdoo12_Ent\source\odoo\addons\web\controllers\main.py", line 954, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\api.py", line 749, in call_kw

    return _call_kw_multi(method, model, args, kwargs)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\api.py", line 736, in _call_kw_multi

    result = method(recs, *args, **kwargs)

  File "<decorator-gen-67>", line 2, in button_immediate_upgrade

  File "F:\Odoo\GOdoo12_Ent\source\odoo\addons\base\models\ir_module.py", line 71, in check_and_log

    return method(self, *args, **kwargs)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\addons\base\models\ir_module.py", line 596, in button_immediate_upgrade

    return self._button_immediate_function(type(self).button_upgrade)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\addons\base\models\ir_module.py", line 535, in _button_immediate_function

    modules.registry.Registry.new(self._cr.dbname, update_module=True)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\modules\registry.py", line 86, in new

    odoo.modules.load_modules(registry._db, force_demo, status, update_module)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\modules\loading.py", line 422, in load_modules

    force, status, report, loaded_modules, update_module, models_to_check)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\modules\loading.py", line 318, in load_marked_modules

    perform_checks=perform_checks, models_to_check=models_to_check

  File "F:\Odoo\GOdoo12_Ent\source\odoo\modules\loading.py", line 224, in load_module_graph

    load_data(cr, idref, mode, kind='data', package=package, report=report)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\modules\loading.py", line 68, in load_data

    tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\tools\convert.py", line 792, in convert_file

    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\tools\convert.py", line 853, in convert_xml_import

    obj.parse(doc.getroot(), mode=mode)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\tools\convert.py", line 745, in parse

    self.parse(rec, mode)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\tools\convert.py", line 754, in parse

    exc_info[2]

  File "F:\Odoo\GOdoo12_Ent\source\odoo\tools\pycompat.py", line 86, in reraise

    raise value.with_traceback(tb)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\tools\convert.py", line 748, in parse

    self._tags[rec.tag](rec, de, mode=mode)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\tools\convert.py", line 653, in _tag_record

    record = model.with_context(rec_context)._load_records([data], self.mode == 'update')

  File "F:\Odoo\GOdoo12_Ent\source\odoo\models.py", line 3776, in _load_records

    data['record'].write(data['values'])

  File "F:\Odoo\GOdoo12_Ent\source\odoo\addons\base\models\ir_ui_view.py", line 434, in write

    return super(View, self).write(self._compute_defaults(vals))

  File "F:\Odoo\GOdoo12_Ent\source\odoo\models.py", line 3294, in write

    fields[0].determine_inverse(records)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\fields.py", line 1104, in determine_inverse

    getattr(records, self.inverse)()

  File "F:\Odoo\GOdoo12_Ent\source\odoo\addons\base\models\ir_ui_view.py", line 268, in _inverse_arch

    view.write(data)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\addons\base\models\ir_ui_view.py", line 434, in write

    return super(View, self).write(self._compute_defaults(vals))

  File "F:\Odoo\GOdoo12_Ent\source\odoo\models.py", line 3257, in write

    self._write(store_vals)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\models.py", line 3401, in _write

    self._validate_fields(vals)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\models.py", line 1100, in _validate_fields

    check(self)

  File "F:\Odoo\GOdoo12_Ent\source\odoo\addons\base\models\ir_ui_view.py", line 353, in _check_xml

    raise ValidationError(_('Invalid view %s definition in %s') % (view.name, view.arch_fs))

odoo.tools.convert.ParseError: "Invalid view qunar.report.stock.line.search definition in False

None" while parsing file:/f:/odoo/godoo12_ent/myaddons/qunar_stockreport/views/qunar_report_stock_view.xml:102, near

<record id="qunar_report_stock_search_view" model="ir.ui.view">

<field name="name">qunar.report.stock.line.search</field>

<field name="model">qunar.report.stock.line</field>

<field name="arch" type="xml">

<search string="Search Report">

<field name="product_id" string="Product" filter_domain="['|',('product_id.default_code','ilike',self),('product_id.name','ilike',self)]"/>

<filter string="None Zero" domain="['|','|',('last_remainder','!=',0),('in_stock_qty','!=',0),'|','|',('out_stock_qty','!=',0),('inventory_short_qty','!=',0),('inventory_over_qty','!=',0)]"/>

<group expand="0" string="Group by...">

<filter string="Category" domain="[]" context="{'group_by':'product_cate'}"/>

</group>

</search>

</field>

</record>

 

 

单步跟踪到 source\odoo\tools\view_validation.py 文件第20行:

valid_view(arch):
    pred _validators[arch.tag]:
        check = pred(arch)
        check:
            _logger.error(, pred.)
            check == :
            _logger.warning(, pred.)

 

发现是scheama校验错,在日志中打出的错误信息是:

odoo.tools.view_validation: Invalid XML:  Get RNG validator and validate RNG file

经多次检查XML,未发现有明细的错误。最后把视图定义中<search...>[定义内容]</search>

定义内容部分全部删除,然后一行行添加,发现添加到第二行:

1
<filter string="None Zero" domain="['|','|',('last_remainder','!=',0),('in_stock_qty','!=',0),'|','|',('out_stock_qty','!=',0),('inventory_short_qty','!=',0),('inventory_over_qty','!=',0)]"/>

出错,仔细检查发现这一行中没有name属性,尝试增加一个name属性,然后再安装,不再报错。再把第3~5行加上,第4行也增加name属性,再次安装,不再报错。

分析认为是odoo12中对filter节点的name属性改成强制要求,缺少则出错。稍后再去找找scheama文件,确认一下。

 

-----------------------------------------

posted @ 2018-10-29 15:17  勇&进  阅读(3057)  评论(1编辑  收藏  举报