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
Merge requests
!179
new constrains added
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
new constrains added
feature/add-inscription-constraint
into
dev
Overview
6
Commits
5
Pipelines
5
Changes
1
All threads resolved!
Hide all comments
Merged
emanuel buzey
requested to merge
feature/add-inscription-constraint
into
dev
1 year ago
Overview
6
Commits
5
Pipelines
5
Changes
1
All threads resolved!
Hide all comments
Expand
Enlace
a la card de Trello
Edited
1 year ago
by
emanuel buzey
0
0
Merge request reports
Viewing commit
56cb6815
Prev
Next
Show latest version
1 file
+
4
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
56cb6815
Revert "Constranins added to SupplyPointAssignation model"
· 56cb6815
ebuzeyTra
authored
1 year ago
This reverts commit
9d746900
.
energy_selfconsumption/models/supply_point_assignation.py
+
4
−
6
Options
from
odoo
import
api
,
fields
,
models
,
_
from
odoo
import
fields
,
models
,
api
from
odoo.exceptions
import
ValidationError
@@ -36,15 +36,13 @@ class SupplyPointAssignation(models.Model):
company_id
=
fields
.
Many2one
(
"
res.company
"
,
default
=
lambda
self
:
self
.
env
.
company
,
readonly
=
True
)
@api.constrains
(
"
coefficient
"
,
"
owner_id
"
)
@api.constrains
(
'
coefficient
'
)
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
"
))
if
record
.
coefficient
<
0
:
raise
ValidationError
(
_
(
"
Coefficient can
'
t be negative.
"
)
)
raise
ValidationError
(
"
Coefficient can
'
t be negative.
"
)
@api.onchange
(
"
coefficient
"
)
@api.onchange
(
'
coefficient
'
)
def
_onchange_coefficient
(
self
):
if
self
.
coefficient
<
0
:
self
.
coefficient
=
-
self
.
coefficient
Loading