Best Practice for data importation

Hi all,

Which is the best practise for import data.

For a demo, i would like to import article, party, customer, etc.

Thanks in advance.

Johan

1 Like

I’d say that the best way is to create a custom trytond or proteus script. Proteus is a little bit simpler but slower so if you want to load a lot of data better go the trytond way.

Both alternatives will ensure data is checked against business logic so it is much better than direct database loads.

1 Like

You can find an example of proteus script here: tryton-tools: f7c83f70489f tryton_demo.py
For trytond usage, the future console could simplify this usage as you will be able to pipe script into it: Issue 8126: Add console - Tryton issue tracker

Thanks :slight_smile:

I’ll try it next week.
it’s recommended to import only dictionnary like party, customer, or we can import order, delivery invoice, payement, accounting ?

It’s only for not rewrite manually documents for a beginning.?

Thanks in advance

Johan

You can import referential and operational records. But for operational, it is often more complex because they have workflows which often creates other records. Those created records may not match exactly your history.

proteus is also used for testing purpose.
And it happens that proteus is also used to automate some flow like importing bank statement etc.

Is this how you created the “Dunder Mifflin” demo data? Looks like it, at first glance. If so, I may change this script to read Excel-exported files from QuickBooks (customers, vendors, products, etc), loop through the rows, and import them into Tryton–dream come true!

Thanks a lot,
Sean McCarthy
IJACK Technologies Inc

Hello, what is the status of this issue? - Is there an easy way of importing CSV (or ods if you like) files now into tryton?
Cheers,
Wolf

Yes, tryton allows to export and also import any model using a CSV file from the standard user interface. If you export a CSV file with headers it can be filled and used for import. The client has the option to read the headers and detect the fields to import.

Altought this will work for plain data I recomend using a script to import data from order systems as it allows to import all the relational data without duplication.

This sounds good. But how can I do that? - Is there any description available?

This is explained on the Toolbar section of the client usages part of our documentation

Hi,
I’m writing a script that should do this kind of thing:

  1. Initialize the base in French
  2. Load the necessary modules
  3. Create the company and the third party that goes with it
  4. Load the French chart of accounts,
  5. Add some accounting accounts (necessary for my client)
  6. Create some products (csv files)
  7. Create some classifications (csv files)
  8. Create some parties (csv files)

The final goal is to generate a complete data set to test developments on real data (known by the client).

For that I started on the Tryton test models that I use to create certain data and to load some CSV files. I chose this method (even if slower) because it will be easier for the client to adapt/modify/add data on this.

I can make these scripts available if someone is interested.

Regards.

1 Like

That would be great!

For those who are interested in proteus script to import data, you can take a look at our script that migrates OpenERP data to Tryton. It probably needs adaptations but it should be a good base to start. You may also want to change the input sources (PostgreSQL queries).

@pokoli

Thanks for your hint. I guess I missed something essential. At the moment, I start tryton with the command sudo docker start tryton-postgres tryton and then log in with my browser and the URL localhost:8000. My belive was that I can get all out of tryton this way.
Now I find the term “tryton client” in the docs. Is there anything the web client cannot do?

At my web client, my toolbar (section “articles”) looks like this:


I cannot find menu items for import or export - are they available at the non-web-client only?

Please apologize my down-to-earth questions…

Cheers,
Wolf

We try to have the same features on both clients.

It is in the menu that you can open by clicking on Artikel dropdown.

Wow, I never saw this menu. Well, that makes things quite a bit easier… (-;

But now: I downloaded an export file as an example, modified it a little, and tried to upload it, but get error messages all the time, no matter which modification I try. What’s wrong with my file?
Test file is here…

Probably the problem is that you exported the Type as String. This is used for selection values to show the user value but for data import you should use the Type field and include the internal value.

If this does not solve the problem please include the error messages you are getting so we can provide a better advice.

There is no guarantee that an export can be imported because there may be constraints like uniqueness, some required fields may be missing, some relational field has non unique value.
So in general the export should not be the base for an importation. The importation file should be constructed by analyzing the data schema. So this make the CSV import mechanism very complicated to use for complex model like product. It is way better to write proteus scripts.

Hi,

I’ve written such a script last year, I can share it. The hard point is that the import process for each model needs different fields depending on the modules you installed. So it’s not straightforward to reuse if your module needs differs.

I would be interested to see your script.

Thanks.