Commit e4b7a311 authored by Jean-Paul Smets's avatar Jean-Paul Smets

edi improvements


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@300 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b6faeaec
...@@ -64,18 +64,21 @@ def importEdiFile(object=None, file_path=None, delivery_mode=None, incoterm=None ...@@ -64,18 +64,21 @@ def importEdiFile(object=None, file_path=None, delivery_mode=None, incoterm=None
file.close() file.close()
# test the result # test the result
if resultTmp == None: #if resultTmp == None:
get_transaction().commit()
if resultTmp[1] == None:
result = result + '\n' + 'Fichier non valide\n' result = result + '\n' + 'Fichier non valide\n'
resultTab += [(0,result)] resultTab += [(0,result,None)]
else: else:
result = result + '\n' + resultTmp result = result + '\n' + resultTmp[1]
os.remove(file_path) os.remove(file_path)
resultTab += [(1,result)] #resultTab += [(1,result)]
resultTab += [(1,result,resultTmp[0])]
else: else:
result += '\nPas d acces en ecriture\n' result += '\nPas d acces en ecriture\n'
resultTab += [(0,result)] resultTab += [(0,result,None)]
return resultTab return resultTab
...@@ -92,6 +95,7 @@ def importEdiFileList(self, REQUEST,file_path=None, delivery_mode=None, incoterm ...@@ -92,6 +95,7 @@ def importEdiFileList(self, REQUEST,file_path=None, delivery_mode=None, incoterm
result += '############################################################################## \n' result += '############################################################################## \n'
edi_files_number = 0 edi_files_number = 0
uid_list = []
# test the log file # test the log file
if access(log_directory_path, W_OK): if access(log_directory_path, W_OK):
...@@ -112,11 +116,22 @@ def importEdiFileList(self, REQUEST,file_path=None, delivery_mode=None, incoterm ...@@ -112,11 +116,22 @@ def importEdiFileList(self, REQUEST,file_path=None, delivery_mode=None, incoterm
if comment[0]: if comment[0]:
edi_files_number += 1 edi_files_number += 1
result += comment[1] result += comment[1]
if comment[2] != None:
uid_list.append(comment[2])
# write the log file # write the log file
log_path = os.path.join(log_directory_path, 'importEdiERP5.log') log_path = os.path.join(log_directory_path, 'importEdiERP5.log') # C'est mal XXX - il y a LOG de Zope, le mail ou solution CMFActivity
# Ce n'est pas compatible avec du multi utilisateur
log_file = open(log_path,'a') log_file = open(log_path,'a')
log_file.write(result) log_file.write(result)
"""
log_file.write('UID:\n')
for uid in uid_list:
if uid == None:
log_file.write('None\n')
else:
log_file.write('%i\n' % uid)
"""
log_file.close() log_file.close()
else: else:
...@@ -126,5 +141,7 @@ def importEdiFileList(self, REQUEST,file_path=None, delivery_mode=None, incoterm ...@@ -126,5 +141,7 @@ def importEdiFileList(self, REQUEST,file_path=None, delivery_mode=None, incoterm
if batch_mode: if batch_mode:
return result return result
else: else:
self.flushActivity(invoke=1)
self.portal_selections.setSelectionToIds('sales_order_selection', uid_list, REQUEST=self.REQUEST)
redirect_url = '%s?%s%i%s' % ( self.absolute_url()+'/'+'view', 'portal_status_message=',edi_files_number ,' Fichiers+EDI+imports.') redirect_url = '%s?%s%i%s' % ( self.absolute_url()+'/'+'view', 'portal_status_message=',edi_files_number ,' Fichiers+EDI+imports.')
REQUEST[ 'RESPONSE' ].redirect( redirect_url ) REQUEST[ 'RESPONSE' ].redirect( redirect_url )
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<title>Confirmer les commandes</title> <title>Confirmer les commandes</title>
<name>SalesOrder_confirmListForm</name> <name>SalesOrder_confirmListForm</name>
<action>SalesOrder_confirmList</action> <action>SalesOrder_confirmList</action>
<enctype>multipart/form-data</enctype> <enctype></enctype>
<method>POST</method> <method>POST</method>
<pt>form_view_dialog</pt> <pt>form_view_dialog</pt>
...@@ -15,29 +15,19 @@ ...@@ -15,29 +15,19 @@
<field><id>my_start_date</id> <type>DateTimeField</type> <field><id>my_start_date</id> <type>DateTimeField</type>
<values> <values>
<allow_empty_time type="int">0</allow_empty_time>
<alternate_name></alternate_name> <alternate_name></alternate_name>
<ampm_time_style type="int">0</ampm_time_style>
<css_class></css_class> <css_class></css_class>
<date_only type="int">1</date_only> <date_only type="int">1</date_only>
<date_separator>/</date_separator> <date_separator>/</date_separator>
<default_now type="int">0</default_now> <default_now type="int">0</default_now>
<description></description> <description></description>
<editable_expression></editable_expression>
<editable_permission></editable_permission>
<editable_role></editable_role>
<external_validator></external_validator> <external_validator></external_validator>
<hidden type="int">0</hidden> <hidden type="int">0</hidden>
<input_order>dmy</input_order> <input_order>dmy</input_order>
<input_style>text</input_style> <input_style>text</input_style>
<not_viewable type="int">0</not_viewable>
<read_only type="int">0</read_only>
<required type="int">0</required> <required type="int">0</required>
<time_separator>:</time_separator> <time_separator>:</time_separator>
<title>Date d'expdition confirme</title> <title>Date d'expdition confirme</title>
<viewable_expression></viewable_expression>
<viewable_permission></viewable_permission>
<viewable_role></viewable_role>
</values> </values>
<tales> <tales>
</tales> </tales>
...@@ -50,29 +40,19 @@ ...@@ -50,29 +40,19 @@
</field> </field>
<field><id>my_stop_date</id> <type>DateTimeField</type> <field><id>my_stop_date</id> <type>DateTimeField</type>
<values> <values>
<allow_empty_time type="int">0</allow_empty_time>
<alternate_name></alternate_name> <alternate_name></alternate_name>
<ampm_time_style type="int">0</ampm_time_style>
<css_class></css_class> <css_class></css_class>
<date_only type="int">1</date_only> <date_only type="int">1</date_only>
<date_separator>/</date_separator> <date_separator>/</date_separator>
<default_now type="int">0</default_now> <default_now type="int">0</default_now>
<description></description> <description></description>
<editable_expression></editable_expression>
<editable_permission></editable_permission>
<editable_role></editable_role>
<external_validator></external_validator> <external_validator></external_validator>
<hidden type="int">0</hidden> <hidden type="int">0</hidden>
<input_order>dmy</input_order> <input_order>dmy</input_order>
<input_style>text</input_style> <input_style>text</input_style>
<not_viewable type="int">0</not_viewable>
<read_only type="int">0</read_only>
<required type="int">0</required> <required type="int">0</required>
<time_separator>:</time_separator> <time_separator>:</time_separator>
<title>Date de livraison confirme</title> <title>Date de livraison confirme</title>
<viewable_expression></viewable_expression>
<viewable_permission></viewable_permission>
<viewable_role></viewable_role>
</values> </values>
<tales> <tales>
</tales> </tales>
...@@ -85,11 +65,5 @@ ...@@ -85,11 +65,5 @@
</field> </field>
</fields> </fields>
</group> </group>
<group>
<title>hidden</title>
<fields>
</fields>
</group>
</groups> </groups>
</form> </form>
\ No newline at end of file
...@@ -32,7 +32,8 @@ try: ...@@ -32,7 +32,8 @@ try:
alias_table_name = string.split(file_line_list[0].split(':',1)[1])[0] alias_table_name = string.split(file_line_list[0].split(':',1)[1])[0]
import_script = edi_import_script_dict[alias_table_name] import_script = edi_import_script_dict[alias_table_name]
except: except:
return None #return None
return (None,None)
...@@ -89,6 +90,18 @@ def link_with_organisation(code_ean13, link_function, portal_type_name): ...@@ -89,6 +90,18 @@ def link_with_organisation(code_ean13, link_function, portal_type_name):
except IndexError: except IndexError:
setLog(sales_order, 'Erreur sur le code EAN d une societe:\n\tCode EAN: ' + code_ean13 + '\n') setLog(sales_order, 'Erreur sur le code EAN d une societe:\n\tCode EAN: ' + code_ean13 + '\n')
def link_with_organisation_group(code_ean13, link_function, portal_type_name):
result = context.item_by_ean13_code_sql_search(organisation_ean = code_ean13, portal_type = portal_type_name)
try:
if len(result) == 1:
link_function( 'group/'+result[0].getObject().getGroup() )
else:
raise IndexError
except IndexError:
setLog(sales_order, 'Erreur sur le code EAN d un groupe:\n\tCode EAN: ' + code_ean13 + '\n')
def modele_search(code_ean13): def modele_search(code_ean13):
result = context.item_by_ean13_code_sql_search(organisation_ean = code_ean13, portal_type = 'Set Mapped Value') result = context.item_by_ean13_code_sql_search(organisation_ean = code_ean13, portal_type = 'Set Mapped Value')
try: try:
...@@ -104,7 +117,8 @@ def modele_search(code_ean13): ...@@ -104,7 +117,8 @@ def modele_search(code_ean13):
# dictionnary of those functions, in order to give them to the import script # dictionnary of those functions, in order to give them to the import script
useful_functions = { useful_functions = {
'modele_search':modele_search, 'modele_search':modele_search,
'link_with_organisation':link_with_organisation 'link_with_organisation':link_with_organisation,
'link_with_organisation_group':link_with_organisation_group
} }
...@@ -262,7 +276,8 @@ sales_order.sales_order_apply_condition(my_id, 1) ...@@ -262,7 +276,8 @@ sales_order.sales_order_apply_condition(my_id, 1)
# and this is the end .... # and this is the end ....
if batch_mode: if batch_mode:
return sales_order.getComment() #return sales_order.getComment()
return (sales_order.getUid(),sales_order.getComment())
else: else:
redirect_url = '%s?%s' % ( item_module.absolute_url()+'/'+my_id+'/'+'view', 'portal_status_message=Commande+Vente+créée.') redirect_url = '%s?%s' % ( item_module.absolute_url()+'/'+my_id+'/'+'view', 'portal_status_message=Commande+Vente+créée.')
request[ 'RESPONSE' ].redirect( redirect_url ) request[ 'RESPONSE' ].redirect( redirect_url )
...@@ -70,7 +70,8 @@ def read_NAD_ACHETEUR(argument, item_sales_order, products_list ): ...@@ -70,7 +70,8 @@ def read_NAD_ACHETEUR(argument, item_sales_order, products_list ):
useful_functions['link_with_organisation'](argument[0], item_sales_order.setDestinationDecision, 'Organisation') useful_functions['link_with_organisation'](argument[0], item_sales_order.setDestinationDecision, 'Organisation')
def read_NAD_FOURNISSEUR(argument, item_sales_order, products_list ): def read_NAD_FOURNISSEUR(argument, item_sales_order, products_list ):
useful_functions['link_with_organisation'](argument[0], item_sales_order.setSourceSection, 'Organisation') #useful_functions['link_with_organisationGroup'](argument[0], item_sales_order.setSourceSection, 'Organisation')
useful_functions['link_with_organisation_group'](argument[0], item_sales_order.setSourceSection, 'Organisation')
def read_NAD_LIEU_LIVRAISON(argument, item_sales_order, products_list ): def read_NAD_LIEU_LIVRAISON(argument, item_sales_order, products_list ):
# code EAN inconnu de Coramy, solution temporaire ... # code EAN inconnu de Coramy, solution temporaire ...
......
...@@ -94,12 +94,12 @@ ...@@ -94,12 +94,12 @@
<editable_role></editable_role> <editable_role></editable_role>
<external_validator></external_validator> <external_validator></external_validator>
<extra></extra> <extra></extra>
<first_item>False</first_item> <first_item type="int">0</first_item>
<hidden>False</hidden> <hidden type="int">0</hidden>
<items type="list">[]</items> <items type="list">[]</items>
<not_viewable type="int">0</not_viewable> <not_viewable type="int">0</not_viewable>
<read_only type="int">0</read_only> <read_only type="int">0</read_only>
<required>False</required> <required type="int">0</required>
<size type="int">1</size> <size type="int">1</size>
<title>Type de commande</title> <title>Type de commande</title>
<unicode type="int">0</unicode> <unicode type="int">0</unicode>
...@@ -164,8 +164,8 @@ ...@@ -164,8 +164,8 @@
<end></end> <end></end>
<external_validator></external_validator> <external_validator></external_validator>
<extra></extra> <extra></extra>
<hidden>False</hidden> <hidden type="int">0</hidden>
<required>False</required> <required type="int">0</required>
<start></start> <start></start>
<title>Dure de l'expdition (jours)</title> <title>Dure de l'expdition (jours)</title>
</values> </values>
......
...@@ -12,6 +12,6 @@ portal_type</params> ...@@ -12,6 +12,6 @@ portal_type</params>
SELECT DISTINCT id, relative_url, path, Description SELECT DISTINCT id, relative_url, path, Description
FROM catalog FROM catalog
WHERE portal_type REGEXP "<dtml-var portal_type>" WHERE portal_type = "<dtml-var portal_type>"
AND ean13_code = organisation_ean AND ean13_code = "<dtml-var organisation_ean>"
...@@ -4,8 +4,8 @@ connection_id:MySQL ...@@ -4,8 +4,8 @@ connection_id:MySQL
max_rows:1000 max_rows:1000
max_cache:100 max_cache:100
cache_time:0 cache_time:0
class_name:ZSQLBrain class_name:
class_file:zsqlbrain.py class_file:
</dtml-comment> </dtml-comment>
<params>title <params>title
portal_type</params> portal_type</params>
......
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