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
550bdcbd
Valider
550bdcbd
rédigé
8 juin 2022
par
Juliana
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[FIX]Error merge conflict
parent
51cf1474
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
+8
-7
8 ajouts, 7 suppressions
services/auth_services.py
services/operation_services.py
+56
-20
56 ajouts, 20 suppressions
services/operation_services.py
avec
64 ajouts
et
27 suppressions
services/auth_services.py
+
8
−
7
Voir le fichier @
550bdcbd
...
...
@@ -276,7 +276,7 @@ class AuthService(Component):
return
{}
@restapi.method
(
[([
"
/m
y-account
"
],
"
GET
"
)],
[([
"
/m
on-compte
"
],
"
GET
"
)],
input_param
=
restapi
.
CerberusValidator
(
"
_validator_get_my_account
"
),
output_param
=
restapi
.
CerberusValidator
(
"
_validator_return_my_account
"
),
cors
=
"
*
"
,
...
...
@@ -284,17 +284,18 @@ class AuthService(Component):
)
def
get_my_account
(
self
):
user_id
=
self
.
env
[
"
res.users
"
].
browse
(
self
.
request
.
uid
)
user
=
{
"
company
"
:
user_id
.
partner_id
.
parent_id
.
name
,
"
company
"
:
user_id
.
partner_id
.
parent_id
.
name
or
""
,
"
name
"
:
user_id
.
name
,
"
firstname
"
:
user_id
.
firstname
,
"
firstname
"
:
user_id
.
firstname
or
""
,
"
lastname
"
:
user_id
.
lastname
,
"
login
"
:
user_id
.
login
,
}
return
user
@restapi.method
(
[([
"
/m
y-account
"
],
"
POST
"
)],
[([
"
/m
on-compte
"
],
"
POST
"
)],
input_param
=
restapi
.
CerberusValidator
(
"
_validator_set_my_account
"
),
output_param
=
restapi
.
CerberusValidator
(
"
_validator_return_my_account
"
),
cors
=
"
*
"
,
...
...
@@ -311,9 +312,9 @@ class AuthService(Component):
}
)
user
=
{
"
company
"
:
user_id
.
partner_id
.
parent_id
.
name
,
"
company
"
:
user_id
.
partner_id
.
parent_id
.
name
or
""
,
"
name
"
:
user_id
.
name
,
"
firstname
"
:
user_id
.
firstname
,
"
firstname
"
:
user_id
.
firstname
or
""
,
"
lastname
"
:
user_id
.
lastname
,
"
login
"
:
user_id
.
login
,
}
...
...
@@ -411,7 +412,7 @@ class AuthService(Component):
"
login
"
:
{
"
type
"
:
"
string
"
},
"
firstname
"
:
{
"
type
"
:
"
string
"
,
"
nullable
"
:
True
},
"
lastname
"
:
{
"
type
"
:
"
string
"
,
"
nullable
"
:
True
},
"
name
"
:
{
"
type
"
:
"
string
"
},
"
name
"
:
{
"
type
"
:
"
string
"
,
"
nullable
"
:
True
},
"
company
"
:
{
"
type
"
:
"
string
"
,
"
nullable
"
:
True
},
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
services/operation_services.py
+
56
−
20
Voir le fichier @
550bdcbd
# © 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import
base64
from
datetime
import
datetime
from
odoo
import
SUPERUSER_ID
from
odoo.exceptions
import
AccessError
from
odoo.http
import
content_disposition
,
request
from
odoo.addons.base_rest
import
restapi
from
odoo.addons.component.core
import
Component
...
...
@@ -106,6 +103,27 @@ class OperationsService(Component):
power_tot
=
(
0
,
0
)
cons_rate
=
prod_rate
=
0
nb_conso
=
(
self
.
env
[
"
acc.counter
"
]
.
sudo
()
.
search_count
(
[
(
"
acc_operation_id
"
,
"
=
"
,
operation
.
id
),
(
"
is_delivery
"
,
"
=
"
,
True
),
]
)
)
nb_prod
=
(
self
.
env
[
"
acc.counter
"
]
.
sudo
()
.
search_count
(
[
(
"
acc_operation_id
"
,
"
=
"
,
operation
.
id
),
(
"
is_injection
"
,
"
=
"
,
True
),
]
)
)
datas
=
{
"
role
"
:
role
,
"
id
"
:
operation
.
id
,
...
...
@@ -121,8 +139,8 @@ class OperationsService(Component):
if
operation
.
distribution_key
else
None
,
"
pmo
"
:
operation
.
sudo
().
pmo_id
.
name
,
"
consumer_nb
"
:
len
(
operation
.
sudo
().
acc_delivery_ids
)
,
"
productor_nb
"
:
len
(
operation
.
sudo
().
acc_injection_ids
)
,
"
consumer_nb
"
:
nb_conso
,
"
productor_nb
"
:
nb_prod
,
"
power_install
"
:
power_install
,
"
image
"
:
operation
.
image_256
.
decode
(
"
utf-8
"
)
if
operation
.
image_256
...
...
@@ -162,13 +180,12 @@ class OperationsService(Component):
"""
operation
=
self
.
env
[
"
acc.operation
"
].
browse
(
_id
)
role
=
self
.
_get_role
(
operation
)
base_url
=
self
.
env
[
'
ir.config_parameter
'
].
sudo
().
get_param
(
'
web.base.url
'
)
base_url
=
self
.
env
[
"
ir.config_parameter
"
].
sudo
().
get_param
(
"
web.base.url
"
)
if
not
role
.
get
(
"
isIn
"
):
return
AccessError
()
type
=
self
.
request
.
params
.
get
(
"
type
"
,
False
)
self
.
request
.
params
.
get
(
"
type
"
,
False
)
datas
=
{
"
role
"
:
role
,
...
...
@@ -192,21 +209,36 @@ class OperationsService(Component):
}
)
if
acc_account_ids
else
[]
else
:
# Récupération de toutes les factures liées à l'opération spécifiée
acc_account_ids
=
self
.
env
[
"
acc.account
"
].
search
(
[(
"
acc_operation_id
"
,
"
=
"
,
_id
)]
)
datas
[
"
documents
"
]
=
acc_account_ids
.
mapped
(
lambda
n
:
{
"
id
"
:
n
.
id
,
"
name
"
:
n
.
name
,
"
date
"
:
n
.
date
,
"
start_date
"
:
n
.
start_date
,
"
end_date
"
:
n
.
end_date
,
"
amount_total
"
:
n
.
amount_total
,
"
url
"
:
base_url
+
n
.
get_portal_url
(
report_type
=
"
pdf
"
),
}
)
# Récupération de toutes les factures liées à l'opération spécifiée
domain
=
[(
"
acc_operation_id
"
,
"
=
"
,
_id
)]
domain_pmo
=
[(
"
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
(
"
isConsumer
"
)
or
role
.
get
(
"
isProductor
"
):
domain
+=
[(
"
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_ids
=
self
.
env
[
"
acc.contract
"
].
sudo
().
search
(
domain
)
datas
[
"
contracts
"
]
=
acc_contract_ids
.
mapped
(
lambda
n
:
{
datas
[
"
contracts
"
]
=
acc_contract_ids
.
mapped
(
lambda
n
:
{
"
id
"
:
n
.
id
,
"
name
"
:
n
.
name
,
"
start_date
"
:
n
.
start_date
,
...
...
@@ -215,6 +247,8 @@ class OperationsService(Component):
"
url
"
:
base_url
+
n
.
get_portal_url
(),
}
)
if
acc_contract_ids
else
[]
}
)
return
datas
@restapi.method
(
...
...
@@ -625,6 +659,7 @@ class OperationsService(Component):
"
id
"
:
{
"
type
"
:
"
integer
"
},
"
name
"
:
{
"
type
"
:
"
string
"
},
"
documents
"
:
{
"
nullable
"
:
True
,
"
type
"
:
"
list
"
,
"
schema
"
:
{
"
type
"
:
"
dict
"
,
...
...
@@ -640,6 +675,7 @@ class OperationsService(Component):
},
},
"
contracts
"
:
{
"
nullable
"
:
True
,
"
type
"
:
"
list
"
,
"
schema
"
:
{
"
type
"
:
"
dict
"
,
...
...
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