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
cf5ba05e
Commit
cf5ba05e
authored
1 year ago
by
Emanuel Buzey
Committed by
Daniil Digtyar Vasilieva
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[REF] energy_selfconsumption: move action to change state to active to wizard
parent
4629e32b
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
+18
-3
18 additions, 3 deletions
energy_selfconsumption/models/selfconsumption.py
energy_selfconsumption/wizards/contract_generation_wizard.py
+5
-0
5 additions, 0 deletions
energy_selfconsumption/wizards/contract_generation_wizard.py
with
23 additions
and
3 deletions
energy_selfconsumption/models/selfconsumption.py
+
18
−
3
View file @
cf5ba05e
...
...
@@ -107,6 +107,24 @@ class Selfconsumption(models.Model):
self
.
distribution_table_state
(
"
validated
"
,
"
process
"
)
def
activate
(
self
):
"""
Activates the energy self-consumption project, performing various validations.
This method checks for the presence of a valid code, CIL, and rated power
for the project. If all validations pass, it opens a wizard for generating
contracts for the project.
Note:
The change of state for the
'
self-consumption
'
and
'
distribution_table
'
models is performed in the wizard that gets opened. These state changes
are executed only after the contracts have been successfully generated.
Returns:
dict: A dictionary containing the action details for opening the wizard.
Raises:
ValidationError: If the project does not have a valid Code, CIL, or Rated Power.
"""
for
record
in
self
:
if
not
record
.
code
:
raise
ValidationError
(
_
(
"
Project must have a valid Code.
"
))
...
...
@@ -124,9 +142,6 @@ class Selfconsumption(models.Model):
"
target
"
:
"
new
"
,
"
context
"
:
{
"
default_selfconsumption_id
"
:
self
.
id
},
}
# Move state write to contract wizard
# record.write({"state": "active"})
# self.distribution_table_state("process", "active")
def
action_selfconsumption_import_wizard
(
self
):
self
.
ensure_one
()
...
...
This diff is collapsed.
Click to expand it.
energy_selfconsumption/wizards/contract_generation_wizard.py
+
5
−
0
View file @
cf5ba05e
...
...
@@ -39,6 +39,8 @@ class ContractGenerationWizard(models.TransientModel):
It first creates a product and a contract formula. It then
aggregates supply point assignations by partner and owner
to generate the contracts.
In the other hand, if the process was successful, the state of self-consumption
and the distribution_table changes to
'
active
'
.
Returns:
bool: Always True, indicating successful execution.
...
...
@@ -134,4 +136,7 @@ class ContractGenerationWizard(models.TransientModel):
}
)
# Update selfconsumption and distribution_table state
self
.
selfconsumption_id
.
write
({
"
state
"
:
"
active
"
})
self
.
selfconsumption_id
.
distribution_table_state
(
"
process
"
,
"
active
"
)
return
True
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