From 0275e5e4ea37401910a8a500daaaf0b5e5d23965 Mon Sep 17 00:00:00 2001 From: Juliana <juliana@le-filament.com> Date: Thu, 1 Dec 2022 12:45:11 +0100 Subject: [PATCH] [UPD]Add date log info on contact --- services/auth_services.py | 7 +++++++ services/operation_services.py | 34 +++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/services/auth_services.py b/services/auth_services.py index 049562b..20b2315 100644 --- a/services/auth_services.py +++ b/services/auth_services.py @@ -70,6 +70,8 @@ class AuthService(Component): "user": user_datas, "token": {"access_token": token, "expiration_date": payload.get("exp")}, } + # Mise à jour de la date de connexion + user_id.partner_id.write({"date_log": datetime.now()}) return datas # A faire pour gestion User @@ -179,6 +181,8 @@ class AuthService(Component): user = { "login": user_id.login, } + # Mise à jour de la date de connexion + user.partner_id.write({"date_log": datetime.now()}) return user @restapi.method( @@ -201,6 +205,7 @@ class AuthService(Component): if user: if password == confirm_password: user.write({"password": password}) + user.partner_id.write({"date_log": datetime.now()}) else: datas[ "error" @@ -259,6 +264,8 @@ class AuthService(Component): }, } user.write({"password": password}) + # Mise à jour de la date de connexion + user.partner_id.write({"date_log": datetime.now()}) else: datas[ "error" diff --git a/services/operation_services.py b/services/operation_services.py index dda3235..792f0fa 100644 --- a/services/operation_services.py +++ b/services/operation_services.py @@ -215,22 +215,33 @@ class OperationsService(Component): role = self._get_role(operation) if role.get("isConsumer") or role.get("isProductor"): domain_c += [ - '|', ("type", "=", "other"), + "|", + ("type", "=", "other"), ("type", "=", "vente_achat"), ] if role.get("isPmo"): domain_pmo += [("type", "!=", False)] acc_contract_ids = self.env["acc.contract"].sudo().search(domain_pmo) else: - acc_contract_all = self.env["acc.contract"].sudo().search([ - ("acc_operation_id", "=", _id), ("type", "=", "all"), - ]) + acc_contract_all = ( + self.env["acc.contract"] + .sudo() + .search( + [ + ("acc_operation_id", "=", _id), + ("type", "=", "all"), + ] + ) + ) acc_contract_ids = self.env["acc.contract"].search(domain_c) acc_contract_ids += acc_contract_all - acc_contract_pmo = self.env["acc.contract"].search([ - ("acc_operation_id", "=", _id), ("type", "=", "pmo"), - ]) + acc_contract_pmo = self.env["acc.contract"].search( + [ + ("acc_operation_id", "=", _id), + ("type", "=", "pmo"), + ] + ) acc_contract_ids += acc_contract_pmo contract_exist = False if acc_contract_ids: @@ -378,8 +389,9 @@ class OperationsService(Component): domain_prm.append( ("partner_id", "in", [partner_id.id, partner_id.parent_id.id]) ) - prm_ids = self.env["acc.counter"].sudo().search( - domain_prm, order="partner_id asc") + prm_ids = ( + self.env["acc.counter"].sudo().search(domain_prm, order="partner_id asc") + ) prm_name = prm_ids.mapped( lambda p: { @@ -397,7 +409,7 @@ class OperationsService(Component): ) if role.get("isConsumer") and not role.get("isPmo") and not prm_id: - consumer_id = consumer_name[0]['id'] + consumer_id = consumer_name[0]["id"] if operation.is_data_enedis: if scale: graph_datas = operation.graph_view_type( @@ -619,7 +631,7 @@ class OperationsService(Component): "role": role, "id": operation.id, "name": operation.name, - "email": operation.sudo().pmo_id.mail_contact_pmo + "email": operation.sudo().pmo_id.mail_contact_pmo, } return datas -- GitLab