Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
A
acc_account
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_account
Validations
343c8186
Valider
343c8186
rédigé
24 févr. 2022
par
Juliana
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[ADD]Take account unterval price invoice
parent
7f3ce080
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
models/acc_operation.py
+56
-29
56 ajouts, 29 suppressions
models/acc_operation.py
views/acc_operation_views.xml
+2
-2
2 ajouts, 2 suppressions
views/acc_operation_views.xml
views/acc_sale_price_views.xml
+2
-2
2 ajouts, 2 suppressions
views/acc_sale_price_views.xml
avec
60 ajouts
et
33 suppressions
models/acc_operation.py
+
56
−
29
Voir le fichier @
343c8186
...
...
@@ -72,10 +72,11 @@ class AccOperation(models.Model):
]
return
action
def
get_power_by_cons
(
self
,
date_start
,
date_end
):
def
get_power_by_cons
(
self
,
acc_delivery_id
,
date_start
,
date_end
):
power_tab_by_cons
=
self
.
env
[
'
acc.enedis.cdc
'
].
read_group
(
[(
'
acc_operation_id
'
,
'
=
'
,
self
.
id
),
(
'
acc_counter_id
'
,
'
=
'
,
acc_delivery_id
.
id
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
<=
'
,
date_end
),
(
'
comp_data_type
'
,
'
=
'
,
'
cons
'
)],
...
...
@@ -121,44 +122,70 @@ class AccOperation(models.Model):
for
acc_injection_id
in
self
.
acc_injection_ids
:
if
acc_injection_id
.
is_account_auto_activate
:
for
acc_delivery_id
in
self
.
acc_delivery_ids
:
power_tab_by_prod
=
self
.
get_power_by_prod
(
acc_injection_id
,
date_start
,
date_end
)
power_autoprod_percent
=
((
power_tab_by_prod
[
0
][
'
power
'
]
-
power_tab_by_prod
[
1
][
'
power
'
])
*
100
)
/
prod_tot
power_tab_by_cons
=
self
.
get_power_by_cons
(
date_start
,
date_end
)
for
power_cons
in
power_tab_by_cons
:
power_month
=
(
power_cons
[
'
power
'
]
/
1000
/
2
)
*
(
power_autoprod_percent
/
100
)
price_kwh
=
self
.
env
[
'
acc.sale.price
'
].
search
([
(
'
acc_operation_id
'
,
'
=
'
,
self
.
id
),
(
'
acc_injection_id
'
,
'
=
'
,
acc_injection_id
.
id
),
(
'
acc_delivery_id
'
,
'
=
'
,
power_cons
[
'
acc_counter_id
'
][
0
]),
(
'
start_date
'
,
'
<=
'
,
date_month
),
(
'
end_date
'
,
'
>=
'
,
date_month
)
]).
price
power_autoprod_percent
=
((
power_tab_by_prod
[
0
][
'
power
'
]
-
power_tab_by_prod
[
1
][
'
power
'
])
*
100
)
/
prod_tot
power_tab_by_cons
=
self
.
get_power_by_cons
(
acc_delivery_id
,
date_start
,
date_end
)
power_total
=
(
power_tab_by_cons
[
0
][
'
power
'
]
/
1000
/
2
)
*
(
power_autoprod_percent
/
100
)
Account
=
self
.
env
[
'
acc.account
'
]
AccountLine
=
self
.
env
[
'
acc.account.line
'
]
acc_account
=
Account
.
create
({
'
acc_operation_id
'
:
self
.
id
,
'
acc_injection_id
'
:
acc_injection_id
.
id
,
'
acc_delivery_id
'
:
power_cons
[
'
acc_count
er_id
'
][
0
]
,
'
power_cons
'
:
power_
month
,
'
acc_delivery_id
'
:
acc_deliv
er
y
_id
.
id
,
'
power_cons
'
:
power_
total
,
'
start_date
'
:
date_start
,
'
end_date
'
:
date_end
,
'
price_kwh
'
:
price_kwh
,
'
tax_tcfe
'
:
self
.
tax_tcfe
,
})
# Création de la ligne du mois
price_ids
=
self
.
env
[
'
acc.sale.price
'
].
search
([
(
'
acc_operation_id
'
,
'
=
'
,
self
.
id
),
(
'
acc_injection_id
'
,
'
=
'
,
acc_injection_id
.
id
),
(
'
acc_delivery_id
'
,
'
=
'
,
acc_delivery_id
.
id
),
'
|
'
,
(
'
start_date
'
,
'
<=
'
,
date_start
),
(
'
end_date
'
,
'
>=
'
,
date_end
)
])
price2_ids
=
self
.
env
[
'
acc.sale.price
'
].
search
([
(
'
acc_operation_id
'
,
'
=
'
,
self
.
id
),
(
'
acc_injection_id
'
,
'
=
'
,
acc_injection_id
.
id
),
(
'
acc_delivery_id
'
,
'
=
'
,
acc_delivery_id
.
id
),
(
'
start_date
'
,
'
>
'
,
date_start
),
(
'
end_date
'
,
'
<=
'
,
date_end
)
])
interval_ids
=
price_ids
+
price2_ids
for
interval
in
interval_ids
:
if
date_start
>
interval
.
start_date
:
date_interval_start
=
date_start
else
:
date_interval_start
=
interval
.
start_date
if
date_end
<
interval
.
end_date
:
date_interval_end
=
date_end
else
:
date_interval_end
=
interval
.
end_date
power_tab_by_prod
=
self
.
get_power_by_prod
(
acc_injection_id
,
date_interval_start
,
date_interval_end
)
power_autoprod_percent
=
((
power_tab_by_prod
[
0
][
'
power
'
]
-
power_tab_by_prod
[
1
][
'
power
'
])
*
100
)
/
prod_tot
power_tab_by_cons
=
self
.
get_power_by_cons
(
acc_delivery_id
,
date_interval_start
,
date_interval_end
)
power_total
=
(
power_tab_by_cons
[
0
][
'
power
'
]
/
1000
/
2
)
*
(
power_autoprod_percent
/
100
)
AccountLine
=
self
.
env
[
'
acc.account.line
'
]
# Création de la ligne de facture par intervalle de période de prix
acc_account_line
=
AccountLine
.
create
({
'
quantity
'
:
power_
month
,
'
price_unit
'
:
price
_kwh
,
'
quantity
'
:
power_
total
,
'
price_unit
'
:
interval
.
price
,
'
acc_account_id
'
:
acc_account
.
id
,
'
start_date
'
:
date_start
,
'
end_date
'
:
date_end
,
'
description
'
:
'
Facture pour le mois de
'
+
date_
month
.
strftime
(
"
%B
"
)
'
start_date
'
:
date_
interval_
start
,
'
end_date
'
:
date_
interval_
end
,
'
description
'
:
'
Période du
'
+
str
(
date_
interval_start
)
+
'
au
'
+
str
(
date_interval_end
)
})
account_list
.
append
(
acc_account
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
views/acc_operation_views.xml
+
2
−
2
Voir le fichier @
343c8186
...
...
@@ -56,9 +56,9 @@
attrs=
"{'invisible': [('is_account_active', '=', False)]}"
/>
</header>
<field
name=
"acc_sale_price_ids"
widget=
"one2many"
>
<tree
editable=
"bottom"
>
<field
name=
"acc_delivery_id"
/>
<tree
editable=
"bottom"
default_order=
"acc_injection_id,acc_delivery_id,start_date desc"
>
<field
name=
"acc_injection_id"
/>
<field
name=
"acc_delivery_id"
/>
<field
name=
"start_date"
/>
<field
name=
"end_date"
/>
<field
name=
"currency_id"
invisible=
"1"
/>
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
views/acc_sale_price_views.xml
+
2
−
2
Voir le fichier @
343c8186
...
...
@@ -32,10 +32,10 @@
<field
name=
"name"
>
acc.acc_sale_price.tree
</field>
<field
name=
"model"
>
acc.sale.price
</field>
<field
name=
"arch"
type=
"xml"
>
<tree
string=
"Prix de vente"
>
<tree
string=
"Prix de vente"
default_order=
"start_date desc"
>
<field
name=
"acc_operation_id"
/>
<field
name=
"acc_delivery_id"
/>
<field
name=
"acc_injection_id"
/>
<field
name=
"acc_delivery_id"
/>
<field
name=
"start_date"
/>
<field
name=
"end_date"
/>
<field
name=
"currency_id"
invisible=
"1"
/>
...
...
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