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
2734373c
Commit
2734373c
authored
1 year ago
by
ebuzeyTra
Browse files
Options
Downloads
Patches
Plain Diff
Constraint separated to improve the performance
parent
85f856fa
No related branches found
No related tags found
2 merge requests
!195
[REL] 14.0.2.0.0
,
!181
Feature/add constrain to spa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
energy_selfconsumption/models/supply_point_assignation.py
+8
-2
8 additions, 2 deletions
energy_selfconsumption/models/supply_point_assignation.py
with
8 additions
and
2 deletions
energy_selfconsumption/models/supply_point_assignation.py
+
8
−
2
View file @
2734373c
from
odoo
import
fields
,
models
,
api
from
odoo
import
fields
,
models
,
api
,
_
from
odoo.exceptions
import
ValidationError
...
...
@@ -51,7 +51,13 @@ class SupplyPointAssignation(models.Model):
def
constraint_coefficient
(
self
):
for
record
in
self
:
if
record
.
coefficient
<
0
:
raise
ValidationError
(
"
Coefficient can
'
t be negative.
"
)
raise
ValidationError
(
_
(
"
Coefficient can
'
t be negative.
"
))
@api.constrains
(
"
owner_id
"
)
def
constraint_coefficient
(
self
):
for
record
in
self
:
if
record
.
owner_id
and
not
record
.
owner_id
.
member
:
raise
ValidationError
(
_
(
"
The selected partner is not a member
"
))
@api.onchange
(
'
coefficient
'
)
def
_onchange_coefficient
(
self
):
...
...
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