Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odoo CE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Comunitats Energètiques
Odoo CE
Commits
8f66ba95
Commit
8f66ba95
authored
1 year ago
by
Emanuel Buzey
Committed by
Daniil Digtyar Vasilieva
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[ADD] energy_selfconsumption: add contract stat button
parent
cf5ba05e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!253
[REL] Release 06/11/23
,
!211
[IMP] energy_selfconsumption: invoicing acquired power
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
energy_selfconsumption/models/selfconsumption.py
+19
-0
19 additions, 0 deletions
energy_selfconsumption/models/selfconsumption.py
energy_selfconsumption/views/selfconsumption_views.xml
+16
-0
16 additions, 0 deletions
energy_selfconsumption/views/selfconsumption_views.xml
with
35 additions
and
0 deletions
energy_selfconsumption/models/selfconsumption.py
+
19
−
0
View file @
8f66ba95
...
...
@@ -20,6 +20,13 @@ class Selfconsumption(models.Model):
for
record
in
self
:
record
.
inscription_count
=
len
(
record
.
inscription_ids
)
def
_compute_contract_count
(
self
):
for
record
in
self
:
related_contracts
=
self
.
env
[
"
contract.contract
"
].
search
(
[(
"
name
"
,
"
ilike
"
,
record
.
name
)]
)
self
.
contracts_count
=
len
(
related_contracts
)
def
_compute_report_distribution_table
(
self
):
"""
This compute field gets the distribution table needed to generate the reports.
...
...
@@ -68,6 +75,7 @@ class Selfconsumption(models.Model):
"
energy_project.inscription
"
,
"
project_id
"
,
readonly
=
True
)
inscription_count
=
fields
.
Integer
(
compute
=
_compute_inscription_count
)
contracts_count
=
fields
.
Integer
(
compute
=
_compute_contract_count
)
def
get_distribution_tables
(
self
):
self
.
ensure_one
()
...
...
@@ -91,6 +99,17 @@ class Selfconsumption(models.Model):
"
context
"
:
{
"
create
"
:
True
,
"
default_project_id
"
:
self
.
id
},
}
def
get_contracts
(
self
):
self
.
ensure_one
()
return
{
"
type
"
:
"
ir.actions.act_window
"
,
"
name
"
:
"
Contracts
"
,
"
view_mode
"
:
"
tree,form
"
,
"
res_model
"
:
"
contract.contract
"
,
"
domain
"
:
[(
"
name
"
,
"
ilike
"
,
self
.
name
)],
"
context
"
:
{
"
create
"
:
True
,
"
default_project_id
"
:
self
.
id
},
}
def
distribution_table_state
(
self
,
actual_state
,
new_state
):
distribution_table_to_activate
=
self
.
distribution_table_ids
.
filtered
(
lambda
table
:
table
.
state
==
actual_state
...
...
This diff is collapsed.
Click to expand it.
energy_selfconsumption/views/selfconsumption_views.xml
+
16
−
0
View file @
8f66ba95
...
...
@@ -106,6 +106,22 @@
widget=
"statinfo"
/>
</button>
<button
class=
"oe_stat_button"
type=
"object"
name=
"get_contracts"
icon=
"fa-files-o"
attrs=
"{'invisible': [('state', '!=', 'active')]}"
>
<field
string=
"Contracts"
name=
"contracts_count"
widget=
"statinfo"
/>
</button>
</div>
<widget
name=
"web_ribbon"
...
...
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