master
cherif 2024-07-15 20:53:19 +02:00
parent 35d0e81527
commit 57e5e08b83
6 changed files with 3552 additions and 23 deletions

View File

@ -1,15 +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="13/07/2024 - 22h">
<change afterPath="$PROJECT_DIR$/partner_produit_service_mgt.py" afterDir="false" />
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="14/07/2024 - 22h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dashbord_queries/factures_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/factures_tbd_qries.py" 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$/formulaire_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/formulaire_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_produit_service_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_produit_service_mgt.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -79,13 +77,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00302" summary="ddd">
<created>1715884005756</created>
<option name="number" value="00302" />
<option name="presentableId" value="LOCAL-00302" />
<option name="project" value="LOCAL" />
<updated>1715884005756</updated>
</task>
<task id="LOCAL-00303" summary="17/05/2024 - 21h30">
<created>1715973566772</created>
<option name="number" value="00303" />
@ -422,7 +413,14 @@
<option name="project" value="LOCAL" />
<updated>1720900252717</updated>
</task>
<option name="localTasksCounter" value="351" />
<task id="LOCAL-00351" summary="14/07/2024 - 22h">
<created>1720990126140</created>
<option name="number" value="00351" />
<option name="presentableId" value="LOCAL-00351" />
<option name="project" value="LOCAL" />
<updated>1720990126140</updated>
</task>
<option name="localTasksCounter" value="352" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -464,7 +462,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="qsdsqsqdsq" />
<MESSAGE value="05/06/2024 - 23h" />
<MESSAGE value="06/06/2024 - 12h" />
<MESSAGE value="06/06/2024 - 20h" />
@ -489,6 +486,7 @@
<MESSAGE value="wwssdssddd" />
<MESSAGE value="11/07/2024 - 13h14" />
<MESSAGE value="13/07/2024 - 22h" />
<option name="LAST_COMMIT_MESSAGE" value="13/07/2024 - 22h" />
<MESSAGE value="14/07/2024 - 22h" />
<option name="LAST_COMMIT_MESSAGE" value="14/07/2024 - 22h" />
</component>
</project>

View File

@ -384,8 +384,7 @@ def Get_Qery_List_Factures_Data_By_Class(diction):
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$invoice_header_ref_interne",
'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$invoice_header_ref_interne",'$$partner_invoice_line_invoice_header_ref_interne']},
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
]

File diff suppressed because it is too large Load Diff

67
main.py
View File

@ -10413,6 +10413,19 @@ def Get_List_Partner_Produit_Service():
return jsonify(status=status, message=retval)
"""
API pour recuperer la liste des un produit et service d'un partner (article) avec des filtres
"""
@app.route('/myclass/api/Get_List_Partner_Produit_Service_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Produit_Service_with_filter():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_List_Partner_Produit_Service_with_filter payload = ",payload)
status, retval = partner_produit_service_mgt.Get_List_Partner_Produit_Service_with_filter(payload)
return jsonify(status=status, message=retval)
"""
API pour recuperer les données d'un produit et service d'un partner (article)
@ -10427,6 +10440,60 @@ def Get_Given_Partner_Produit_Service():
return jsonify(status=status, message=retval)
"""
API pour recuperer l'image d'un produit et service
"""
@app.route('/myclass/api/getRecoded_Partner_Product_Image_from_front/', methods=['POST','GET'])
@crossdomain(origin='*')
def getRecoded_Partner_Product_Image_from_front():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### getRecoded_Partner_Product_Image_from_front payload = ",payload)
status, retval = partner_produit_service_mgt.getRecoded_Partner_Product_Image_from_front(payload)
return jsonify(status=status, message=retval)
"""
API qui enregistre/met à jour l'image d'un produit et service d'un partenaire
"""
@app.route('/myclass/api/Update_Partner_Product_Image/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Partner_Product_Image():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Update_Partner_Product_Image : payload = ",payload)
if request.method == 'POST':
# Create variable for uploaded file
if ('file_img' in request.files.keys()):
file_img = request.files['file_img']
else:
file_img = None
return False, "Aucun fichier image à enregistrer"
localStatus, message = partner_produit_service_mgt.Update_Partner_Product_Image(file_img, MYSY_GV.upload_folder, payload)
return jsonify(status=localStatus, message=message)
"""
API pour supprimer l'image d'un produit et service
"""
@app.route('/myclass/api/DeleteImage_Partner_Product/', methods=['POST','GET'])
@crossdomain(origin='*')
def DeleteImage_Partner_Product():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### DeleteImage_Partner_Product payload = ",payload)
status, retval = partner_produit_service_mgt.DeleteImage_Partner_Product(payload)
return jsonify(status=status, message=retval)
if __name__ == '__main__':
print(" debut api")

View File

@ -2207,7 +2207,8 @@ def Add_Update_Partner_Order_Line(diction):
'order_line_tax', 'order_line_type_reduction', 'order_line_type_valeur',
'order_line_montant_reduction', 'order_line_id', 'order_header_ref_interne',
'order_header_id', 'order_line_status', 'order_line_type', 'order_line_comment',
'order_line_montant_hors_taxes', 'order_line_tax_amount', 'order_line_montant_toutes_taxes']
'order_line_montant_hors_taxes', 'order_line_tax_amount', 'order_line_montant_toutes_taxes',
'order_line_type_article']
@ -2311,6 +2312,15 @@ def Add_Update_Partner_Order_Line(diction):
order_line_qty = diction['order_line_qty']
data['order_line_qty'] = order_line_qty
order_line_type_article = ""
if ("order_line_type_article" in diction.keys()):
if diction['order_line_type_article']:
order_line_type_article = diction['order_line_type_article']
data['order_line_type_article'] = order_line_type_article
order_line_prix_unitaire = ""
if ("order_line_prix_unitaire" in diction.keys()):
if diction['order_line_prix_unitaire']:
@ -3307,6 +3317,9 @@ def Get_Given_Partner_Order_Lines(diction):
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
filt_order_header_id = {'order_header_id': str(diction['order_header_id'])}
"""
Recuperation des formations
"""
query = [{'$match': {'$and': [ filt_order_header_id,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup':
@ -3435,7 +3448,128 @@ def Get_Given_Partner_Order_Lines(diction):
RetObject.append(mycommon.JSONEncoder().encode(user))
"""
Recuperation des produits & services
"""
query = [{'$match': {'$and': [filt_order_header_id,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup': {
'from': 'partner_produit_service',
"let": {'order_line_formation': "$order_line_formation",
"partner_produit_service_partner_owner_recid":"$partner_owner_recid"
},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$_id", {'$convert': {
'input': "$$order_line_formation",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$partner_owner_recid",'$$partner_produit_service_partner_owner_recid']},
]
}
}
},
],
'as': 'collection_partner_produit_service'
}
},
]
print("#### Get_Given_Partner_Order_Lines for PRODUCT & SERVICES : query pip= ", query)
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
if ('collection_partner_produit_service' in retval.keys() and len(retval['collection_partner_produit_service']) > 0):
user = {}
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
user['_id'] = retval['_id']
user['order_line_formation'] = retval['order_line_formation']
user['order_line_qty'] = retval['order_line_qty']
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
user['order_header_id'] = retval['order_header_id']
user['order_header_ref_interne'] = retval['order_header_ref_interne']
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
user['order_line_session_id'] = retval['order_line_session_id']
# Recuperation du code de la session
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'partner_owner_recid': str(my_partner['recid']),
'valide': '1'})
if (local_session_data and "code_session" in local_session_data.keys()):
user['order_line_session_code_session'] = local_session_data['code_session']
else:
user['order_line_session_code_session'] = ""
else:
user['order_line_session_id'] = ""
user['order_line_session_code_session'] = ""
if ("order_line_montant_reduction" in retval.keys()):
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
else:
user['order_line_montant_reduction'] = "0"
if ("order_line_montant_toutes_taxes" in retval.keys()):
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
else:
user['order_line_montant_toutes_taxes'] = "0"
if ("order_line_tax" in retval.keys()):
user['order_line_tax'] = retval['order_line_tax']
else:
user['order_line_tax'] = ""
if ("order_line_tax_amount" in retval.keys()):
user['order_line_tax_amount'] = retval['order_line_tax_amount']
else:
user['order_line_tax_amount'] = "0"
if ("order_line_type_reduction" in retval.keys()):
user['order_line_type_reduction'] = retval['order_line_type_reduction']
else:
user['order_line_montant_reduction'] = ""
if ("order_line_type_valeur" in retval.keys()):
user['order_line_type_valeur'] = retval['order_line_type_valeur']
else:
user['order_line_type_valeur'] = "0"
if ("order_line_montant_hors_taxes" in retval.keys()):
user['order_line_montant_hors_taxes'] = retval['order_line_montant_hors_taxes']
else:
user['order_line_montant_hors_taxes'] = "0"
user['date_update'] = retval['date_update']
user['partner_owner_recid'] = retval['partner_owner_recid']
user['order_line_type'] = retval['order_line_type']
user['order_line_status'] = retval['order_line_status']
if ("order_line_comment" in retval.keys()):
user['order_line_comment'] = retval['order_line_comment']
else:
user['order_line_comment'] = ""
user['title'] = retval['collection_partner_produit_service'][0]['nom']
user['order_line_formation_external_code'] = retval['collection_partner_produit_service'][0]['code']
user['domaine'] = ""
user['duration'] = ""
user['duration_unit'] = ""
user['duration_concat'] = ""
RetObject.append(mycommon.JSONEncoder().encode(user))
#print(" ### RetObject = ", RetObject)
return True, RetObject
@ -3634,6 +3768,130 @@ def Get_Given_Partner_Order_Lines_From_order_ref_interne(diction):
RetObject.append(mycommon.JSONEncoder().encode(user))
"""
Recuperation des produits & services
"""
query = [{'$match': {'$and': [filt_order_header_ref_interne,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup': {
'from': 'partner_produit_service',
"let": {'order_line_formation': "$order_line_formation",
"partner_produit_service_partner_owner_recid": "$partner_owner_recid"
},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$_id", {'$convert': {
'input': "$$order_line_formation",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$partner_owner_recid",
'$$partner_produit_service_partner_owner_recid']},
]
}
}
},
],
'as': 'collection_partner_produit_service'
}
},
]
print("#### Get_Given_Partner_Order_Lines for PRODUCT & SERVICES : query pip= ", query)
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
if ('collection_partner_produit_service' in retval.keys() and len(
retval['collection_partner_produit_service']) > 0):
user = {}
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
user['_id'] = retval['_id']
user['order_line_formation'] = retval['order_line_formation']
user['order_line_qty'] = retval['order_line_qty']
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
user['order_header_id'] = retval['order_header_id']
user['order_header_ref_interne'] = retval['order_header_ref_interne']
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
user['order_line_session_id'] = retval['order_line_session_id']
# Recuperation du code de la session
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'partner_owner_recid': str(my_partner['recid']),
'valide': '1'})
if (local_session_data and "code_session" in local_session_data.keys()):
user['order_line_session_code_session'] = local_session_data['code_session']
else:
user['order_line_session_code_session'] = ""
else:
user['order_line_session_id'] = ""
user['order_line_session_code_session'] = ""
if ("order_line_montant_reduction" in retval.keys()):
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
else:
user['order_line_montant_reduction'] = "0"
if ("order_line_montant_toutes_taxes" in retval.keys()):
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
else:
user['order_line_montant_toutes_taxes'] = "0"
if ("order_line_tax" in retval.keys()):
user['order_line_tax'] = retval['order_line_tax']
else:
user['order_line_tax'] = ""
if ("order_line_tax_amount" in retval.keys()):
user['order_line_tax_amount'] = retval['order_line_tax_amount']
else:
user['order_line_tax_amount'] = "0"
if ("order_line_type_reduction" in retval.keys()):
user['order_line_type_reduction'] = retval['order_line_type_reduction']
else:
user['order_line_montant_reduction'] = ""
if ("order_line_type_valeur" in retval.keys()):
user['order_line_type_valeur'] = retval['order_line_type_valeur']
else:
user['order_line_type_valeur'] = "0"
if ("order_line_montant_hors_taxes" in retval.keys()):
user['order_line_montant_hors_taxes'] = retval['order_line_montant_hors_taxes']
else:
user['order_line_montant_hors_taxes'] = "0"
user['date_update'] = retval['date_update']
user['partner_owner_recid'] = retval['partner_owner_recid']
user['order_line_type'] = retval['order_line_type']
user['order_line_status'] = retval['order_line_status']
if ("order_line_comment" in retval.keys()):
user['order_line_comment'] = retval['order_line_comment']
else:
user['order_line_comment'] = ""
user['title'] = retval['collection_partner_produit_service'][0]['nom']
user['order_line_formation_external_code'] = retval['collection_partner_produit_service'][0]['code']
user['domaine'] = ""
user['duration'] = ""
user['duration_unit'] = ""
user['duration_concat'] = ""
RetObject.append(mycommon.JSONEncoder().encode(user))
#print(" ### RetObject = ", RetObject)
return True, RetObject
@ -4308,6 +4566,129 @@ def Get_Given_Line_Of_Partner_Order_Lines(diction):
RetObject.append(mycommon.JSONEncoder().encode(user))
"""
Recuperation des produits & services
"""
query = [{'$match': {'$and': [filt_order_line_id, filt_order_line_header_ref_interne,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup': {
'from': 'partner_produit_service',
"let": {'order_line_formation': "$order_line_formation",
"partner_produit_service_partner_owner_recid": "$partner_owner_recid"
},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$_id", {'$convert': {
'input': "$$order_line_formation",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$partner_owner_recid",
'$$partner_produit_service_partner_owner_recid']},
]
}
}
},
],
'as': 'collection_partner_produit_service'
}
},
]
print("#### Get_Given_Partner_Order_Lines for PRODUCT & SERVICES : query pip= ", query)
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
if ('collection_partner_produit_service' in retval.keys() and len(
retval['collection_partner_produit_service']) > 0):
user = {}
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
user['_id'] = retval['_id']
user['order_line_formation'] = retval['order_line_formation']
user['order_line_qty'] = retval['order_line_qty']
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
user['order_header_id'] = retval['order_header_id']
user['order_header_ref_interne'] = retval['order_header_ref_interne']
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
user['order_line_session_id'] = retval['order_line_session_id']
# Recuperation du code de la session
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'partner_owner_recid': str(my_partner['recid']),
'valide': '1'})
if (local_session_data and "code_session" in local_session_data.keys()):
user['order_line_session_code_session'] = local_session_data['code_session']
else:
user['order_line_session_code_session'] = ""
else:
user['order_line_session_id'] = ""
user['order_line_session_code_session'] = ""
if ("order_line_montant_reduction" in retval.keys()):
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
else:
user['order_line_montant_reduction'] = "0"
if ("order_line_montant_toutes_taxes" in retval.keys()):
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
else:
user['order_line_montant_toutes_taxes'] = "0"
if ("order_line_tax" in retval.keys()):
user['order_line_tax'] = retval['order_line_tax']
else:
user['order_line_tax'] = ""
if ("order_line_tax_amount" in retval.keys()):
user['order_line_tax_amount'] = retval['order_line_tax_amount']
else:
user['order_line_tax_amount'] = "0"
if ("order_line_type_reduction" in retval.keys()):
user['order_line_type_reduction'] = retval['order_line_type_reduction']
else:
user['order_line_montant_reduction'] = ""
if ("order_line_type_valeur" in retval.keys()):
user['order_line_type_valeur'] = retval['order_line_type_valeur']
else:
user['order_line_type_valeur'] = "0"
if ("order_line_montant_hors_taxes" in retval.keys()):
user['order_line_montant_hors_taxes'] = retval['order_line_montant_hors_taxes']
else:
user['order_line_montant_hors_taxes'] = "0"
user['date_update'] = retval['date_update']
user['partner_owner_recid'] = retval['partner_owner_recid']
user['order_line_type'] = retval['order_line_type']
user['order_line_status'] = retval['order_line_status']
if ("order_line_comment" in retval.keys()):
user['order_line_comment'] = retval['order_line_comment']
else:
user['order_line_comment'] = ""
user['title'] = retval['collection_partner_produit_service'][0]['nom']
user['order_line_formation_external_code'] = retval['collection_partner_produit_service'][0]['code']
user['domaine'] = ""
user['duration'] = ""
user['duration_unit'] = ""
user['duration_concat'] = ""
RetObject.append(mycommon.JSONEncoder().encode(user))
#print(" ### RetObject = ", RetObject)
@ -4680,6 +5061,8 @@ def GerneratePDF_Partner_Order(diction):
Order_header_data['order_header_condition_paiement_code'] = cdtion_paiement_code
Order_header_data['order_header_condition_paiement_id'] = cdtion_paiement_id
val_tmp = 0
Order_header_lines_data = []
# Recuperation des details de lignes de : partner_order_line
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
@ -4702,8 +5085,7 @@ def GerneratePDF_Partner_Order(diction):
}
]
#print("#### Get_Given_Partner_Order_Lines_From_order_ref_interne : query pip= ", query)
val_tmp = 0
Order_header_lines_data = []
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
if ('myclass_collection' in retval.keys() and len(retval['myclass_collection']) > 0):
user = {}
@ -4821,6 +5203,141 @@ def GerneratePDF_Partner_Order(diction):
Order_header_lines_data.append(user)
"""
Recuperation des produits et services
"""
query = [{'$match': {'$and': [filt_order_header_order_id,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup': {
'from': 'partner_produit_service',
"let": {'order_line_formation': "$order_line_formation",
"partner_produit_service_partner_owner_recid": "$partner_owner_recid"
},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$_id", {'$convert': {
'input': "$$order_line_formation",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$partner_owner_recid",
'$$partner_produit_service_partner_owner_recid']},
]
}
}
},
],
'as': 'collection_partner_produit_service'
}
},
]
# print("#### Get_Given_Partner_Order_Lines_From_order_ref_interne : query pip= ", query)
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
if ('collection_partner_produit_service' in retval.keys() and len(retval['collection_partner_produit_service']) > 0):
user = {}
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
user['_id'] = retval['_id']
user['order_line_formation'] = retval['order_line_formation']
user['order_line_qty'] = retval['order_line_qty']
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
user['order_header_id'] = retval['order_header_id']
user['order_header_ref_interne'] = retval['order_header_ref_interne']
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
'partner_owner_recid': my_partner['recid']})
if (local_session_data):
if ("code_session" in local_session_data.keys()):
user['code_session'] = local_session_data['code_session']
else:
user['code_session'] = ""
if ("date_debut" in local_session_data.keys() and "date_fin" in local_session_data.keys()):
user['session_date_debut'] = local_session_data['date_debut']
user['session_date_fin'] = local_session_data['date_fin']
else:
user['session_date_debut'] = ""
user['session_date_fin'] = ""
else:
user['order_line_session_id'] = ""
user['code_session'] = ""
user['session_date_debut'] = ""
user['session_date_fin'] = ""
if ("order_line_montant_reduction" in retval.keys()):
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
else:
user['order_line_montant_reduction'] = "0"
if ("order_line_montant_toutes_taxes" in retval.keys()):
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
else:
user['order_line_montant_toutes_taxes'] = "0"
if ("order_line_tax" in retval.keys()):
user['order_line_tax'] = retval['order_line_tax']
else:
user['order_line_tax'] = ""
if ("order_line_tax_amount" in retval.keys()):
user['order_line_tax_amount'] = retval['order_line_tax_amount']
else:
user['order_line_tax_amount'] = "0"
if ("order_line_type_reduction" in retval.keys()):
user['order_line_type_reduction'] = retval['order_line_type_reduction']
else:
user['order_line_montant_reduction'] = ""
if ("order_line_type_valeur" in retval.keys()):
user['order_line_type_valeur'] = retval['order_line_type_valeur']
else:
user['order_line_type_valeur'] = "0"
if ("order_line_montant_hors_taxes" in retval.keys()):
user['order_line_montant_hors_taxes'] = str(
round(mycommon.tryFloat(str(retval['order_line_montant_hors_taxes'])), 2))
else:
user['order_line_montant_hors_taxes'] = "0"
user['date_update'] = retval['date_update']
user['partner_owner_recid'] = retval['partner_owner_recid']
user['order_line_type'] = retval['order_line_type']
user['order_line_status'] = retval['order_line_status']
if ("order_line_comment" in retval.keys()):
user['order_line_comment'] = retval['order_line_comment']
else:
user['order_line_comment'] = ""
user['title'] = retval['collection_partner_produit_service'][0]['nom']
user['order_line_formation_external_code'] = retval['collection_partner_produit_service'][0]['code']
user['domaine'] = ""
user['duration'] = ""
user['duration_unit'] = ""
user['duration_concat'] = ""
Order_header_lines_data.append(user)
if (len(Order_header_lines_data) <= 0):
mycommon.myprint(str(inspect.stack()[0][
3]) + " - Aucune ligne de détail pour cette commande ")
@ -5159,6 +5676,139 @@ def Gernerate_Stock_PDF_Partner_Order(diction):
Order_header_lines_data.append(user)
"""
Recuperation des produits et services
"""
query = [{'$match': {'$and': [filt_order_header_order_id,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup': {
'from': 'partner_produit_service',
"let": {'order_line_formation': "$order_line_formation",
"partner_produit_service_partner_owner_recid": "$partner_owner_recid"
},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$_id", {'$convert': {
'input': "$$order_line_formation",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$partner_owner_recid",
'$$partner_produit_service_partner_owner_recid']},
]
}
}
},
],
'as': 'collection_partner_produit_service'
}
},
]
# print("#### Get_Given_Partner_Order_Lines_From_order_ref_interne : query pip= ", query)
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
if ('collection_partner_produit_service' in retval.keys() and len(
retval['collection_partner_produit_service']) > 0):
user = {}
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
user['_id'] = retval['_id']
user['order_line_formation'] = retval['order_line_formation']
user['order_line_qty'] = retval['order_line_qty']
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
user['order_header_id'] = retval['order_header_id']
user['order_header_ref_interne'] = retval['order_header_ref_interne']
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
'partner_owner_recid': my_partner['recid']})
if (local_session_data):
if ("code_session" in local_session_data.keys()):
user['code_session'] = local_session_data['code_session']
else:
user['code_session'] = ""
if ("date_debut" in local_session_data.keys() and "date_fin" in local_session_data.keys()):
user['session_date_debut'] = local_session_data['date_debut']
user['session_date_fin'] = local_session_data['date_fin']
else:
user['session_date_debut'] = ""
user['session_date_fin'] = ""
else:
user['order_line_session_id'] = ""
user['code_session'] = ""
user['session_date_debut'] = ""
user['session_date_fin'] = ""
if ("order_line_montant_reduction" in retval.keys()):
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
else:
user['order_line_montant_reduction'] = "0"
if ("order_line_montant_toutes_taxes" in retval.keys()):
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
else:
user['order_line_montant_toutes_taxes'] = "0"
if ("order_line_tax" in retval.keys()):
user['order_line_tax'] = retval['order_line_tax']
else:
user['order_line_tax'] = ""
if ("order_line_tax_amount" in retval.keys()):
user['order_line_tax_amount'] = retval['order_line_tax_amount']
else:
user['order_line_tax_amount'] = "0"
if ("order_line_type_reduction" in retval.keys()):
user['order_line_type_reduction'] = retval['order_line_type_reduction']
else:
user['order_line_montant_reduction'] = ""
if ("order_line_type_valeur" in retval.keys()):
user['order_line_type_valeur'] = retval['order_line_type_valeur']
else:
user['order_line_type_valeur'] = "0"
if ("order_line_montant_hors_taxes" in retval.keys()):
user['order_line_montant_hors_taxes'] = str(
round(mycommon.tryFloat(str(retval['order_line_montant_hors_taxes'])), 2))
else:
user['order_line_montant_hors_taxes'] = "0"
user['date_update'] = retval['date_update']
user['partner_owner_recid'] = retval['partner_owner_recid']
user['order_line_type'] = retval['order_line_type']
user['order_line_status'] = retval['order_line_status']
if ("order_line_comment" in retval.keys()):
user['order_line_comment'] = retval['order_line_comment']
else:
user['order_line_comment'] = ""
user['title'] = retval['collection_partner_produit_service'][0]['nom']
user['order_line_formation_external_code'] = retval['collection_partner_produit_service'][0]['code']
user['domaine'] = ""
user['duration'] = ""
user['duration_unit'] = ""
user['duration_concat'] = ""
Order_header_lines_data.append(user)
if (len(Order_header_lines_data) <= 0):
mycommon.myprint(str(inspect.stack()[0][
3]) + " - Aucune ligne de détail pour cette commande ")
@ -5498,6 +6148,139 @@ def Send_Partner_Order_By_Email(diction):
Order_header_lines_data.append(user)
"""
Recuperation des produits et services
"""
query = [{'$match': {'$and': [filt_order_header_order_id,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup': {
'from': 'partner_produit_service',
"let": {'order_line_formation': "$order_line_formation",
"partner_produit_service_partner_owner_recid": "$partner_owner_recid"
},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$_id", {'$convert': {
'input': "$$order_line_formation",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$partner_owner_recid",
'$$partner_produit_service_partner_owner_recid']},
]
}
}
},
],
'as': 'collection_partner_produit_service'
}
},
]
# print("#### Get_Given_Partner_Order_Lines_From_order_ref_interne : query pip= ", query)
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
if ('collection_partner_produit_service' in retval.keys() and len(
retval['collection_partner_produit_service']) > 0):
user = {}
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
user['_id'] = retval['_id']
user['order_line_formation'] = retval['order_line_formation']
user['order_line_qty'] = retval['order_line_qty']
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
user['order_header_id'] = retval['order_header_id']
user['order_header_ref_interne'] = retval['order_header_ref_interne']
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
'partner_owner_recid': my_partner['recid']})
if (local_session_data):
if ("code_session" in local_session_data.keys()):
user['code_session'] = local_session_data['code_session']
else:
user['code_session'] = ""
if ("date_debut" in local_session_data.keys() and "date_fin" in local_session_data.keys()):
user['session_date_debut'] = local_session_data['date_debut']
user['session_date_fin'] = local_session_data['date_fin']
else:
user['session_date_debut'] = ""
user['session_date_fin'] = ""
else:
user['order_line_session_id'] = ""
user['code_session'] = ""
user['session_date_debut'] = ""
user['session_date_fin'] = ""
if ("order_line_montant_reduction" in retval.keys()):
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
else:
user['order_line_montant_reduction'] = "0"
if ("order_line_montant_toutes_taxes" in retval.keys()):
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
else:
user['order_line_montant_toutes_taxes'] = "0"
if ("order_line_tax" in retval.keys()):
user['order_line_tax'] = retval['order_line_tax']
else:
user['order_line_tax'] = ""
if ("order_line_tax_amount" in retval.keys()):
user['order_line_tax_amount'] = retval['order_line_tax_amount']
else:
user['order_line_tax_amount'] = "0"
if ("order_line_type_reduction" in retval.keys()):
user['order_line_type_reduction'] = retval['order_line_type_reduction']
else:
user['order_line_montant_reduction'] = ""
if ("order_line_type_valeur" in retval.keys()):
user['order_line_type_valeur'] = retval['order_line_type_valeur']
else:
user['order_line_type_valeur'] = "0"
if ("order_line_montant_hors_taxes" in retval.keys()):
user['order_line_montant_hors_taxes'] = str(
round(mycommon.tryFloat(str(retval['order_line_montant_hors_taxes'])), 2))
else:
user['order_line_montant_hors_taxes'] = "0"
user['date_update'] = retval['date_update']
user['partner_owner_recid'] = retval['partner_owner_recid']
user['order_line_type'] = retval['order_line_type']
user['order_line_status'] = retval['order_line_status']
if ("order_line_comment" in retval.keys()):
user['order_line_comment'] = retval['order_line_comment']
else:
user['order_line_comment'] = ""
user['title'] = retval['collection_partner_produit_service'][0]['nom']
user['order_line_formation_external_code'] = retval['collection_partner_produit_service'][0]['code']
user['domaine'] = ""
user['duration'] = ""
user['duration_unit'] = ""
user['duration_concat'] = ""
Order_header_lines_data.append(user)
if(len(Order_header_lines_data) <= 0 ):
mycommon.myprint(str(inspect.stack()[0][
@ -7195,6 +7978,139 @@ def Send_Quotation_Remind_Level1(diction):
Order_header_lines_data.append(user)
"""
Recuperation des produits et services
"""
query = [{'$match': {'$and': [filt_order_header_order_id,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup': {
'from': 'partner_produit_service',
"let": {'order_line_formation': "$order_line_formation",
"partner_produit_service_partner_owner_recid": "$partner_owner_recid"
},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$valide", "1"]},
{'$eq': ["$_id", {'$convert': {
'input': "$$order_line_formation",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$partner_owner_recid",
'$$partner_produit_service_partner_owner_recid']},
]
}
}
},
],
'as': 'collection_partner_produit_service'
}
},
]
# print("#### Get_Given_Partner_Order_Lines_From_order_ref_interne : query pip= ", query)
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
if ('collection_partner_produit_service' in retval.keys() and len(
retval['collection_partner_produit_service']) > 0):
user = {}
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
user['_id'] = retval['_id']
user['order_line_formation'] = retval['order_line_formation']
user['order_line_qty'] = retval['order_line_qty']
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
user['order_header_id'] = retval['order_header_id']
user['order_header_ref_interne'] = retval['order_header_ref_interne']
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_session_id" in retval.keys()):
local_session_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(retval['order_line_session_id'])),
'valide': '1',
'partner_owner_recid': my_partner['recid']})
if (local_session_data):
if ("code_session" in local_session_data.keys()):
user['code_session'] = local_session_data['code_session']
else:
user['code_session'] = ""
if ("date_debut" in local_session_data.keys() and "date_fin" in local_session_data.keys()):
user['session_date_debut'] = local_session_data['date_debut']
user['session_date_fin'] = local_session_data['date_fin']
else:
user['session_date_debut'] = ""
user['session_date_fin'] = ""
else:
user['order_line_session_id'] = ""
user['code_session'] = ""
user['session_date_debut'] = ""
user['session_date_fin'] = ""
if ("order_line_montant_reduction" in retval.keys()):
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
else:
user['order_line_montant_reduction'] = "0"
if ("order_line_montant_toutes_taxes" in retval.keys()):
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
else:
user['order_line_montant_toutes_taxes'] = "0"
if ("order_line_tax" in retval.keys()):
user['order_line_tax'] = retval['order_line_tax']
else:
user['order_line_tax'] = ""
if ("order_line_tax_amount" in retval.keys()):
user['order_line_tax_amount'] = retval['order_line_tax_amount']
else:
user['order_line_tax_amount'] = "0"
if ("order_line_type_reduction" in retval.keys()):
user['order_line_type_reduction'] = retval['order_line_type_reduction']
else:
user['order_line_montant_reduction'] = ""
if ("order_line_type_valeur" in retval.keys()):
user['order_line_type_valeur'] = retval['order_line_type_valeur']
else:
user['order_line_type_valeur'] = "0"
if ("order_line_montant_hors_taxes" in retval.keys()):
user['order_line_montant_hors_taxes'] = str(
round(mycommon.tryFloat(str(retval['order_line_montant_hors_taxes'])), 2))
else:
user['order_line_montant_hors_taxes'] = "0"
user['date_update'] = retval['date_update']
user['partner_owner_recid'] = retval['partner_owner_recid']
user['order_line_type'] = retval['order_line_type']
user['order_line_status'] = retval['order_line_status']
if ("order_line_comment" in retval.keys()):
user['order_line_comment'] = retval['order_line_comment']
else:
user['order_line_comment'] = ""
user['title'] = retval['collection_partner_produit_service'][0]['nom']
user['order_line_formation_external_code'] = retval['collection_partner_produit_service'][0]['code']
user['domaine'] = ""
user['duration'] = ""
user['duration_unit'] = ""
user['duration_concat'] = ""
Order_header_lines_data.append(user)
if (len(Order_header_lines_data) <= 0):
mycommon.myprint(str(inspect.stack()[0][
3]) + " - Aucune ligne de détail pour cette commande ")

View File

@ -54,7 +54,8 @@ def Add_Partner_Produit_Service(diction):
"""
Verification des input acceptés
"""
field_list = ['token', 'code', 'nom', 'description', 'type', 'code_taxe', 'famille']
field_list = ['token', 'code', 'nom', 'description', 'type', 'code_taxe',
'famille', 'prix_vente']
incom_keys = diction.keys()
for val in incom_keys:
@ -87,6 +88,11 @@ def Add_Partner_Produit_Service(diction):
if (local_status is not True):
return local_status, my_partner
# Verifier que le prix est un floattant
if ("prix_vente" in diction.keys() and diction['prix_vente']):
local_price_status, local_status_retval = mycommon.IsFloat(str(diction['prix_vente']))
if (local_price_status is False):
return local_price_status, local_status_retval
# Verifier que ce code n'existe pas déjà
is_existe_class_categorie = MYSY_GV.dbname['partner_produit_service'].count_documents({'code':str(diction['code']),
@ -142,7 +148,8 @@ def Update_Partner_Produit_Service(diction):
"""
Verification des input acceptés
"""
field_list = ['token', '_id', 'code', 'nom', 'description', 'type', 'code_taxe', 'famille']
field_list = ['token', '_id', 'code', 'nom', 'description', 'type', 'code_taxe',
'famille', 'prix_vente']
incom_keys = diction.keys()
for val in incom_keys:
@ -175,8 +182,15 @@ def Update_Partner_Produit_Service(diction):
if (local_status is not True):
return local_status, my_partner
new_data = diction
# Verifier que le prix est un floattant
if( "prix_vente" in diction.keys() and diction['prix_vente']):
local_price_status, local_status_retval = mycommon.IsFloat(str(diction['prix_vente']))
if( local_price_status is False ):
return local_price_status, local_status_retval
new_data = diction
# Verifier que le produit est valide
is_existe_produit = MYSY_GV.dbname['partner_produit_service'].count_documents(
{'_id': ObjectId(str(diction['_id'])),
@ -398,7 +412,91 @@ def Get_List_Partner_Produit_Service(diction):
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer la liste des categories de formation "
return False, " Impossible de récupérer la liste des produits "
"""
Recuperer la liste des produits et services d'un partenaire avec des filter
"""
def Get_List_Partner_Produit_Service_with_filter(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'code', 'nom' ]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
return False, " Les informations fournies sont incorrectes",
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', ]
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes",
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
filt_code = {}
if ("code" in diction.keys()):
filt_code = {'code': {'$regex': str(diction['code']), "$options": "i"}}
filt_nom = {}
if ("nom" in diction.keys()):
filt_nom = {'nom': {'$regex': str(diction['nom']), "$options": "i"}}
"""
Clés de mise à jour
"""
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['valide'] = "1"
data_cle['locked'] = "0"
find_qry = {'$and': [
data_cle,
filt_nom, filt_code]}
print(" ### find_qry = ", find_qry)
RetObject = []
val_tmp = 0
for retval in MYSY_GV.dbname['partner_produit_service'].find(find_qry).sort([("_id", pymongo.DESCENDING), ]):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
return True, RetObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer la liste des produits "
@ -470,3 +568,201 @@ def Get_Given_Partner_Produit_Service(diction):
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer les données du produit "
""" Recuperation de l'image d'un produit
/!\ important : on prend le 'related_collection_recid' comme le '_id' de la collection inscription
"""
def getRecoded_Partner_Product_Image_from_front(diction=None):
try:
# Dictionnaire des champs utilisables
field_list = ['token', '_id', ]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le champ '" + val + "' n'existe pas, requete annulée")
return False, " Impossible de récupérer les informations"
'''
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
On controle que les champs obligatoires sont presents dans la liste
'''
field_list_obligatoire = ['token', '_id',]
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - : La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Impossible de récupérer les informations"
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
qery_images = {'locked': '0', 'valide': '1', 'related_collection': 'partner_produit_service',
'related_collection_recid': str(diction['_id'])}
#print(" ### qery_images = ", qery_images)
RetObject = []
employee_images = {}
# Recuperation des image 'logo' et 'cachet' si le partenaire en a
for retVal in MYSY_GV.dbname['mysy_images'].find(qery_images):
if ('type_img' in retVal.keys()):
if (retVal['type_img'] == "user"):
employee_images['logo_img'] = retVal['img'].decode()
employee_images['logo_img_recid'] = retVal['recid']
RetObject.append(mycommon.JSONEncoder().encode(employee_images))
return True, RetObject
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))
return False, " Impossible de recupérer l'image de du produit "
"""
Cette fonction ajoute une image de profil d'un produit
"""
def Update_Partner_Product_Image(file_img=None, Folder=None, diction=None):
try:
# Dictionnaire des champs utilisables
'''
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list.
'''
field_list = ['token', 'file_img_recid', '_id' ]
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " : Le champ '"+val + "' n'est pas autorisé ")
return False, " Le champ '" + val + "' n'est pas accepté "
'''
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
On controle que les champs obligatoires sont presents dans la liste
'''
field_list_obligatoire = ['token']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " La valeur '" + val + "' n'est pas presente dans liste "
# recuperation des paramettre
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
_id = ""
if ("_id" in diction.keys()):
if diction['_id']:
_id = diction['_id']
if( file_img ):
recordimage_diction = {}
recordimage_diction['token'] = diction['token']
recordimage_diction['related_collection'] = "partner_produit_service"
recordimage_diction['type_img'] = "user"
recordimage_diction['related_collection_recid'] = str(_id)
recordimage_diction['image_recid'] = diction['file_img_recid']
local_status, local_message = mycommon.recordClassImage_v2(file_img, MYSY_GV.upload_folder, recordimage_diction)
if( local_status is False):
return local_status, local_message
return True, "L'image a été correctement enregistrée"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible d'enregistrer l'image"
"""
Suppresion d'un image d'un produit
"""
def DeleteImage_Partner_Product(diction=None):
try:
# Dictionnaire des champs utilisables
field_list = ['token', 'image_recid', ]
incom_keys = diction.keys()
'''
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list.
'''
for val in incom_keys:
if str(val).lower() not in str(field_list).lower():
mycommon.myprint(
str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas accepté dans cette API")
return False, " Impossible de se connecter"
'''
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
On controle que les champs obligatoires sont presents dans la liste
'''
field_list_obligatoire = ['token', 'image_recid']
for val in field_list_obligatoire:
if str(val).lower() not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans liste des champs")
return False, "Impossible de se connecter"
mydata = {}
mytoken = ""
# recuperation des paramettre
if ("token" in diction.keys()):
if diction['token']:
mytoken = diction['token']
image_recid = ""
if ("image_recid" in diction.keys()):
if diction['image_recid']:
image_recid = diction['image_recid']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
# " Lecture du fichier "
# print(" Lecture du fichier : " + saved_file + ". le token est :" + str(mytoken))
nb_line = 0
coll_name = MYSY_GV.dbname['mysy_images']
query_delete = {"recid": image_recid,}
ret_val = coll_name.delete_one({"recid": image_recid,}, )
print(" ### recordClassImage_v2 :L'image a été correctement supprimée ")
return True, "L'image a été correctement supprimée"
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))
return False, "Impossible de supprimer l'image "