Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
A
acc_rest_api
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Ce projet est archivé. Le dépôt et les autres ressources du projet sont en lecture seule.
Afficher davantage de fils d'Ariane
Le Filament
Opération Auto-Consommation Collective
acc_rest_api
Validations
1a5de4b7
Valider
1a5de4b7
rédigé
Il y a 3 ans
par
Juliana
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[UPD]Pass pre commit
parent
a8a0d9b9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
services/auth_services.py
+40
-28
40 ajouts, 28 suppressions
services/auth_services.py
services/operation_services.py
+19
-10
19 ajouts, 10 suppressions
services/operation_services.py
avec
59 ajouts
et
38 suppressions
services/auth_services.py
+
40
−
28
Voir le fichier @
1a5de4b7
...
@@ -2,11 +2,10 @@
...
@@ -2,11 +2,10 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import
logging
import
logging
import
werkzeug
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
import
jwt
import
jwt
import
werkzeug
from
odoo.addons.base_rest
import
restapi
from
odoo.addons.base_rest
import
restapi
from
odoo.addons.component.core
import
Component
from
odoo.addons.component.core
import
Component
...
@@ -95,7 +94,8 @@ class AuthService(Component):
...
@@ -95,7 +94,8 @@ class AuthService(Component):
if
user
:
if
user
:
jwt_validator
=
self
.
env
.
ref
(
"
acc_rest_api.elo_validator
"
).
sudo
()
jwt_validator
=
self
.
env
.
ref
(
"
acc_rest_api.elo_validator
"
).
sudo
()
exp
=
datetime
.
now
()
+
timedelta
(
exp
=
datetime
.
now
()
+
timedelta
(
hours
=
(
jwt_validator
.
token_expiration
*
24
))
hours
=
(
jwt_validator
.
token_expiration
*
24
)
)
payload
=
{
payload
=
{
"
aud
"
:
jwt_validator
.
audience
,
"
aud
"
:
jwt_validator
.
audience
,
"
iss
"
:
jwt_validator
.
issuer
,
"
iss
"
:
jwt_validator
.
issuer
,
...
@@ -111,14 +111,16 @@ class AuthService(Component):
...
@@ -111,14 +111,16 @@ class AuthService(Component):
)
)
datas
=
{
datas
=
{
# "user": user_datas,
# "user": user_datas,
"
token
"
:
{
"
access_token
"
:
token
,
"
token
"
:
{
"
expiration_date
"
:
payload
.
get
(
"
exp
"
)},
"
access_token
"
:
token
,
"
expiration_date
"
:
payload
.
get
(
"
exp
"
),
},
}
}
# send email to users with their signup url
# send email to users with their signup url
template
=
False
template
=
False
if
not
template
:
if
not
template
:
template
=
self
.
env
.
ref
(
'
acc_portal.acc_reset_password_email
'
)
template
=
self
.
env
.
ref
(
"
acc_portal.acc_reset_password_email
"
)
assert
template
.
_name
==
'
mail.template
'
assert
template
.
_name
==
"
mail.template
"
# template.sudo().write(template_values)
# template.sudo().write(template_values)
try
:
try
:
...
@@ -126,26 +128,29 @@ class AuthService(Component):
...
@@ -126,26 +128,29 @@ class AuthService(Component):
lang
=
user
.
lang
lang
=
user
.
lang
query
=
dict
(
db
=
self
.
request
.
env
.
cr
.
dbname
)
query
=
dict
(
db
=
self
.
request
.
env
.
cr
.
dbname
)
query
[
'
login
'
]
=
user
.
login
query
[
"
login
"
]
=
user
.
login
route
=
'
signup
'
route
=
"
signup
"
signup_url
=
"
/%s?%s
"
%
(
route
,
werkzeug
.
urls
.
url_encode
(
query
))
signup_url
=
"
/%s?%s
"
%
(
route
,
werkzeug
.
urls
.
url_encode
(
query
))
signup_url
=
werkzeug
.
urls
.
url_join
(
user
.
company_id
.
url_app
,
signup_url
)
signup_url
=
werkzeug
.
urls
.
url_join
(
user
.
company_id
.
url_app
,
signup_url
)
user
.
partner_id
.
sudo
().
signup_prepare
()
user
.
partner_id
.
sudo
().
signup_prepare
()
template
.
sudo
().
with_context
(
template
.
sudo
().
with_context
(
portal_url
=
signup_url
,
portal_url
=
signup_url
,
lang
=
lang
lang
=
lang
).
send_mail
(
user
.
id
,
force_send
=
True
,
raise_exception
=
True
)
).
send_mail
(
user
.
id
,
force_send
=
True
,
raise_exception
=
True
)
except
Exception
as
e
:
except
Exception
as
e
:
datas
[
'
error
'
]
=
str
(
e
)
datas
[
"
error
"
]
=
str
(
e
)
_logger
.
info
(
"
Password reset email sent for user <%s> to <%s>
"
,
_logger
.
info
(
user
.
login
,
user
.
email
)
"
Password reset email sent for user <%s> to <%s>
"
,
user
.
login
,
user
.
email
,
)
else
:
else
:
datas
[
'
info
'
]
=
"
Veuillez réinitialiser votre mot de passe: adresse email incorrecte
"
datas
[
"
info
"
]
=
"
Veuillez réinitialiser votre mot de passe: adresse email incorrecte
"
return
datas
return
datas
@restapi.method
(
@restapi.method
(
...
@@ -195,9 +200,11 @@ class AuthService(Component):
...
@@ -195,9 +200,11 @@ class AuthService(Component):
user
=
User
.
search
([(
"
login
"
,
"
=
"
,
login
)])
user
=
User
.
search
([(
"
login
"
,
"
=
"
,
login
)])
if
user
:
if
user
:
if
password
==
confirm_password
:
if
password
==
confirm_password
:
user
.
write
({
'
password
'
:
password
})
user
.
write
({
"
password
"
:
password
})
else
:
else
:
datas
[
'
error
'
]
=
"
Les mots de passe ne correspondent pas, veuillez les saisir à nouveau.
"
datas
[
"
error
"
]
=
"
Les mots de passe ne correspondent pas, veuillez les saisir à nouveau.
"
return
datas
return
datas
@restapi.method
(
@restapi.method
(
...
@@ -229,7 +236,8 @@ class AuthService(Component):
...
@@ -229,7 +236,8 @@ class AuthService(Component):
if
password
==
confirm_password
:
if
password
==
confirm_password
:
jwt_validator
=
self
.
env
.
ref
(
"
acc_rest_api.elo_validator
"
).
sudo
()
jwt_validator
=
self
.
env
.
ref
(
"
acc_rest_api.elo_validator
"
).
sudo
()
exp
=
datetime
.
now
()
+
timedelta
(
exp
=
datetime
.
now
()
+
timedelta
(
hours
=
(
jwt_validator
.
token_expiration
*
24
))
hours
=
(
jwt_validator
.
token_expiration
*
24
)
)
payload
=
{
payload
=
{
"
aud
"
:
jwt_validator
.
audience
,
"
aud
"
:
jwt_validator
.
audience
,
"
iss
"
:
jwt_validator
.
issuer
,
"
iss
"
:
jwt_validator
.
issuer
,
...
@@ -245,12 +253,16 @@ class AuthService(Component):
...
@@ -245,12 +253,16 @@ class AuthService(Component):
)
)
datas
=
{
datas
=
{
"
user
"
:
user_datas
,
"
user
"
:
user_datas
,
"
token
"
:
{
"
access_token
"
:
token
,
"
token
"
:
{
"
expiration_date
"
:
payload
.
get
(
"
exp
"
)},
"
access_token
"
:
token
,
"
expiration_date
"
:
payload
.
get
(
"
exp
"
),
},
}
}
user
.
write
({
'
password
'
:
password
})
user
.
write
({
"
password
"
:
password
})
else
:
else
:
datas
[
"
error
"
]
=
"
Les mots de passe ne correspondent pas, veuillez les saisir à nouveau.
"
datas
[
"
error
"
]
=
"
Les mots de passe ne correspondent pas, veuillez les saisir à nouveau.
"
datas
[
"
user
"
]
=
user_datas
datas
[
"
user
"
]
=
user_datas
return
datas
return
datas
...
@@ -427,6 +439,6 @@ class AuthService(Component):
...
@@ -427,6 +439,6 @@ class AuthService(Component):
"
access_token
"
:
{
"
type
"
:
"
string
"
,
"
nullable
"
:
True
},
"
access_token
"
:
{
"
type
"
:
"
string
"
,
"
nullable
"
:
True
},
"
expiration_date
"
:
{
"
type
"
:
"
datetime
"
,
"
nullable
"
:
True
},
"
expiration_date
"
:
{
"
type
"
:
"
datetime
"
,
"
nullable
"
:
True
},
},
},
"
nullable
"
:
True
"
nullable
"
:
True
,
},
},
}
}
Ce diff est replié.
Cliquez pour l'agrandir.
services/operation_services.py
+
19
−
10
Voir le fichier @
1a5de4b7
...
@@ -175,8 +175,8 @@ class OperationsService(Component):
...
@@ -175,8 +175,8 @@ class OperationsService(Component):
}
}
if
type
==
"
invoice
"
:
if
type
==
"
invoice
"
:
# Récupération de toutes les factures liées à l'opération spécifiée
# Récupération de toutes les factures liées à l'opération spécifiée
acc_account_ids
=
(
acc_account_ids
=
self
.
env
[
"
acc.account
"
].
search
(
self
.
env
[
"
acc.account
"
].
search
(
[(
"
acc_operation_id
"
,
"
=
"
,
_id
)]
)
[(
"
acc_operation_id
"
,
"
=
"
,
_id
)]
)
)
datas
[
"
documents
"
]
=
[]
datas
[
"
documents
"
]
=
[]
...
@@ -192,9 +192,15 @@ class OperationsService(Component):
...
@@ -192,9 +192,15 @@ class OperationsService(Component):
datas
[
"
documents
"
].
append
(
val
)
datas
[
"
documents
"
].
append
(
val
)
else
:
else
:
# Récupération de toutes les factures liées à l'opération spécifiée
# Récupération de toutes les factures liées à l'opération spécifiée
acc_contract_ids
=
(
domain
=
[(
"
acc_operation_id
"
,
"
=
"
,
_id
)]
self
.
env
[
"
acc.contract
"
].
search
([(
"
acc_operation_id
"
,
"
=
"
,
_id
)])
role
=
self
.
_get_role
(
operation
)
)
if
role
.
get
(
"
isConsumer
"
):
domain
+=
[(
"
type
"
,
"
=
"
,
"
achat
"
)]
if
role
.
get
(
"
isProductor
"
):
domain
+=
[(
"
type
"
,
"
=
"
,
"
vente
"
)]
if
role
.
get
(
"
isPmo
"
):
domain
+=
[(
"
type
"
,
"
!=
"
,
False
)]
acc_contract_ids
=
self
.
env
[
"
acc.contract
"
].
search
(
domain
)
datas
[
"
contracts
"
]
=
[]
datas
[
"
contracts
"
]
=
[]
for
n
in
acc_contract_ids
:
for
n
in
acc_contract_ids
:
...
@@ -224,9 +230,9 @@ class OperationsService(Component):
...
@@ -224,9 +230,9 @@ class OperationsService(Component):
if
invoice
:
if
invoice
:
invoice_sudo
=
invoice
.
with_user
(
SUPERUSER_ID
).
exists
()
invoice_sudo
=
invoice
.
with_user
(
SUPERUSER_ID
).
exists
()
report_sudo
=
request
.
env
.
ref
(
"
acc_account.acc_account_invoices
"
).
with_user
(
report_sudo
=
request
.
env
.
ref
(
SUPERUSER_ID
"
acc_account.acc_account_invoices
"
)
)
.
with_user
(
SUPERUSER_ID
)
pdf
=
report_sudo
.
_render_qweb_pdf
(
pdf
=
report_sudo
.
_render_qweb_pdf
(
[
invoice_sudo
.
id
],
data
=
{
"
report_type
"
:
"
pdf
"
}
[
invoice_sudo
.
id
],
data
=
{
"
report_type
"
:
"
pdf
"
}
...
@@ -237,7 +243,9 @@ class OperationsService(Component):
...
@@ -237,7 +243,9 @@ class OperationsService(Component):
(
"
Content-Length
"
,
len
(
pdf
)),
(
"
Content-Length
"
,
len
(
pdf
)),
]
]
filename
=
"
Facture.pdf
"
filename
=
"
Facture.pdf
"
reporthttpheaders
.
append
((
"
Content-Disposition
"
,
content_disposition
(
filename
)))
reporthttpheaders
.
append
(
(
"
Content-Disposition
"
,
content_disposition
(
filename
))
)
return
request
.
make_response
(
b64_pdf
)
return
request
.
make_response
(
b64_pdf
)
else
:
else
:
contract_id
=
self
.
request
.
params
.
get
(
"
invoice_id
"
,
False
)
contract_id
=
self
.
request
.
params
.
get
(
"
invoice_id
"
,
False
)
...
@@ -250,7 +258,8 @@ class OperationsService(Component):
...
@@ -250,7 +258,8 @@ class OperationsService(Component):
]
]
filename
=
"
Contrat.pdf
"
filename
=
"
Contrat.pdf
"
reporthttpheaders
.
append
(
reporthttpheaders
.
append
(
(
"
Content-Disposition
"
,
content_disposition
(
filename
)))
(
"
Content-Disposition
"
,
content_disposition
(
filename
))
)
return
request
.
make_response
(
contract_sudo
.
document
)
return
request
.
make_response
(
contract_sudo
.
document
)
@restapi.method
(
@restapi.method
(
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter