Commit 168120b4 authored by Thierry's avatar Thierry

first version


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@72 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b1e29d6e
......@@ -8,12 +8,13 @@
##title=
##
# import des lieux fonctions depuis Cognis
# format de fichier attendu
# id, code tissu Cognis, coloris, no fournisseur, qt, laize, no bain, emplacement, commentaires
# format de fichier attendu :
# Organigramme, Role, Metier, Fonction, Raison sociale, Adresse, CodePostal, Ville
# Ville, Pays, Code Ean, Code TVA, Code compta, Tl, Fax, email
request = context.REQUEST
file_line_list = import_file.readlines()
item_module = context.getPortalObject().organisation
organisation_module = context.getPortalObject().organisation
for file_line in file_line_list :
sub_line_list = file_line.split('\r')
......@@ -23,64 +24,146 @@ for file_line in file_line_list :
# create a new item
line_item_list = sub_line.split('\t')
# recup Id
# gnration Id
my_id = str(organisation_module.generateNewId())
# recup categorie Organigramme
if len(line_item_list) > 0 :
my_id = line_item_list[0]
my_organigramme = line_item_list[0]
else :
my_organigramme = None
# recup catgorie Role
if len(line_item_list) > 1 :
my_role = line_item_list[1]
else :
my_id = str(item_module .generateNewId())
my_role = None
# recup reference_fournisseur
# recup categorie Mtier
if len(line_item_list) > 2 :
my_metier = line_item_list[2]
else :
my_metier = None
# recup categorie Fonction
if len(line_item_list) > 3 :
my_source_reference = line_item_list[3]
my_fonction = line_item_list[3]
else :
my_source_reference = None
my_fonction = None
# recup quantit
# recup raison sociale
if len(line_item_list) > 4 :
my_quantity = float(line_item_list[4].replace(',','.'))
my_name = line_item_list[4]
else :
my_quantity = None
my_name = None
# recup laize utile
# recup Adresse
if len(line_item_list) > 5 :
my_laize_utile = float(line_item_list[5].replace(',','.'))
my_street1 = line_item_list[5]
else :
my_laize_utile = None
# recup no bain teinture
my_street1 = None
if len(line_item_list) > 6 :
my_bain_teinture = line_item_list[6]
my_street2 = line_item_list[6]
else :
my_bain_teinture = None
# recup emplacement
my_street2 = None
if len(line_item_list) > 7 :
my_location = line_item_list[7]
my_street3 = line_item_list[7]
else :
my_location = None
my_street3 = None
# recup commentaires
# recup Code Postal
if len(line_item_list) > 8 :
my_comment = 'ancien code : '+line_item_list[1]+' '+line_item_list[2]+'\r'+''.join(line_item_list[7:])
my_cp = line_item_list[8]
else :
my_cp = None
# recup Ville
if len(line_item_list) > 9 :
my_city = line_item_list[9]
else :
my_city = None
# recup catgorie Pays
if len(line_item_list) > 10 :
if line_item_list[10] == "France" :
my_country = "Europe/Nord/France"
else :
my_country = None
else :
my_country = None
# recup Code EAN
if len(line_item_list) > 11 :
my_ean_code = line_item_list[11]
else :
my_comment = None
my_ean_code = None
# print my_id, my_source_reference, my_quantity, my_laize_utile, my_location
context.portal_types.constructContent(type_name = 'Piece Tissu',
container = item_module,
# recup Code TVA
if len(line_item_list) > 12 :
my_tva_code = line_item_list[12]
else :
my_tva_code = None
# recup Code comptable
if len(line_item_list) > 13 :
my_compta_code = line_item_list[13]
else :
my_compta_code = None
# recup Tlphone
if len(line_item_list) > 14 :
my_tel = line_item_list[14]
else :
my_tel = None
# recup Fax
if len(line_item_list) > 15 :
my_fax = line_item_list[15]
else :
my_fax = None
# recup Email
if len(line_item_list) > 16 :
my_email = line_item_list[16]
else :
my_email = None
my_address = ''
if my_street1 != '' :
my_address += my_street1
if my_street2 != '' :
my_address += '\n'+my_street2
if my_street3 != '' :
my_address += '\n'+my_street3
# print my_id,my_name,my_address,my_tel,my_fax,my_email,my_role,my_organigramme,my_fonction,my_metier,my_country,my_city,my_cp,my_name,my_ean_code,my_tva_code,my_compta_code
# print len(line_item_list), len(file_line_list)
context.portal_types.constructContent(type_name = 'Organisation',
container = organisation_module,
id = my_id,
source_reference = my_source_reference,
quantity = my_quantity,
laize_utile = my_laize_utile,
bain_teinture = my_bain_teinture,
location = my_location,
comment = my_comment )
item_module[my_id].flushActivity(invoke=1)
#return printed
redirect_url = '%s?%s' % ( item_module.absolute_url()
, 'portal_status_message=%s+organisation+cres.' % len(sub_line_list)
title = my_name,
default_address_street_address = my_address,
default_telephone_text = my_tel,
default_fax_text = my_fax,
default_email_text = my_email,
role = my_role,
group = my_organigramme,
function = my_fonction,
activity = my_metier,
default_address_region = my_country,
default_address_city = my_city,
default_address_zip_code = my_cp,
corporate_name = my_name,
ean13_code = my_ean_code,
eu_vat_code = my_tva_code,
code_comptable = my_compta_code)
organisation_module[my_id].flushActivity(invoke=1)
# return printed
redirect_url = '%s?%s' % ( organisation_module.absolute_url()
, 'portal_status_message=%s+organisations+cres.' % len(sub_line_list)
)
request[ 'RESPONSE' ].redirect( redirect_url )
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment