Search code examples
xmlruntime-errorodoohelper

How can i solve this error message in OpenERP or Odoo?


How can solved this error in OpenERP or Odoo ? I'm trying to create an own demo data for a custom module but I don't kno how to do it. I'm using Odoo 12 and the module is account.invoices

Error: Odoo Server Error Traceback (most recent call last):   File "/home/ubuntu/OdooAddons/odoo/odoo/http.py", line 656, in
_handle_exception
    return super(JsonRequest, self)._handle_exception(exception)   File "/home/ubuntu/OdooAddons/odoo/odoo/http.py", line 314, in
_handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])   File "/home/ubuntu/OdooAddons/odoo/odoo/tools/pycompat.py", line 87, in reraise
    raise value   File "/home/ubuntu/OdooAddons/odoo/odoo/http.py", line 698, in dispatch
    result = self._call_function(**self.params)   File "/home/ubuntu/OdooAddons/odoo/odoo/http.py", line 346, in
_call_function
    return checked_call(self.db, *args, **kwargs)   File "/home/ubuntu/OdooAddons/odoo/odoo/service/model.py", line 98, in wrapper
    return f(dbname, *args, **kwargs)   File "/home/ubuntu/OdooAddons/odoo/odoo/http.py", line 339, in checked_call
    result = self.endpoint(*a, **kw)   File "/home/ubuntu/OdooAddons/odoo/odoo/http.py", line 941, in __call__
    return self.method(*args, **kw)   File "/home/ubuntu/OdooAddons/odoo/odoo/http.py", line 519, in response_wrap
    response = f(*args, **kw)   File "/home/ubuntu/OdooAddons/odoo/addons/web/controllers/main.py", line 967, in call_button
    action = self._call_kw(model, method, args, {})   File "/home/ubuntu/OdooAddons/odoo/addons/web/controllers/main.py", line 955, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)   File "/home/ubuntu/OdooAddons/odoo/odoo/api.py", line 759, in call_kw
    return _call_kw_multi(method, model, args, kwargs)   File "/home/ubuntu/OdooAddons/odoo/odoo/api.py", line 746, in
_call_kw_multi
    result = method(recs, *args, **kwargs)   File "<decorator-gen-67>", line 2, in button_immediate_upgrade   File "/home/ubuntu/OdooAddons/odoo/odoo/addons/base/models/ir_module.py", line 74, in check_and_log
    return method(self, *args, **kwargs)   File "/home/ubuntu/OdooAddons/odoo/odoo/addons/base/models/ir_module.py", line 627, in button_immediate_upgrade
    return self._button_immediate_function(type(self).button_upgrade)   File "/home/ubuntu/OdooAddons/odoo/odoo/addons/base/models/ir_module.py", line 561, in _button_immediate_function
    modules.registry.Registry.new(self._cr.dbname, update_module=True)   File "/home/ubuntu/OdooAddons/odoo/odoo/modules/registry.py", line 86, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)   File "/home/ubuntu/OdooAddons/odoo/odoo/modules/loading.py", line 417, in load_modules
    force, status, report, loaded_modules, update_module, models_to_check)   File "/home/ubuntu/OdooAddons/odoo/odoo/modules/loading.py", line 313, in load_marked_modules
    perform_checks=perform_checks, models_to_check=models_to_check   File "/home/ubuntu/OdooAddons/odoo/odoo/modules/loading.py", line 222, in load_module_graph
    load_data(cr, idref, mode, kind='data', package=package, report=report)   File "/home/ubuntu/OdooAddons/odoo/odoo/modules/loading.py", line 68, in load_data
    tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)   File "/home/ubuntu/OdooAddons/odoo/odoo/tools/convert.py", line 802, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)   File "/home/ubuntu/OdooAddons/odoo/odoo/tools/convert.py", line 852, in convert_xml_import
    relaxng.assert_(doc)   File "src/lxml/etree.pyx", line 3542, in lxml.etree._Validator.assert_ AssertionError: Element odoo has extra content: data, line 2

And I have this demo data code to create a new Invoice but I don't know how to resolve this error

<odoo>
    <data>
         <record id="emb_invoice_1" model="account.invoice">
            <field name="partner_id" ref="base.res_partner_2"/>
            <field name="user_id" ref="base.user_demo"/>
             <field name="origin">SO001</field>
            <field name="emb_dual_use">True</field>
            <field name="emb_message">True Field transport</field>
            <field name="amount_untaxed_invoice_signed">750.00</field>
            <field name="amount_tax_signed">157.50</field>
            <field name="amount_total_signed">907.50</field>
        </record>
        <record id="emb_invoice_line_ids" model="account.invoice">
            <field name="invoice_line_ids">
            <field name="order_id" ref="emb_invoice_1"/>
            <field name="product_id" ref="product.product">'{[FURN_0096] Customizable Desk (Steel, White)}'</field>
            <field name="name">'PC Assamble + 2GB RAM'</field>
            <field name="account_id">'162'</field>
            <field name="price_unit">'2950.00'</field>
            <field name="origin_country" model="res.country.state">'{Spain}'</field>
            </field>
        </record>
    </data>
</odoo>

THANKS!


Solution

  • In the second data record:

    The declared fields are not present in account.invoice, you need to replace it with correct model name account.invoice.line, remove <field name="invoice_line_ids"> tag and set the value of invoice_id. Use invoice_id instead of order_id.

    The ref attribute must be a valid external id. Find the external id of FURN_0096 and replace the field tag as following (like you did with partner_id and user_id):

    <field name="product_id" ref="the external id">  
    

    You can read in the documentation that if a ref attribute is provided, its value must be a valid external id, which will be looked up and set as the field’s value.

    Mostly for Many2one and Reference fields

    You have also to use the same logic with the two last fields: account_id and origin_country.