Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oacc_repartition_keys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Le Filament
Opération Auto-Consommation Collective
oacc_repartition_keys
Commits
34b4536c
Commit
34b4536c
authored
1 month ago
by
Stéphane - Enercoop
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] api.depends, store total_share and counter_percentage
parent
901a58a9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
models/acc_priority_group.py
+2
-2
2 additions, 2 deletions
models/acc_priority_group.py
models/acc_priority_group_counter.py
+2
-4
2 additions, 4 deletions
models/acc_priority_group_counter.py
with
4 additions
and
6 deletions
models/acc_priority_group.py
+
2
−
2
View file @
34b4536c
...
...
@@ -33,7 +33,7 @@ class AccPriorityGroup(models.Model):
)
counter_datas
=
fields
.
Json
(
compute
=
"
_compute_counter_datas
"
)
total_share
=
fields
.
Float
(
compute
=
"
_compute_total_share
"
,
store
=
Fals
e
)
total_share
=
fields
.
Float
(
compute
=
"
_compute_total_share
"
,
store
=
Tru
e
)
# ------------------------------------------------------
# SQL Constraints
# ------------------------------------------------------
...
...
@@ -45,7 +45,7 @@ class AccPriorityGroup(models.Model):
# ------------------------------------------------------
# Computed fields / Search Fields
# ------------------------------------------------------
@api.depends
(
"
acc_priority_group_counter_ids
"
)
@api.depends
(
"
acc_priority_group_counter_ids
"
,
"
acc_priority_group_counter_ids.acc_counter_share
"
)
def
_compute_total_share
(
self
):
for
record
in
self
:
record
.
total_share
=
sum
(
...
...
This diff is collapsed.
Click to expand it.
models/acc_priority_group_counter.py
+
2
−
4
View file @
34b4536c
...
...
@@ -47,7 +47,7 @@ class AccPriorityGroupCounter(models.Model):
related
=
"
acc_priority_group_id.type_algo
"
,
readonly
=
True
)
acc_counter_percentage
=
fields
.
Float
(
compute
=
"
_compute_acc_counter_percentage
"
,
store
=
Fals
e
compute
=
"
_compute_acc_counter_percentage
"
,
store
=
Tru
e
)
# ------------------------------------------------------
...
...
@@ -62,9 +62,7 @@ class AccPriorityGroupCounter(models.Model):
# Computed fields / Search Fields
# ------------------------------------------------------
@api.depends
(
"
acc_priority_group_id.acc_priority_group_counter_ids
"
,
"
acc_counter_share
"
)
@api.depends
(
"
acc_priority_group_id.total_share
"
)
def
_compute_acc_counter_percentage
(
self
):
for
record
in
self
:
total_share
=
record
.
acc_priority_group_id
.
total_share
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment