Import/export CSV

149 views
Skip to first unread message

Manuel Moura

unread,
Aug 25, 2016, 3:05:05 AM8/25/16
to tryton

Hi. I tried to find an answer for my question but because I did not found it, here is my problem:

I need to import 400 client records to tryton 4.0.3.

1. First of all I made a test export from a record that I already input manually:
Name,Phone,Mobile,E-Mail,Addresses/Street,Addresses/Zip,Addresses/City,VAT Code
Maxxx Mxxxx,,+351XXXXXXXXX,mxx...@gmail.com,"Rua das Fxxxxxxxxx, 112",4XXX-XXX,Braga,PT111222333

2. Based on that export I created an import test csv file:
Name,Phone,Mobile,E-Mail,Addresses/Street,Addresses/Zip,Addresses/City,VAT Code
Teste Name,,+351123456789,teste...@gmail.com,"Rua dos Anzois de Cima, 1234",4700-100,Braga,PT100334223

3. I tried the Auto-Detect button but the result was "error processing the file at field Phone".

I get this error with -l debug
"ERROR:tryton.common.common:Traceback (most recent call last):
  File "/trytond/wsgi.py", line 47, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 59, in rpc
    request, database_name, *request.params)
  File "/trytond/wsgi.py", line 39, in auth_required
    return wrapped(*args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 40, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 201, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/model/modelstorage.py", line 744, in import_data
    assert all(len(x) == len_fields_names for x in data)
AssertionErrorr"

The filed names are/should be different in export/import files?
Do I need to installtrytond-import_csv ( The import CSV module of the Tryton application platform)?

Thanks, in advance, for your help.

Kind regards,

Manuel Moura

Sergi Almacellas Abellana

unread,
Aug 25, 2016, 3:43:47 AM8/25/16
to try...@googlegroups.com
El 25/08/16 a les 08:34, Manuel Moura ha escrit:
> <https://lh3.googleusercontent.com/-BKKnb7v1MO8/V76LcrlQHSI/AAAAAAAAFeI/S4KuR-iaNwAOtZKWQ5KmCOiq2bn_khoyACLcB/s1600/Captura%2Bde%2Becr%25C3%25A3%2Bde%2B2016-08-25%2B07%253A06%253A06.png>
THe problem is that the phone field is a Functional field which has no
setter method, so it's not editable and you should not import this on
the CSV file. Same for Mobile and Email.

You should create contact mechanisms for them.

Hope it helps!

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Manuel Moura

unread,
Aug 25, 2016, 9:30:04 AM8/25/16
to tryton

Thanks for your help, Sergi.

The field detection is automatic, now.
But I receive an error, in the end of importing process, saying that "The field "Value" in the model "Contact Mechanisms" is mandatory"...
If I delete the fields with "Contact Mechanisms/XXXX" the import process runs successfully.

Thanks for your patience.

Kind regards,
Manuel Moura



quinta-feira, 25 de Agosto de 2016 às 08:05:05 UTC+1, Manuel Moura escreveu:

Hi. I tried to find an answer for my question but because I did not found it, here is my problem:

I need to import 400 client records to tryton 4.0.3.

1. First of all I made a test export from a record that I already input manually:
Name,Phone,Mobile,E-Mail,Addresses/Street,Addresses/Zip,Addresses/City,VAT Code
Maxxx Mxxxx,,+351XXXXXXXXX,mxxxxx@gmail.com,"Rua das Fxxxxxxxxx, 112",4XXX-XXX,Braga,PT111222333


2. Based on that export I created an import test csv file:
Name,Phone,Mobile,E-Mail,Addresses/Street,Addresses/Zip,Addresses/City,VAT Code
Teste Name,,+351123456789,teste.ma...@gmail.com,"Rua dos Anzois de Cima, 1234",4700-100,Braga,PT100334223

Sergi Almacellas Abellana

unread,
Aug 25, 2016, 9:34:32 AM8/25/16
to try...@googlegroups.com
El 25/08/16 a les 14:41, Manuel Moura ha escrit:
> <https://lh3.googleusercontent.com/-3_ZJ7iUqbaM/V77mTKNWINI/AAAAAAAAFec/nO-PuWPazFcPdU3aPgp-TA0fgXdk5hPTgCLcB/s1600/Captura%2Bde%2Becr%25C3%25A3%2Bde%2B2016-08-25%2B13%253A33%253A23.png>
>
> Thanks for your help, Sergi.
>
> The field detection is automatic, now.
> But I receive an error, in the end of importing process, saying that
> "The field "Value" in the model "Contact Mechanisms" is mandatory"...
> If I delete the fields with "Contact Mechanisms/XXXX" the import process
> runs successfully.

Because you have to specify the type and the value for the contact
mechanism. If you want to import the email, the type will be always
'email' and the value should be the email address you want to import.

Hope it helps!

P.S: Don't top post on this mailing list. See
https://groups.tryton.org/netiquette

Manuel Moura

unread,
Aug 25, 2016, 1:45:04 PM8/25/16
to tryton
Hi, again.
Sorry, but no success.
Please, tell me, in the example bellow, the correct solution.
Where and how to put in the file xxx.csv the type 'email'?

Example for only one record to import:
Name,Contact Mechanisms/E-mail
Bla Bla Lda,y...@blabla.pt

Thanks.
Manuel Moura
 

Luciano Rossi

unread,
Aug 25, 2016, 3:06:22 PM8/25/16
to try...@googlegroups.com
El 25/08/16 a las 14:21, Manuel Moura escribió:
> Hi, again.
> Sorry, but no success.
> Please, tell me, in the example bellow, the correct solution.
> Where and how to put in the file xxx.csv the type 'email'?
>
> Example for only one record to import:
> Name,Contact Mechanisms/E-mail
> Bla Bla Lda,y...@blabla.pt

Hi! Try something like this:

"""
name,contact_mechanisms/value,contact_mechanisms/type
Bla bla lda,y...@blabla.pt,email
"""

Cheers,
--
Luciano Rossi - lu...@gcoop.coop
http://gcoop.coop | Cooperativa de Software Libre
Julián Alvarez 958 CABA C1414DRT +54 11 4771-0055

Manuel Moura

unread,
Aug 25, 2016, 4:50:05 PM8/25/16
to tryton
quinta-feira, 25 de Agosto de 2016 às 20:06:22 UTC+1, Luciano Rossi escreveu:
El 25/08/16 a las 14:21, Manuel Moura escribió:
> Hi, again.
> Sorry, but no success.
> Please, tell me, in the example bellow, the correct solution.
> Where and how to put in the file xxx.csv the type 'email'?
>
> Example for only one record to import:
> Name,Contact Mechanisms/E-mail
> Bla Bla Lda,y...@blabla.pt

Hi! Try something like this:

"""
name,contact_mechanisms/value,contact_mechanisms/type
Bla bla lda,y...@blabla.pt,email
"""


Bingo!
Works great.
Thanks, Luciano.

Adrian Herrera Montenegro

unread,
Dec 4, 2017, 4:35:07 AM12/4/17
to tryton
El jueves, 25 de agosto de 2016, 8:30:04 (UTC-5), Manuel Moura escribió:
> Thanks for your help, Sergi.
>
> The field detection is automatic, now.

How did you fix the automatic field detection?

> But I receive an error, in the end of importing process, saying that "The field "Value" in the model "Contact Mechanisms" is mandatory"...
> If I delete the fields with "Contact Mechanisms/XXXX" the import process runs successfully.
>
> Thanks for your patience.
>
> Kind regards,
> Manuel Moura
>
>
> quinta-feira, 25 de Agosto de 2016 às 08:05:05 UTC+1, Manuel Moura escreveu:
>
> Hi. I tried to find an answer for my question but because I did not found it, here is my problem:
>
> I need to import 400 client records to tryton 4.0.3.
>
> 1. First of all I made a test export from a record that I already input manually:
> Name,Phone,Mobile,E-Mail,Addresses/Street,Addresses/Zip,Addresses/City,VAT Code
> Maxxx Mxxxx,,+351XXXXXXXXX,mxx...@gmail.com,"Rua das Fxxxxxxxxx, 112",4XXX-XXX,Braga,PT111222333
>
> 2. Based on that export I created an import test csv file:
> Name,Phone,Mobile,E-Mail,Addresses/Street,Addresses/Zip,Addresses/City,VAT Code
> Teste Name,,+351123456789,teste...@gmail.com,"Rua dos Anzois de Cima, 1234",4700-100,Braga,PT100334223

Sergi Almacellas Abellana

unread,
Dec 7, 2017, 4:29:39 AM12/7/17
to try...@googlegroups.com
El 04/12/17 a les 06:24, Adrian Herrera Montenegro ha escrit:
> El jueves, 25 de agosto de 2016, 8:30:04 (UTC-5), Manuel Moura escribió:
>> Thanks for your help, Sergi.
>>
>> The field detection is automatic, now.
> How did you fix the automatic field detection?
>
Sorry but I don't understand what do you want to fix.
Reply all
Reply to author
Forward
0 new messages