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
56a02f0f
Commit
56a02f0f
authored
1 year ago
by
Daniil Digtyar Vasilieva
Browse files
Options
Downloads
Patches
Plain Diff
[IMP] energy_selfconsumption: constraint of contract lines with the same period
parent
d76201f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
energy_selfconsumption/wizards/invoicing_wizard.py
+18
-1
18 additions, 1 deletion
energy_selfconsumption/wizards/invoicing_wizard.py
with
18 additions
and
1 deletion
energy_selfconsumption/wizards/invoicing_wizard.py
+
18
−
1
View file @
56a02f0f
from
odoo
import
_
,
fields
,
models
from
odoo
import
_
,
api
,
fields
,
models
from
odoo.exceptions
import
ValidationError
class
InvoicingWizard
(
models
.
TransientModel
):
...
...
@@ -7,6 +8,22 @@ class InvoicingWizard(models.TransientModel):
power
=
fields
.
Float
(
string
=
"
Total Energy Generated (kWh)
"
)
contract_ids
=
fields
.
Many2many
(
"
contract.contract
"
)
@api.constrains
(
"
contract_ids
"
)
def
constraint_contract_ids
(
self
):
for
record
in
self
:
contract_list
=
record
.
contract_ids
all_equal_period
=
all
(
element
.
next_period_date_start
==
contract_list
[
0
].
next_period_date_start
and
element
.
next_period_date_end
==
contract_list
[
0
].
next_period_date_end
for
element
in
contract_list
)
if
not
all_equal_period
:
raise
ValidationError
(
_
(
"
Select only contracts with the same period of invoicing.
"
)
)
def
generate_invoices
(
self
):
return
self
.
with_context
(
{
"
energy_delivered
"
:
self
.
power
}
...
...
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