Importing data from xml to modules

How do I import data from a xml file and link it to the fields in my module? The xml file is currently in the same directory as my module and have the following code

<?xml version="1.0" encoding="UTF-8"?>
 <tryton>
  <data noupdate="1" skiptest="1">
   <record model="module.directory" id="code_123">
   <field name="code_name">123</field>
   <field name="code_description">Description</field>
   <field name="code_table">Table number</field>
   </record>
.
.
.
.
  </data>
 </tryton>

The fields are ‘code_name’, ‘code_description’ and ‘code_table’.

I suspect that you are using the wrong model name.

For example for party module the main model name is party.party because of the following python code:

    __name__ = 'party.party'

Not because of the directory or the module name.

Are you sure your model is called module.directory?

Perhaps if you give more specific data I can give a more specific answer.

I see you have

 <data noupdate="1" skiptest="1">

Maybe try without the attributes? How are you trying to create the records? Perhaps by “updating” the module?

Hi thanks for the reply Josef!

The model and field names are just arbitrary names due to my project’s confidentiality.

I did this and I had the error: “ERROR trytond.convert Error while parsing xml file”

The records are just stored as Char values. I tried updating the module but I could not see them being stored in the database.

I am importing data into the database using <data> without attributes.

I suspect you have an error in you xml file which is not shown when you have noupdate="1" skiptest="1" because the file is not being fully parsed, however this is just my hunch.

Is your field “code_name” Char or Numeric ?

In case of Numeric field you should use:

<field name="code_name" eval="123"/>

It might be so, which can be a syntax issue on my part.

The field for “code_name” is Char, but I suspect it may be a syntax issue on my part. Thanks for the input though, Max!