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
4725b2a3
Valider
4725b2a3
rédigé
14 sept. 2022
par
Juliana
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[UPD]Update arborescence documents
parent
02024baa
Branches
Branches contenant la validation
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
services/operation_services.py
+48
-84
48 ajouts, 84 suppressions
services/operation_services.py
avec
48 ajouts
et
84 suppressions
services/operation_services.py
+
48
−
84
Voir le fichier @
4725b2a3
...
...
@@ -192,71 +192,65 @@ class OperationsService(Component):
"
id
"
:
operation
.
id
,
"
name
"
:
operation
.
name
,
}
if
type
==
"
invoice
"
:
# 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
),
(
"
state
"
,
"
=
"
,
"
published
"
)]
)
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
"
),
}
)
if
acc_account_ids
else
[]
)
# Récupération de toutes les factures externes
# liées à l'opération spécifiée
domain
=
[(
"
acc_operation_id
"
,
"
=
"
,
_id
)]
domain
+=
[
(
"
type
"
,
"
=
"
,
"
facture
"
),
]
acc_contract_ids
=
self
.
env
[
"
acc.contract
"
].
search
(
domain
)
datas
[
"
factures_externes
"
]
=
(
acc_contract_ids
.
mapped
(
acc_contract_ids_f
=
self
.
env
[
"
acc.contract
"
].
search
(
domain
)
invoice_exist
=
False
if
acc_contract_ids_f
or
acc_account_ids
:
invoice_exist
=
True
# Récupération de tous les contrats liés à l'opération spécifiée
domain_c
=
[(
"
acc_operation_id
"
,
"
=
"
,
_id
)]
domain_pmo
=
[(
"
acc_operation_id
"
,
"
=
"
,
_id
)]
role
=
self
.
_get_role
(
operation
)
if
role
.
get
(
"
isConsumer
"
)
or
role
.
get
(
"
isProductor
"
):
domain_c
+=
[
(
"
type
"
,
"
!=
"
,
"
convention
"
),
(
"
type
"
,
"
!=
"
,
"
all
"
),
(
"
type
"
,
"
!=
"
,
False
),
]
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_ids
=
self
.
env
[
"
acc.contract
"
].
search
(
domain_c
)
acc_contract_ids
+=
acc_contract_all
contract_exist
=
False
if
acc_contract_ids
:
contract_exist
=
True
if
type
==
"
invoice
"
and
invoice_exist
:
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
,
"
type
"
:
n
.
type
,
"
url
"
:
base_url
+
n
.
get_portal_url
(),
"
amount_total
"
:
n
.
amount_total
,
"
url
"
:
base_url
+
n
.
get_portal_url
(
report_type
=
"
pdf
"
),
}
)
if
acc_
contrac
t_ids
if
acc_
accoun
t_ids
else
[]
)
elif
type
==
"
other
"
:
# Récupération de tous les contrats liés à l'opération spécifiée
domain
=
[(
"
acc_operation_id
"
,
"
=
"
,
_id
)]
role
=
self
.
_get_role
(
operation
)
# if role.get("isConsumer") or role.get("isProductor"):
# domain += [
# ("type", "!=", "convention"),
# ("type", "!=", "all"),
# ("type", "!=", False),
# ]
# 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
([
(
"
acc_operation_id
"
,
"
=
"
,
_id
),
(
"
type
"
,
"
=
"
,
"
all
"
),
])
# acc_contract_ids = self.env["acc.contract"].search(domain)
# acc_contract_ids += acc_contract_all
datas
[
"
other
"
]
=
(
acc_contract_ids
.
mapped
(
datas
[
"
factures_externes
"
]
=
(
acc_contract_ids
_f
.
mapped
(
lambda
n
:
{
"
id
"
:
n
.
id
,
"
name
"
:
n
.
name
,
...
...
@@ -266,29 +260,10 @@ class OperationsService(Component):
"
url
"
:
base_url
+
n
.
get_portal_url
(),
}
)
if
acc_contract_ids
if
acc_contract_ids
_f
else
[]
)
else
:
# Récupération de tous les contrats liés à 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
"
)
or
role
.
get
(
"
isProductor
"
):
domain
+=
[
(
"
type
"
,
"
!=
"
,
"
convention
"
),
(
"
type
"
,
"
!=
"
,
"
all
"
),
(
"
type
"
,
"
!=
"
,
False
),
]
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_ids
=
self
.
env
[
"
acc.contract
"
].
search
(
domain
)
# acc_contract_ids += acc_contract_all
elif
type
==
"
contract
"
or
(
not
invoice_exist
and
contract_exist
):
datas
[
"
contracts
"
]
=
(
acc_contract_ids
.
mapped
(
...
...
@@ -304,6 +279,8 @@ class OperationsService(Component):
if
acc_contract_ids
else
[]
)
datas
[
"
contract_exist
"
]
=
contract_exist
datas
[
"
invoice_exist
"
]
=
invoice_exist
return
datas
@restapi.method
(
...
...
@@ -751,6 +728,8 @@ class OperationsService(Component):
},
},
"
id
"
:
{
"
type
"
:
"
integer
"
},
"
invoice_exist
"
:
{
"
type
"
:
"
boolean
"
},
"
contract_exist
"
:
{
"
type
"
:
"
boolean
"
},
"
name
"
:
{
"
type
"
:
"
string
"
},
"
documents
"
:
{
"
nullable
"
:
True
,
...
...
@@ -798,21 +777,6 @@ class OperationsService(Component):
},
},
},
"
other
"
:
{
"
nullable
"
:
True
,
"
type
"
:
"
list
"
,
"
schema
"
:
{
"
type
"
:
"
dict
"
,
"
schema
"
:
{
"
id
"
:
{
"
type
"
:
"
integer
"
},
"
name
"
:
{
"
type
"
:
"
string
"
},
"
type
"
:
{
"
type
"
:
"
string
"
,
"
nullable
"
:
True
},
"
url
"
:
{
"
type
"
:
"
string
"
,
"
nullable
"
:
True
},
"
seller
"
:
{
"
type
"
:
"
string
"
,
"
nullable
"
:
True
},
"
buyer
"
:
{
"
type
"
:
"
string
"
,
"
nullable
"
:
True
},
},
},
},
}
def
_validator_get_pmo
(
self
):
...
...
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