Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
O
oacc_perimeter_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
Afficher davantage de fils d'Ariane
Le Filament
Opération Auto-Consommation Collective
oacc_perimeter_api
Validations
fbae1c54
Valider
fbae1c54
rédigé
Il y a 3 semaines
par
Julien - Le Filament
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[UPD] refactoring
parent
60cdbfd4
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é
models/acc_operation.py
+26
-121
26 ajouts, 121 suppressions
models/acc_operation.py
avec
26 ajouts
et
121 suppressions
models/acc_operation.py
+
26
−
121
Voir le fichier @
fbae1c54
...
...
@@ -6,7 +6,6 @@ from enum import Enum
from
odoo
import
_
,
api
,
fields
,
models
from
odoo.exceptions
import
AccessError
,
UserError
,
ValidationError
from
odoo.osv
import
expression
from
odoo.tools
import
html_sanitize
from
odoo.addons.api_enedis_acc.tools.elo_enums
import
EloCode
...
...
@@ -474,6 +473,17 @@ class AccOperation(models.Model):
log_id
.
send_enedis_perimeter_email
()
return
log_id
def
_update_with_same_date
(
self
,
period
,
tLogData
):
tLogData
[
"
message
"
]
=
"
Pas de changement
"
tLogData
[
"
log_type
"
]
=
GetPerimeterEvent
.
NO_CHANGE
return
period
def
_update_with_end_date_change
(
self
,
period
,
usage_point_end
,
tLogData
):
period
.
end_date
=
usage_point_end
tLogData
[
"
message
"
]
=
"
Changement de la date de sortie du PRM
"
tLogData
[
"
log_type
"
]
=
GetPerimeterEvent
.
PRM_OUT
return
period
def
update_existing_counter
(
self
,
counter_id
,
...
...
@@ -485,20 +495,23 @@ class AccOperation(models.Model):
counter_period_ids
=
counter_id
.
period_ids
.
filtered
(
lambda
p
:
p
.
prm_type
==
usage_point_prm_type
)
if
counter_period_ids
.
filtered
(
period
=
counter_period_ids
.
filtered
(
lambda
p
:
p
.
start_date
==
usage_point_start
and
p
.
end_date
==
usage_point_end
):
tLogData
[
"
message
"
]
=
"
Pas de changement
"
tLogData
[
"
log_type
"
]
=
GetPerimeterEvent
.
NO_CHANGE
)
if
period
:
return
self
.
_update_with_same_date
(
period
=
period
,
tLogData
=
tLogData
)
elif
counter_period_ids
.
filtered
(
lambda
p
:
p
.
start_date
==
usage_point_start
):
counter_period_ids
.
filtered
(
period
=
counter_period_ids
.
filtered
(
lambda
p
:
p
.
start_date
==
usage_point_start
).
end_date
=
usage_point_end
tLogData
[
"
message
"
]
=
"
Changement de la date de sortie du PRM
"
tLogData
[
"
log_type
"
]
=
GetPerimeterEvent
.
PRM_OUT
)
return
self
.
_update_with_end_date_change
(
period
=
period
,
usage_point_end
=
usage_point_end
,
tLogData
=
tLogData
)
else
:
self
.
env
[
"
acc.counter.period
"
].
create
(
period
=
self
.
env
[
"
acc.counter.period
"
].
create
(
{
"
acc_counter_id
"
:
counter_id
.
id
,
"
prm_type
"
:
usage_point_prm_type
,
...
...
@@ -522,6 +535,7 @@ class AccOperation(models.Model):
"
Vérifier le paramétrage de la clé de répartition le cas échéant
"
,
"
Donner éventuellement au participant l
'
accès au portail Elocoop
"
,
]
return
period
def
add_new_counter
(
self
,
...
...
@@ -557,22 +571,6 @@ class AccOperation(models.Model):
}
)
# ajout acc.price.conf se fait désormais lors de la création de la période
self
.
check_sale_price_conf
(
counter_id
=
counter_id
,
periode_start_date
=
usage_point_start
)
# If delivery counter add to first priority group if exist
b_added
=
False
if
usage_point_prm_type
==
"
delivery
"
:
if
self
.
check_priority_groups
(
counter
=
counter_id
):
b_added
=
True
# ajout au premier groupe de priorité par défaut
# en fonction du type de clé de répartition de l'opération
# se fera désormais lors de la création de la période
tLogData
[
"
action
"
]
=
[
"
Ajouter, si ce n
'
est pas déjà le cas,
"
"
le participant dans l
'
onglet Participants de l
'
opération
"
,
...
...
@@ -584,14 +582,11 @@ class AccOperation(models.Model):
),
"
Indiquer si nécessaire le prix de vente pour ce PRM
"
,
]
if
b_added
:
tLogData
[
"
action
"
].
append
(
"
Vérifier le paramétrage de la clé de répartition si nécessaire,
"
"
le nouveau PRM a été ajouté par défaut au premier groupe de priorité
"
,
)
tLogData
[
"
action
"
].
append
(
"
Donner éventuellement au participant l
'
accès au portail Elocoop
"
,
)
return
counter_id
def
update_date_start_contract
(
self
,
usage_point_start
):
if
not
self
.
date_start_contract
or
self
.
date_start_contract
>
usage_point_start
:
...
...
@@ -601,93 +596,3 @@ class AccOperation(models.Model):
# ------------------------------------------------------
# Business methods
# ------------------------------------------------------
def
check_priority_groups
(
self
,
counter
):
"""
add new counter to first priorirty group if exist counter
"""
first_prio
=
self
.
env
[
"
acc.priority.group
"
].
search
(
[(
"
acc_operation_id
"
,
"
=
"
,
self
.
id
),
(
"
sequence
"
,
"
=
"
,
1
)]
)
if
first_prio
:
first_prio
.
add_counter
(
counter_id
=
counter
)
return
True
return
False
def
check_sale_price_conf_for_delivery_counter
(
self
,
counter_id
,
periode_start_date
):
if
self
.
use_default_sale_price
:
domain
=
[
(
"
acc_operation_id
"
,
"
=
"
,
self
.
id
),
(
"
prm_type
"
,
"
=
"
,
"
injection
"
),
]
date_end_domain
=
expression
.
OR
(
[
[(
"
end_date
"
,
"
>=
"
,
periode_start_date
)],
[(
"
end_date
"
,
"
=
"
,
False
)],
]
)
domain
=
expression
.
AND
([
domain
,
date_end_domain
])
inj_periods
=
self
.
env
[
"
acc.counter.period
"
].
search
(
domain
)
for
inj_period
in
inj_periods
:
if
counter_id
.
type
==
"
del_inj
"
:
price
=
self
.
sale_price_by_default
else
:
price
=
inj_period
.
sale_price
if
price
==
0.0
:
# ex: compteur d'injection ajouté récemment
price
=
self
.
sale_price_by_default
if
price
>
0.0
:
self
.
env
[
"
acc.price.conf
"
].
create
(
{
"
start_date
"
:
inj_period
.
start_date
,
"
acc_operation_id
"
:
self
.
id
,
"
acc_injection_counter_id
"
:
inj_period
.
acc_counter_id
.
id
,
"
acc_delivery_counter_id
"
:
counter_id
.
id
,
"
price
"
:
price
,
"
type
"
:
"
sale
"
,
}
)
def
check_sale_price_conf_for_injection_counter
(
self
,
counter_id
,
periode_start_date
):
if
self
.
use_default_sale_price
and
self
.
sale_price_by_default
>
0.0
:
domain
=
[(
"
acc_operation_id
"
,
"
=
"
,
self
.
id
),
(
"
prm_type
"
,
"
=
"
,
"
delivery
"
)]
date_end_domain
=
expression
.
OR
(
[
[(
"
end_date
"
,
"
>=
"
,
periode_start_date
)],
[(
"
end_date
"
,
"
=
"
,
False
)],
]
)
domain
=
expression
.
AND
([
domain
,
date_end_domain
])
del_periods
=
self
.
env
[
"
acc.counter.period
"
].
search
(
domain
)
for
del_period
in
del_periods
:
self
.
env
[
"
acc.price.conf
"
].
create
(
{
"
start_date
"
:
periode_start_date
,
"
acc_operation_id
"
:
self
.
id
,
"
acc_injection_counter_id
"
:
counter_id
.
id
,
"
acc_delivery_counter_id
"
:
del_period
.
acc_counter_id
.
id
,
"
price
"
:
self
.
sale_price_by_default
,
"
type
"
:
"
sale
"
,
}
)
def
check_sale_price_conf
(
self
,
counter_id
,
periode_start_date
):
"""
create sale price conf on new counter
"""
if
counter_id
.
type
in
[
"
del
"
,
"
del_inj
"
]:
self
.
check_sale_price_conf_for_delivery_counter
(
counter_id
,
periode_start_date
)
elif
counter_id
.
type
in
[
"
inj
"
]:
self
.
check_sale_price_conf_for_injection_counter
(
counter_id
,
periode_start_date
)
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