08/09/2023 - 18h30

master
cherif 2023-09-08 18:39:05 +02:00
parent c92fc99a1e
commit 15be3e0c0c
3 changed files with 1575 additions and 45 deletions

View File

@ -4,9 +4,7 @@
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="07/09/2023 - 14h">
<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$/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$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,8 @@ def Add_Partner_Order(diction):
'order_header_adr_liv_adresse', 'order_header_adr_liv_code_postal', 'order_header_adr_liv_ville', 'order_header_adr_liv_pays',
'order_header_condition_paiement', 'order_header_ref_client', 'order_header_vendeur_id',
'order_header_ref_interne', 'order_header_total_ht', 'order_header_total_tax', 'order_header_total_ttc', 'order_header_status', 'order_header_type_reduction',
'order_header_type_reduction_valeur', 'order_header_montant_reduction', 'order_lines', 'order_header_type']
'order_header_type_reduction_valeur', 'order_header_montant_reduction', 'order_lines', 'order_header_type',
'order_header_location_type']
"""
/!\ A noter que "order_lines" est tableau [] qui peut contenir les keys suivantes : 'order_line_formation', 'order_line_qty', 'order_line_prix_unitaire', 'order_line_tax', 'order_line_type_reduction', 'order_line_type_valeur', 'order_line_montant_reduction'
@ -187,6 +188,18 @@ def Add_Partner_Order(diction):
return False, " - Le champ 'ref_externe' fait plus de 255 caractères "
data['order_header_ref_externe'] = diction['order_header_ref_externe']
order_header_location_type = ""
if ("order_header_location_type" in diction.keys()):
if diction['order_header_location_type']:
order_header_location_type = diction['order_header_location_type']
if (len(str(order_header_location_type)) > 255):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_location_type' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_location_type' fait plus de 255 caractères "
data['order_header_location_type'] = diction['order_header_location_type']
order_header_vendeur_id = ""
if ("order_header_vendeur_id" in diction.keys()):
@ -456,6 +469,8 @@ def Add_Partner_Order(diction):
order_line['locked'] = '0'
order_line['date_update'] = str(datetime.now())
order_line['partner_owner_recid'] = my_partner['recid']
order_line['order_line_type'] = "commande"
order_line['order_line_status'] = data['order_header_status']
inserted_line_id = ""
inserted_line_id = MYSY_GV.dbname['partner_order_line'].insert_one(order_line).inserted_id
@ -495,7 +510,7 @@ def Add_Partner_Quotation(diction):
'order_header_ref_interne', 'order_header_total_ht', 'order_header_total_tax',
'order_header_total_ttc', 'order_header_status', 'order_header_type_reduction',
'order_header_type_reduction_valeur', 'order_header_montant_reduction', 'order_lines',
'order_header_type']
'order_header_type', 'order_header_location_type']
"""
/!\ A noter que "order_lines" est tableau [] qui peut contenir les keys suivantes : 'order_line_formation', 'order_line_qty', 'order_line_prix_unitaire', 'order_line_tax', 'order_line_type_reduction', 'order_line_type_valeur', 'order_line_montant_reduction'
@ -581,6 +596,20 @@ def Add_Partner_Quotation(diction):
else:
data['order_header_status'] = "0"
order_header_location_type = ""
if ("order_header_location_type" in diction.keys()):
if diction['order_header_location_type']:
order_header_location_type = diction['order_header_location_type']
if (len(str(order_header_location_type)) > 255):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_location_type' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_location_type' fait plus de 255 caractères "
data['order_header_location_type'] = diction['order_header_location_type']
order_header_comment = ""
if ("order_header_comment" in diction.keys()):
if diction['order_header_comment']:
@ -894,6 +923,8 @@ def Add_Partner_Quotation(diction):
order_line['locked'] = '0'
order_line['date_update'] = str(datetime.now())
order_line['partner_owner_recid'] = my_partner['recid']
order_line['order_line_type'] = "devis"
order_line['order_line_status'] = data['order_header_status']
inserted_line_id = ""
inserted_line_id = MYSY_GV.dbname['partner_order_line'].insert_one(order_line).inserted_id
@ -934,7 +965,7 @@ def Update_Partner_Order_Header(diction):
'order_header_ref_interne', 'order_header_total_ht', 'order_header_total_tax',
'order_header_total_ttc', 'order_header_status', 'order_header_type_reduction',
'order_header_type_reduction_valeur', 'order_header_montant_reduction',
'order_header_id', 'order_header_type']
'order_header_id', 'order_header_type', 'order_header_location_type']
@ -1040,6 +1071,17 @@ def Update_Partner_Order_Header(diction):
return False, " - Le champ 'Statut' est invalide. Les valeurs acceptées "+str(MYSY_GV.PARTNER_ORDER_STATUS)
data['order_header_status'] = diction['order_header_status']
order_header_location_type = ""
if ("order_header_location_type" in diction.keys()):
order_header_location_type = diction['order_header_location_type']
if (len(str(order_header_location_type)) > 255):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_location_type' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_location_type' fait plus de 255 caractères "
data['order_header_location_type'] = diction['order_header_location_type']
order_header_comment = ""
if ("order_header_comment" in diction.keys()):
@ -1288,7 +1330,8 @@ def Update_Partner_Order_Header(diction):
'order_header_id': str(order_header_id)
},
{
"$set": {"order_line_status": str(order_header_status), 'date_update':str(data['date_update'])}
"$set": {"order_line_status": str(order_header_status), "order_line_type": str(my_order_data_previous_information['order_header_type']),
'date_update':str(data['date_update'])}
})
"""print("raw:", inserted_data_line.raw_result)
print("acknowledged:", inserted_data_line.acknowledged)
@ -1300,7 +1343,8 @@ def Update_Partner_Order_Header(diction):
'order_header_id': str(order_header_id)
},
{
"$set": {"order_line_status": str(order_header_status), 'date_update': str(data['date_update'])}
"$set": {"order_line_status": str(order_header_status), "order_line_type": str(my_order_data_previous_information['order_header_type']),
'date_update': str(data['date_update'])}
})
"""print("raw:", inserted_data_line.raw_result)
print("acknowledged:", inserted_data_line.acknowledged)
@ -1334,7 +1378,7 @@ def Update_Partner_Quotation_Header(diction):
'order_header_ref_interne', 'order_header_total_ht', 'order_header_total_tax',
'order_header_total_ttc', 'order_header_status', 'order_header_type_reduction',
'order_header_type_reduction_valeur', 'order_header_montant_reduction',
'order_header_id', 'order_header_type']
'order_header_id', 'order_header_type', 'order_header_location_type']
incom_keys = diction.keys()
for val in incom_keys:
@ -1444,6 +1488,17 @@ def Update_Partner_Quotation_Header(diction):
data['order_header_status'] = diction['order_header_status']
order_header_location_type = ""
if ("order_header_location_type" in diction.keys()):
order_header_location_type = diction['order_header_location_type']
if (len(str(order_header_location_type)) > 255):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Le champ 'order_header_location_type' fait plus de 255 caractères ")
return False, " - Le champ 'order_header_location_type' fait plus de 255 caractères "
data['order_header_location_type'] = diction['order_header_location_type']
order_header_comment = ""
if ("order_header_comment" in diction.keys()):
order_header_comment = diction['order_header_comment']
@ -1692,7 +1747,8 @@ def Update_Partner_Quotation_Header(diction):
'order_header_id': str(order_header_id)
},
{
"$set": {"order_line_status": str(order_header_status), 'date_update': str(data['date_update'])}
"$set": {"order_line_status": str(order_header_status), "order_line_type": str(my_order_data_previous_information['order_header_type']),
'date_update': str(data['date_update'])}
})
"""print("raw:", inserted_data_line.raw_result)
print("acknowledged:", inserted_data_line.acknowledged)
@ -1705,7 +1761,8 @@ def Update_Partner_Quotation_Header(diction):
'order_header_id': str(order_header_id)
},
{
"$set": {"order_line_status": str(order_header_status), 'date_update': str(data['date_update'])}
"$set": {"order_line_status": str(order_header_status), "order_line_type": str(my_order_data_previous_information['order_header_type']),
'date_update': str(data['date_update'])}
})
"""print("raw:", inserted_data_line.raw_result)
print("acknowledged:", inserted_data_line.acknowledged)
@ -1736,7 +1793,7 @@ def Add_Update_Partner_Order_Line(diction):
field_list = ['token', 'order_line_formation', 'order_line_qty', 'order_line_prix_unitaire',
'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_header_id', 'order_line_status', 'order_line_type', 'order_line_comment']
incom_keys = diction.keys()
for val in incom_keys:
@ -1858,6 +1915,18 @@ def Add_Update_Partner_Order_Line(diction):
order_header_ref_interne = diction['order_header_ref_interne']
data['order_header_ref_interne'] = order_header_ref_interne
order_line_comment = ""
if ("order_line_comment" in diction.keys()):
if diction['order_line_comment']:
order_line_comment = diction['order_line_comment']
data['order_line_comment'] = order_line_comment
if(len(str(order_line_comment)) > 500):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Le champ 'order_line_comment' fait plus de 500 caractères ")
return False, " - Le champ 'Commentaire de la ligne' fait plus de 500 caractères "
order_header_id = ""
if ("order_header_id" in diction.keys()):
if diction['order_header_id']:
@ -1866,31 +1935,30 @@ def Add_Update_Partner_Order_Line(diction):
order_line_id = ""
if ("order_line_id" in diction.keys()):
if diction['order_line_id']:
# il s'agit de mettre à jour la ligne. Il faut verifier que la ligne existe et est modifiable
order_line_id = diction['order_line_id']
existe_order_line_count = MYSY_GV.dbname['partner_order_line'].count_documents({'_id':ObjectId(str(order_line_id)), 'valide':'1', 'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if ("order_line_id" in diction.keys() and len(str(diction['order_line_id'])) > 0 ) :
# il s'agit de mettre à jour la ligne. Il faut verifier que la ligne existe et est modifiable
order_line_id = diction['order_line_id']
existe_order_line_count = MYSY_GV.dbname['partner_order_line'].count_documents({'_id':ObjectId(str(order_line_id)), 'valide':'1', 'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( existe_order_line_count != 1 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La ligne à mettre à jour est invalide")
return False, "La ligne à mettre à jour est invalide",
if( existe_order_line_count != 1 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La ligne à mettre à jour est invalide")
return False, "La ligne à mettre à jour est invalide",
data['date_update'] = str(datetime.now())
inserted_data = MYSY_GV.dbname['ressource_humaine_affectation'].find_one_and_update(
{'_id': ObjectId(str(order_line_id)), 'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])},
{"$set": data},
return_document=ReturnDocument.AFTER,
upsert=False,
)
data['date_update'] = str(datetime.now())
inserted_data = MYSY_GV.dbname['partner_order_line'].find_one_and_update(
{'_id': ObjectId(str(order_line_id)), 'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])},
{"$set": data},
return_document=ReturnDocument.AFTER,
upsert=False,
)
if (inserted_data is None):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Impossible de mettre à jour la ligne (3)")
return False, " Impossible de mettre à jour la ligne (3) "
if (inserted_data is None):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Impossible de mettre à jour la ligne (3)")
return False, " Impossible de mettre à jour la ligne (3) "
else:
@ -1917,6 +1985,7 @@ def Add_Update_Partner_Order_Line(diction):
"""
Fonction de suppression d'une commande client (entete et ligne) si son statut le permet en prenant le '_id'
"""
@ -2362,14 +2431,78 @@ def Get_Given_Partner_Order_Lines(diction):
RetObject = []
val_tmp = 1
#print(" ### data_cle = ", data_cle)
for retval in MYSY_GV.dbname['partner_order_line'].find(data_cle):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
filt_order_header_id = {'order_header_id': str(diction['order_header_id'])}
query = [{'$match': {'$and': [ filt_order_header_id,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup':
{
'from': 'myclass',
'localField': 'order_line_formation',
'foreignField': 'internal_url',
'pipeline': [{'$match': {'$and': [ filt_class_partner_recid]}},
{'$project': {'title': 1, 'domaine': 1,
'duration': 1,
'duration_unit': 1}}],
'as': 'myclass_collection'
}
}
]
print("#### Get_Given_Partner_Order_Lines : query pip= ", query)
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
if ('myclass_collection' in retval.keys() and len(retval['myclass_collection']) > 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']
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['myclass_collection'][0]['title']
user['domaine'] = retval['myclass_collection'][0]['domaine']
user['duration'] = retval['myclass_collection'][0]['duration']
user['duration_unit'] = retval['myclass_collection'][0]['duration_unit']
if (str(retval['myclass_collection'][0]['duration_unit']) == "heure"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " h"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "jour"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " j"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "semaine"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " s"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "mois"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " m"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "annee"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " a"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "user_rythme"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " u"
else:
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " ?"
RetObject.append(mycommon.JSONEncoder().encode(user))
RetObject.append(mycommon.JSONEncoder().encode(user))
#print(" ### RetObject = ", RetObject)
return True, RetObject
@ -2437,14 +2570,77 @@ def Get_Given_Partner_Order_Lines_From_order_ref_interne(diction):
RetObject = []
val_tmp = 1
#print(" ### data_cle = ", data_cle)
for retval in MYSY_GV.dbname['partner_order_line'].find(data_cle):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
filt_order_header_ref_interne = {'order_header_ref_interne': str(diction['order_header_ref_interne'])}
query = [{'$match': {'$and': [filt_order_header_ref_interne,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup':
{
'from': 'myclass',
'localField': 'order_line_formation',
'foreignField': 'internal_url',
'pipeline': [{'$match': {'$and': [ filt_class_partner_recid]}},
{'$project': {'title': 1, 'domaine': 1,
'duration': 1,
'duration_unit': 1}}],
'as': 'myclass_collection'
}
}
]
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 ('myclass_collection' in retval.keys() and len(retval['myclass_collection']) > 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']
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['myclass_collection'][0]['title']
user['domaine'] = retval['myclass_collection'][0]['domaine']
user['duration'] = retval['myclass_collection'][0]['duration']
user['duration_unit'] = retval['myclass_collection'][0]['duration_unit']
if (str(retval['myclass_collection'][0]['duration_unit']) == "heure"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " h"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "jour"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " j"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "semaine"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " s"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "mois"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " m"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "annee"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " a"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "user_rythme"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " u"
else:
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " ?"
RetObject.append(mycommon.JSONEncoder().encode(user))
RetObject.append(mycommon.JSONEncoder().encode(user))
#print(" ### RetObject = ", RetObject)
return True, RetObject