diff --git a/product/Coramy/Extensions/ImportEdiFiles.py b/product/Coramy/Extensions/ImportEdiFiles.py index 50f1e92cd580177892663fdebaddbdd3f17f7baf..59002cab0cc47a1a9767759f5aba2f03502bc2a7 100755 --- a/product/Coramy/Extensions/ImportEdiFiles.py +++ b/product/Coramy/Extensions/ImportEdiFiles.py @@ -64,18 +64,21 @@ def importEdiFile(object=None, file_path=None, delivery_mode=None, incoterm=None file.close() # test the result - if resultTmp == None: + #if resultTmp == None: + get_transaction().commit() + if resultTmp[1] == None: result = result + '\n' + 'Fichier non valide\n' - resultTab += [(0,result)] + resultTab += [(0,result,None)] else: - result = result + '\n' + resultTmp + result = result + '\n' + resultTmp[1] os.remove(file_path) - resultTab += [(1,result)] + #resultTab += [(1,result)] + resultTab += [(1,result,resultTmp[0])] else: result += '\nPas d acces en ecriture\n' - resultTab += [(0,result)] + resultTab += [(0,result,None)] return resultTab @@ -85,13 +88,14 @@ def importEdiFile(object=None, file_path=None, delivery_mode=None, incoterm=None this allows to import many edi files by the same time """ def importEdiFileList(self, REQUEST,file_path=None, delivery_mode=None, incoterm=None, order_type=None, segmentation_strategique=None, travel_duration=None, batch_mode=0): - + result = '' result += '############################################################################## \n' result += 'Tentative d import\n'+ DateTime().strftime("%a, %Y %B %d %H:%M:%S")+'\n' result += '############################################################################## \n' edi_files_number = 0 + uid_list = [] # test the log file if access(log_directory_path, W_OK): @@ -103,20 +107,31 @@ def importEdiFileList(self, REQUEST,file_path=None, delivery_mode=None, incoterm for file_name in files_list: file_path = os.path.join(import_directory_path, file_name) - - tab += importEdiFile(object=self, file_path=file_path, delivery_mode=delivery_mode, incoterm=incoterm, order_type=order_type, segmentation_strategique=segmentation_strategique, travel_duration=travel_duration ) + tab += importEdiFile(object=self, file_path=file_path, delivery_mode=delivery_mode, incoterm=incoterm, order_type=order_type, segmentation_strategique=segmentation_strategique, travel_duration=travel_duration ) - - for comment in tab: + + + for comment in tab: if comment[0]: - edi_files_number += 1 + edi_files_number += 1 result += comment[1] + if comment[2] != None: + uid_list.append(comment[2]) # 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.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() else: @@ -126,5 +141,7 @@ def importEdiFileList(self, REQUEST,file_path=None, delivery_mode=None, incoterm if batch_mode: return result 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+importés.') REQUEST[ 'RESPONSE' ].redirect( redirect_url ) diff --git a/product/Coramy/skins/coramy_trade/SalesOrder_confirmListForm.form b/product/Coramy/skins/coramy_trade/SalesOrder_confirmListForm.form index 0f8f116f299ef407ba1c7afb5860722843090905..ed6d1a912fd3423ab7fc44bdc6d0f2a6331e834b 100755 --- a/product/Coramy/skins/coramy_trade/SalesOrder_confirmListForm.form +++ b/product/Coramy/skins/coramy_trade/SalesOrder_confirmListForm.form @@ -4,7 +4,7 @@ <title>Confirmer les commandes</title> <name>SalesOrder_confirmListForm</name> <action>SalesOrder_confirmList</action> - <enctype>multipart/form-data</enctype> + <enctype></enctype> <method>POST</method> <pt>form_view_dialog</pt> @@ -15,29 +15,19 @@ <field><id>my_start_date</id> <type>DateTimeField</type> <values> - <allow_empty_time type="int">0</allow_empty_time> <alternate_name></alternate_name> - <ampm_time_style type="int">0</ampm_time_style> <css_class></css_class> <date_only type="int">1</date_only> <date_separator>/</date_separator> <default_now type="int">0</default_now> <description></description> - <editable_expression></editable_expression> - <editable_permission></editable_permission> - <editable_role></editable_role> <external_validator></external_validator> <hidden type="int">0</hidden> <input_order>dmy</input_order> <input_style>text</input_style> - <not_viewable type="int">0</not_viewable> - <read_only type="int">0</read_only> <required type="int">0</required> <time_separator>:</time_separator> <title>Date d'expédition confirmée</title> - <viewable_expression></viewable_expression> - <viewable_permission></viewable_permission> - <viewable_role></viewable_role> </values> <tales> </tales> @@ -50,29 +40,19 @@ </field> <field><id>my_stop_date</id> <type>DateTimeField</type> <values> - <allow_empty_time type="int">0</allow_empty_time> <alternate_name></alternate_name> - <ampm_time_style type="int">0</ampm_time_style> <css_class></css_class> <date_only type="int">1</date_only> <date_separator>/</date_separator> <default_now type="int">0</default_now> <description></description> - <editable_expression></editable_expression> - <editable_permission></editable_permission> - <editable_role></editable_role> <external_validator></external_validator> <hidden type="int">0</hidden> <input_order>dmy</input_order> <input_style>text</input_style> - <not_viewable type="int">0</not_viewable> - <read_only type="int">0</read_only> <required type="int">0</required> <time_separator>:</time_separator> <title>Date de livraison confirmée</title> - <viewable_expression></viewable_expression> - <viewable_permission></viewable_permission> - <viewable_role></viewable_role> </values> <tales> </tales> @@ -85,11 +65,5 @@ </field> </fields> </group> - <group> - <title>hidden</title> - <fields> - - </fields> - </group> </groups> </form> \ No newline at end of file diff --git a/product/Coramy/skins/coramy_trade/SalesOrder_importEdi.py b/product/Coramy/skins/coramy_trade/SalesOrder_importEdi.py index 8b3038f8c7be09d0f748e9f3d4fb9866b00dd7ef..292ee10352db8e592a7674f4471745f18726e9e0 100755 --- a/product/Coramy/skins/coramy_trade/SalesOrder_importEdi.py +++ b/product/Coramy/skins/coramy_trade/SalesOrder_importEdi.py @@ -32,7 +32,8 @@ try: alias_table_name = string.split(file_line_list[0].split(':',1)[1])[0] import_script = edi_import_script_dict[alias_table_name] except: - return None + #return None + return (None,None) @@ -89,6 +90,18 @@ def link_with_organisation(code_ean13, link_function, portal_type_name): except IndexError: 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): result = context.item_by_ean13_code_sql_search(organisation_ean = code_ean13, portal_type = 'Set Mapped Value') try: @@ -104,7 +117,8 @@ def modele_search(code_ean13): # dictionnary of those functions, in order to give them to the import script useful_functions = { '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) # and this is the end .... if batch_mode: - return sales_order.getComment() + #return sales_order.getComment() + return (sales_order.getUid(),sales_order.getComment()) else: redirect_url = '%s?%s' % ( item_module.absolute_url()+'/'+my_id+'/'+'view', 'portal_status_message=Commande+Vente+créée.') request[ 'RESPONSE' ].redirect( redirect_url ) diff --git a/product/Coramy/skins/coramy_trade/SalesOrder_importEdiAuchan.py b/product/Coramy/skins/coramy_trade/SalesOrder_importEdiAuchan.py index 20373c5c09514925be6e03ec7c6d60fd4b205e6c..5c9d23092144ecc56e974a471c10484ede75e045 100755 --- a/product/Coramy/skins/coramy_trade/SalesOrder_importEdiAuchan.py +++ b/product/Coramy/skins/coramy_trade/SalesOrder_importEdiAuchan.py @@ -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') 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 ): # code EAN inconnu de Coramy, solution temporaire ... diff --git a/product/Coramy/skins/coramy_trade/SalesOrder_importEdiForm.form b/product/Coramy/skins/coramy_trade/SalesOrder_importEdiForm.form index c5d45bf1c51632f9e914700125057d489bfb8e5d..893682aab5522c122b1b905de7582bf5dbc65609 100755 --- a/product/Coramy/skins/coramy_trade/SalesOrder_importEdiForm.form +++ b/product/Coramy/skins/coramy_trade/SalesOrder_importEdiForm.form @@ -94,12 +94,12 @@ <editable_role></editable_role> <external_validator></external_validator> <extra></extra> - <first_item>False</first_item> - <hidden>False</hidden> + <first_item type="int">0</first_item> + <hidden type="int">0</hidden> <items type="list">[]</items> <not_viewable type="int">0</not_viewable> <read_only type="int">0</read_only> - <required>False</required> + <required type="int">0</required> <size type="int">1</size> <title>Type de commande</title> <unicode type="int">0</unicode> @@ -164,8 +164,8 @@ <end></end> <external_validator></external_validator> <extra></extra> - <hidden>False</hidden> - <required>False</required> + <hidden type="int">0</hidden> + <required type="int">0</required> <start></start> <title>Durée de l'expédition (jours)</title> </values> diff --git a/product/Coramy/skins/coramy_trade/item_by_ean13_code_sql_search.zsql b/product/Coramy/skins/coramy_trade/item_by_ean13_code_sql_search.zsql index dba5f82158ad74f72facf165057f2d06c1a53374..b168ce38b3ba96dbf52b1b952024edceaaef6096 100755 --- a/product/Coramy/skins/coramy_trade/item_by_ean13_code_sql_search.zsql +++ b/product/Coramy/skins/coramy_trade/item_by_ean13_code_sql_search.zsql @@ -12,6 +12,6 @@ portal_type</params> SELECT DISTINCT id, relative_url, path, Description FROM catalog -WHERE portal_type REGEXP "<dtml-var portal_type>" -AND ean13_code = organisation_ean +WHERE portal_type = "<dtml-var portal_type>" +AND ean13_code = "<dtml-var organisation_ean>" diff --git a/product/Coramy/skins/coramy_trade/item_by_title_sql_search.zsql b/product/Coramy/skins/coramy_trade/item_by_title_sql_search.zsql index e9fffdd2c46479a64e0b37ed64313bd943c07042..a0ac20f2084b9ca5ce8c67fc920c673486a3d01e 100755 --- a/product/Coramy/skins/coramy_trade/item_by_title_sql_search.zsql +++ b/product/Coramy/skins/coramy_trade/item_by_title_sql_search.zsql @@ -4,8 +4,8 @@ connection_id:MySQL max_rows:1000 max_cache:100 cache_time:0 -class_name:ZSQLBrain -class_file:zsqlbrain.py +class_name: +class_file: </dtml-comment> <params>title portal_type</params> @@ -13,4 +13,4 @@ SELECT DISTINCT id, relative_url, path, Description FROM catalog WHERE portal_type = "<dtml-var portal_type>" -AND Title REGEXP "<dtml-var title>" +AND Title REGEXP "<dtml-var title>" \ No newline at end of file