06/10/2024 - 19h30
parent
204616e847
commit
0d4c96471d
|
@ -1,8 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="05/10/2024 - 12h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="05/10/2024 - 18h30">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/invoice_paiement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/invoice_paiement_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_invoice.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_invoice.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -72,13 +77,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00355" summary="17/07/2024 - 11h30sdf">
|
||||
<created>1721461819238</created>
|
||||
<option name="number" value="00355" />
|
||||
<option name="presentableId" value="LOCAL-00355" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1721461819239</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00356" summary="21/07/2024 - 12h">
|
||||
<created>1721557111552</created>
|
||||
<option name="number" value="00356" />
|
||||
|
@ -415,7 +413,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1728125449141</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="404" />
|
||||
<task id="LOCAL-00404" summary="05/10/2024 - 18h30">
|
||||
<created>1728145402808</created>
|
||||
<option name="number" value="00404" />
|
||||
<option name="presentableId" value="LOCAL-00404" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1728145402808</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="405" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -457,7 +462,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="ss" />
|
||||
<MESSAGE value="ddd" />
|
||||
<MESSAGE value="dddqsd" />
|
||||
<MESSAGE value="dddqsdd" />
|
||||
|
@ -482,6 +486,7 @@
|
|||
<MESSAGE value="sdfsd" />
|
||||
<MESSAGE value="sdfsdsdsd" />
|
||||
<MESSAGE value="05/10/2024 - 12h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="05/10/2024 - 12h" />
|
||||
<MESSAGE value="05/10/2024 - 18h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="05/10/2024 - 18h30" />
|
||||
</component>
|
||||
</project>
|
4335
Log/log_file.log
4335
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -207,6 +207,7 @@ def Add_Invoice_Paiement(diction):
|
|||
Tout est ok, alors on enregistre le paiement
|
||||
"""
|
||||
|
||||
mytoken = diction['token']
|
||||
new_data = diction
|
||||
del diction['token']
|
||||
|
||||
|
@ -255,6 +256,22 @@ def Add_Invoice_Paiement(diction):
|
|||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
"""
|
||||
Ajout l'action dans l'historique
|
||||
"""
|
||||
## Add to log history
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = str(mytoken)
|
||||
history_event_dict['related_collection'] = "partner_invoice_header"
|
||||
history_event_dict['related_collection_recid'] = str(diction['invoice_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Ajout paiement "+str(diction['paiement_amount'])+" - "+str(diction['paiement_mode'])
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
return True, " Le paiement a été correctement crée "
|
||||
|
||||
except Exception as e:
|
||||
|
|
10
main.py
10
main.py
|
@ -6588,7 +6588,15 @@ def Send_Partner_Invoice_By_Email():
|
|||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Send_Partner_Invoice_By_Email payload = ",payload)
|
||||
status, retval = partner_invoice.Send_Partner_Invoice_By_Email(payload)
|
||||
|
||||
file = []
|
||||
tab_files = []
|
||||
if request.method == 'POST':
|
||||
# Create variable for uploaded file
|
||||
for tmp in request.files.getlist("File"):
|
||||
tab_files.append(tmp)
|
||||
|
||||
status, retval = partner_invoice.Send_Partner_Invoice_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ from pymongo import MongoClient
|
|||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, date
|
||||
|
||||
import Session_Formation
|
||||
import invoice_paiement_mgt
|
||||
|
@ -416,6 +416,22 @@ def Invoice_Partner_Order(diction):
|
|||
return True, "WARNING : La facture a été créée avec la réf. "+str(new_invoice_data_header['invoice_header_ref_interne'])+"; mais impossible de créer la e-Facture Sécurisée (1).", str(new_invoice_data_header['invoice_header_ref_interne'])
|
||||
|
||||
|
||||
"""
|
||||
Ajout l'action dans l'historique
|
||||
"""
|
||||
## Add to log history
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = diction['token']
|
||||
history_event_dict['related_collection'] = "partner_invoice_header"
|
||||
history_event_dict['related_collection_recid'] = str(inserted_invoice_id)
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Creation facture"
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
return True, " La commande a été correctement facturée", str(new_invoice_data_header['invoice_header_ref_interne'])
|
||||
|
||||
except Exception as e:
|
||||
|
@ -2434,7 +2450,7 @@ def GerneratePDF_Partner_Invoice(diction):
|
|||
"""
|
||||
Envoie de la facture par email
|
||||
"""
|
||||
def Send_Partner_Invoice_By_Email(diction):
|
||||
def Send_Partner_Invoice_By_Email(tab_files, Folder, diction):
|
||||
try:
|
||||
field_list = ['invoice_id', 'token', ]
|
||||
incom_keys = diction.keys()
|
||||
|
@ -2465,7 +2481,7 @@ def Send_Partner_Invoice_By_Email(diction):
|
|||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
# Verification de la validité de l'order
|
||||
# Verification de la validité de la facture
|
||||
qry = {'_id': ObjectId(str(diction['invoice_id'])), 'valide': '1', 'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
#print(" ### qry = ", qry)
|
||||
|
@ -2800,12 +2816,32 @@ def Send_Partner_Invoice_By_Email(diction):
|
|||
3]) + " - Aucune ligne de détail pour cette facture ")
|
||||
return False, " Aucune ligne de détail pour cette facture "
|
||||
|
||||
# Sauvegarde des fichiers joints depuis le front
|
||||
tab_saved_file_full_path = []
|
||||
for file in tab_files:
|
||||
status, saved_file_full_path = mycommon.Upload_Save_PDF_IMG_File(file, Folder)
|
||||
if (status is False):
|
||||
return status, saved_file_full_path
|
||||
|
||||
#print(" ### Order_header_lines_data = ", Order_header_lines_data)
|
||||
tab_saved_file_full_path.append(saved_file_full_path)
|
||||
|
||||
|
||||
# Traitement de l'eventuel fichier joint
|
||||
tab_files_to_attache_to_mail = []
|
||||
for saved_file in tab_saved_file_full_path:
|
||||
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
|
||||
file_to_attache_to_mail.set_payload(open(saved_file, "rb").read())
|
||||
|
||||
encoders.encode_base64(file_to_attache_to_mail)
|
||||
file_to_attache_to_mail.add_header('Content-Disposition',
|
||||
'attachment; filename="{0}"'.format(os.path.basename(saved_file)))
|
||||
|
||||
new_node = {"attached_file": file_to_attache_to_mail}
|
||||
tab_files_to_attache_to_mail.append(new_node)
|
||||
|
||||
print(" ## tab_files_to_attache_to_mail 01 = ", tab_files_to_attache_to_mail)
|
||||
|
||||
|
||||
contenu_doc_Template = jinja2.Template(str(partner_document_INVOICE_data['contenu_doc']))
|
||||
|
||||
# Recuperation des données du partenaire associé à l'utilisateur connecté
|
||||
local_status, local_retval = mycommon.Get_Connected_User_Partner_Data_From_RecID(my_partner['recid'])
|
||||
|
@ -2815,42 +2851,7 @@ def Send_Partner_Invoice_By_Email(diction):
|
|||
|
||||
local_company_data = local_retval
|
||||
|
||||
"""
|
||||
# Recuperation des données de la société
|
||||
company_data = {}
|
||||
|
||||
company_liste_champ = ['nom', 'email', 'telephone', 'num_nda', 'website', 'adr_street', 'adr_zip', 'adr_city',
|
||||
'adr_country']
|
||||
for champ in company_liste_champ:
|
||||
if (champ in local_company_data):
|
||||
new_champ_name = "societe_" + str(champ)
|
||||
new_field = {new_champ_name: str(local_company_data[champ])}
|
||||
company_data.update(new_field)
|
||||
else:
|
||||
new_champ_name = "societe_" + str(champ)
|
||||
new_field = {new_champ_name: ""}
|
||||
company_data.update(new_field)
|
||||
|
||||
# Recuperation du logo et du cachet de la société si il y en a
|
||||
local_part_status, local_part_imgs = partners.getRecodedParnterImage_from_front(
|
||||
{'token': str(diction['token'])})
|
||||
if (local_part_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " WARNING : Impossible de récuperer le logo et le cachet du partenaire ")
|
||||
new_field_logo = {'societe_logo': ''}
|
||||
new_field_cachet = {'societe_cachet': ''}
|
||||
company_data.update(new_field_logo)
|
||||
company_data.update(new_field_cachet)
|
||||
else:
|
||||
|
||||
local_JSON = ast.literal_eval(local_part_imgs[0])
|
||||
|
||||
new_field_logo = {'societe_logo': "data:image/png;base64," + local_JSON['logo_img']}
|
||||
new_field_cachet = {'societe_cachet': "data:image/png;base64," + local_JSON['cachet_img']}
|
||||
company_data.update(new_field_logo)
|
||||
company_data.update(new_field_cachet)
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
Recuperation du dictionnaire des info
|
||||
|
@ -2876,12 +2877,144 @@ def Send_Partner_Invoice_By_Email(diction):
|
|||
"params": convention_dictionnary_data,
|
||||
}
|
||||
|
||||
body = {
|
||||
"params": convention_dictionnary_data,
|
||||
}
|
||||
|
||||
|
||||
convention_dictionnary_data['order_header'] = Order_header_data
|
||||
convention_dictionnary_data['order_lines'] = Order_header_lines_data
|
||||
|
||||
print(" ############ convention_dictionnary_data = ", convention_dictionnary_data)
|
||||
#print(" ############ convention_dictionnary_data = ", convention_dictionnary_data)
|
||||
|
||||
# Recuperation de la version PDF de la facture déjà enregistrée
|
||||
Invoice_header_data = MYSY_GV.dbname['partner_invoice_header'].find_one(
|
||||
{'_id': ObjectId(str(diction['invoice_id'])),
|
||||
'valide': '1', 'locked': '0',
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])})
|
||||
|
||||
# Verifier s'il s'agit d'un document à envoyer avec une version de pièce jointe.
|
||||
if ("joint_pdf" in partner_document_INVOICE_data.keys() and str(
|
||||
partner_document_INVOICE_data['joint_pdf']) == "1"):
|
||||
|
||||
# Si on a un document sécurisé associé, alors on va le chercher, si non on le crée à la volée
|
||||
if ("e_document_signe_id" in Invoice_header_data.keys() and Invoice_header_data['e_document_signe_id']):
|
||||
# On retourne la e_Invoice securisée
|
||||
|
||||
print(" #### RECUPERATION DU FICHIER SECURISE ")
|
||||
qry = {'_id': ObjectId(str(Invoice_header_data['e_document_signe_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'statut': '1',
|
||||
'related_collection': 'partner_invoice_header',
|
||||
'related_collection_id': str(Invoice_header_data['_id']),
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
print(" qry = ", qry)
|
||||
e_Invoice_Secure_Data = MYSY_GV.dbname['e_document_signe'].find_one(
|
||||
{'_id': ObjectId(str(Invoice_header_data['e_document_signe_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'statut': '1',
|
||||
'related_collection': 'partner_invoice_header',
|
||||
'related_collection_id': str(Order_header_data['_id']),
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (e_Invoice_Secure_Data is None):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " Le document sécurisé associé à la facture est invalide 'e_document_signe_id' = " + str(
|
||||
Order_header_data['e_document_signe_id']))
|
||||
|
||||
return False, " Le document sécurisé associé à la facture est invalide "
|
||||
|
||||
orig_file_name = "Partner_Invoice_" + str(Invoice_header_data['invoice_header_ref_interne']) + ".pdf"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
||||
|
||||
# open output file for writing (truncated binary)
|
||||
with open(outputFilename, 'w+b') as resultFile:
|
||||
encoded = base64.b64encode(e_Invoice_Secure_Data['document_data_signed'])
|
||||
decode_data = e_Invoice_Secure_Data['document_data_signed'].decode()
|
||||
bytes = base64.b64decode(decode_data, validate=True)
|
||||
resultFile.write(bytes)
|
||||
|
||||
# close output file
|
||||
resultFile.close()
|
||||
|
||||
# Attachement du fichier joint
|
||||
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
|
||||
file_to_attache_to_mail.set_payload(open(outputFilename, "rb").read())
|
||||
|
||||
encoders.encode_base64(file_to_attache_to_mail)
|
||||
file_to_attache_to_mail.add_header('Content-Disposition',
|
||||
'attachment; filename="{0}"'.format(
|
||||
os.path.basename(outputFilename)))
|
||||
|
||||
new_node = {"attached_file": file_to_attache_to_mail}
|
||||
tab_files_to_attache_to_mail.append(new_node)
|
||||
|
||||
|
||||
|
||||
|
||||
else:
|
||||
# Il n'y pas de fichier joint sécurisé, il faut donc en créer un à la volée
|
||||
|
||||
"""
|
||||
1 - Creation du PDF
|
||||
"""
|
||||
contenu_doc_Template = jinja2.Template(str(partner_document_INVOICE_data['contenu_doc']))
|
||||
|
||||
contenuHtml = contenu_doc_Template.render(params=body["params"])
|
||||
|
||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||
ts = datetime.now().timestamp()
|
||||
ts = str(ts).replace(".", "").replace(",", "")[-5:]
|
||||
|
||||
orig_file_name = str(Invoice_header_data['invoice_header_type']) + "_" + str(my_partner['recid'])[
|
||||
0:5] + "_" + str(ts) + ".pdf"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
||||
|
||||
# open output file for writing (truncated binary)
|
||||
resultFile = open(outputFilename, "w+b")
|
||||
|
||||
# convert HTML to PDF
|
||||
pisaStatus = pisa.CreatePDF(
|
||||
src=contenuHtml, # the HTML to convert
|
||||
dest=resultFile) # file handle to receive result
|
||||
|
||||
# close output file
|
||||
resultFile.close()
|
||||
|
||||
# Attachement du fichier joint
|
||||
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
|
||||
file_to_attache_to_mail.set_payload(open(outputFilename, "rb").read())
|
||||
|
||||
encoders.encode_base64(file_to_attache_to_mail)
|
||||
file_to_attache_to_mail.add_header('Content-Disposition',
|
||||
'attachment; filename="{0}"'.format(os.path.basename(outputFilename)))
|
||||
|
||||
new_node = {"attached_file": file_to_attache_to_mail}
|
||||
tab_files_to_attache_to_mail.append(new_node)
|
||||
|
||||
|
||||
|
||||
corps_mail_doc_Template = jinja2.Template(str(partner_document_INVOICE_data['corps_mail']))
|
||||
sujet_doc_Template_subject = jinja2.Template(str(partner_document_INVOICE_data['sujet']))
|
||||
|
||||
|
||||
sourceHtml = corps_mail_doc_Template.render(params=body['params'], )
|
||||
sujetHtml = sujet_doc_Template_subject.render(params=body['params'], )
|
||||
|
||||
|
||||
html_mime = MIMEText(sourceHtml, 'html')
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " Le paramétrage du modèle de courrier 'PART_ORDER' ne comporte pas de 'joint_pdf' ")
|
||||
return False, " Le paramétrage du modèle de courrier 'PART_ORDER' ne comporte pas de 'joint_pdf'. Merci d'activier les pièces jointes dans le paramétrage "
|
||||
|
||||
|
||||
""" ORIG "" "
|
||||
#print(" #### Order_header_data = ", Order_header_data)
|
||||
#sourceHtml = contenu_doc_Template.render(params=Order_header_data, param_order_lines=Order_header_lines_data, company_data=company_data)
|
||||
|
||||
|
@ -2896,11 +3029,7 @@ def Send_Partner_Invoice_By_Email(diction):
|
|||
|
||||
#print(" #### sourceHtml = ", sourceHtml)
|
||||
|
||||
|
||||
print("debut envoi mail de test ")
|
||||
msg = EmailMessage()
|
||||
msg.set_content(contenuHtml, subtype='html')
|
||||
|
||||
"" " FIN ORIG """
|
||||
|
||||
"""
|
||||
Recuperation des parametre SMTP du partner si le client a decidé d'utiliser son propre smpt
|
||||
|
@ -2950,61 +3079,109 @@ def Send_Partner_Invoice_By_Email(diction):
|
|||
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
print("debut envoi mail de test ")
|
||||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
msg.attach(html_mime)
|
||||
|
||||
smtpserver = smtplib.SMTP(partner_SMTP_COUNT_smtpsrv, partner_SMTP_COUNT_port)
|
||||
else:
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
"""
|
||||
La commande est envoyée à l'adresse email qui se trouve sur la commande, le champ : 'order_header_email_client'.
|
||||
client_main_mail_tmp = ""
|
||||
|
||||
Si ce champ est vide alors on regarde si il y a un email sur la fiche client.
|
||||
"""
|
||||
client_main_mail_tmp = ""
|
||||
if ("order_header_email_client" in Order_header_data.keys() and Order_header_data[
|
||||
'order_header_email_client']):
|
||||
client_main_mail_tmp = str(Order_header_data['order_header_email_client'])
|
||||
|
||||
if ("order_header_email_client" in Order_header_data.keys() and Order_header_data['order_header_email_client']):
|
||||
client_main_mail_tmp = str(Order_header_data['order_header_email_client'])
|
||||
if (mycommon.isEmailValide(client_main_mail_tmp) is True):
|
||||
msg['To'] = client_main_mail_tmp
|
||||
|
||||
if (mycommon.isEmailValide(client_main_mail_tmp) is True):
|
||||
msg['To'] = client_main_mail_tmp
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - L'adresse email sur la commande n'est pas valide ")
|
||||
return False, " L'adresse email sur la commande n'est pas valide "
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - L'adresse email sur la commande n'est pas valide ")
|
||||
return False, " L'adresse email sur la commande n'est pas valide "
|
||||
3]) + " - Aucune adresse email sur la commande ")
|
||||
return False, " Aucune adresse email sur la commande "
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Aucune adresse email sur la commande ")
|
||||
return False, " Aucune adresse email sur la commande "
|
||||
|
||||
|
||||
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
msg['From'] = partner_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = sujetHtml
|
||||
|
||||
# Attacher l'eventuelle pièces jointes
|
||||
for myfile in tab_files_to_attache_to_mail:
|
||||
msg.attach(myfile['attached_file'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(partner_SMTP_COUNT_user, partner_SMTP_COUNT_password)
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
|
||||
|
||||
else:
|
||||
print("debut envoi mail de test ")
|
||||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
msg.attach(html_mime)
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
client_main_mail_tmp = ""
|
||||
|
||||
if ("order_header_email_client" in Order_header_data.keys() and Order_header_data[
|
||||
'order_header_email_client']):
|
||||
client_main_mail_tmp = str(Order_header_data['order_header_email_client'])
|
||||
|
||||
if (mycommon.isEmailValide(client_main_mail_tmp) is True):
|
||||
msg['To'] = client_main_mail_tmp
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - L'adresse email sur la commande n'est pas valide ")
|
||||
return False, " L'adresse email sur la commande n'est pas valide "
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Aucune adresse email sur la commande ")
|
||||
return False, " Aucune adresse email sur la commande "
|
||||
|
||||
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = sujetHtml
|
||||
|
||||
# Attacher l'eventuelle pièces jointes
|
||||
for myfile in tab_files_to_attache_to_mail:
|
||||
msg.attach(myfile['attached_file'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
|
||||
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
"""
|
||||
Ajout l'action dans l'historique
|
||||
"""
|
||||
## Add to log history
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = diction['token']
|
||||
history_event_dict['related_collection'] = "partner_invoice_header"
|
||||
history_event_dict['related_collection_recid'] = str(diction['invoice_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Envoyé par email à : '"+str(client_main_mail_tmp)+"' "
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
|
||||
return True, " La facture a été envoyée par email à :'"+str(client_main_mail_tmp)+"' "
|
||||
return True, "Facture a été envoyée par email à : '"+str(client_main_mail_tmp)+"' "
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
|
@ -3360,6 +3537,23 @@ def Add_Update_Invoice_Annotation(diction):
|
|||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
"""
|
||||
Ajout l'action dans l'historique
|
||||
"""
|
||||
## Add to log history
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = diction['token']
|
||||
history_event_dict['related_collection'] = "partner_invoice_header"
|
||||
history_event_dict['related_collection_recid'] = str(diction['_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Annotation Mise à jour "
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
|
||||
return True, 'La note a été mise à jour'
|
||||
|
||||
|
||||
|
@ -3668,6 +3862,37 @@ def Create_Invoice_Avoir_Total(diction):
|
|||
upsert=False,
|
||||
)
|
||||
|
||||
"""
|
||||
Creation des log historique pour :
|
||||
- la facture et
|
||||
- l'avoir
|
||||
"""
|
||||
## Add to log history pour l'annulation de l'avoir
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = str(token)
|
||||
history_event_dict['related_collection'] = "partner_invoice_header"
|
||||
history_event_dict['related_collection_recid'] = str(diction['_id'])
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Avoir : annulation facture. Ref Avoir : '"+str(credit_notes_reference)+"' "
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
## Add to log history pour l'avoir (nouveau document)
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = str(token)
|
||||
history_event_dict['related_collection'] = "partner_invoice_header"
|
||||
history_event_dict['related_collection_recid'] = str(invoice_header_inserted_id)
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Creation Avoir "
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -137,7 +137,6 @@ def Upload_Save_PDF_IMG_File(file=None, Folder=None):
|
|||
basename = os.path.basename(file.filename)
|
||||
basename2 = basename.split(".")
|
||||
|
||||
|
||||
'''
|
||||
Verification qu'il s'agit bien d'un fichier image ('jpg', 'jpeg', 'png', 'jpe', ...), dont le nom ne comporte pas de "."
|
||||
'''
|
||||
|
|
Loading…
Reference in New Issue