# Importing data from xml to modules

**URL:** https://discuss.tryton.org/t/importing-data-from-xml-to-modules/3653
**Category:** Developer
**Created:** [January 7, 2021, 5:56am UTC](https://discuss.tryton.org/t/importing-data-from-xml-to-modules/3653 "2021-01-07T05:56:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![cdonut](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/c/b3f665/32.png) [@cdonut](https://discuss.tryton.org/u/cdonut)
#### Post date: [January 7, 2021, 5:56am UTC](https://discuss.tryton.org/t/importing-data-from-xml-to-modules/3653/1 "2021-01-07T05:56:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dotbit](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dotbit/32/2093_2.png) [@dotbit](https://discuss.tryton.org/u/dotbit)
#### Post date: [January 7, 2021, 6:06am UTC](https://discuss.tryton.org/t/importing-data-from-xml-to-modules/3653/2 "2021-01-07T06:06:35Z")

</div>

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:

```auto
    __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

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

```

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

---

<div class="post-metadata">

### Author: ![cdonut](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/c/b3f665/32.png) [@cdonut](https://discuss.tryton.org/u/cdonut)
#### Post date: [January 7, 2021, 6:25am UTC](https://discuss.tryton.org/t/importing-data-from-xml-to-modules/3653/3 "2021-01-07T06:25:43Z")

</div>

Hi thanks for the reply Josef!

> [@](#):
>
> 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?

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

> [@](#):
>
> I see you have
> 
> ```auto
> <data noupdate="1" skiptest="1">
> 
> ```
> 
> Maybe try without the attributes?

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

> [@](#):
>
> How are you trying to create the records? Perhaps by “updating” the module?

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

---

<div class="post-metadata">

### Author: ![dotbit](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dotbit/32/2093_2.png) [@dotbit](https://discuss.tryton.org/u/dotbit)
#### Post date: [January 7, 2021, 6:33am UTC](https://discuss.tryton.org/t/importing-data-from-xml-to-modules/3653/4 "2021-01-07T06:33:25Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [January 7, 2021, 8:16am UTC](https://discuss.tryton.org/t/importing-data-from-xml-to-modules/3653/5 "2021-01-07T08:16:20Z")

</div>

Is your field “code\_name” Char or Numeric ?

In case of Numeric field you should use:

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

```

---

<div class="post-metadata">

### Author: ![cdonut](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/c/b3f665/32.png) [@cdonut](https://discuss.tryton.org/u/cdonut)
#### Post date: [January 7, 2021, 9:54am UTC](https://discuss.tryton.org/t/importing-data-from-xml-to-modules/3653/6 "2021-01-07T09:54:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![cdonut](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/c/b3f665/32.png) [@cdonut](https://discuss.tryton.org/u/cdonut)
#### Post date: [January 7, 2021, 9:55am UTC](https://discuss.tryton.org/t/importing-data-from-xml-to-modules/3653/7 "2021-01-07T09:55:17Z")

</div>

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!
