Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
d4fb0385
Commit
d4fb0385
authored
Apr 22, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "ERP5: Remove getVariationValue/setVariationValue"
This reverts commit 73cfdb0f66502e1f969ee6dc119ce8fbc6205470.
parent
0018c7cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
1 deletion
+113
-1
product/ERP5/Document/Amount.py
product/ERP5/Document/Amount.py
+26
-0
product/ERP5/VariationValue.py
product/ERP5/VariationValue.py
+76
-0
product/ERP5/interfaces/variated.py
product/ERP5/interfaces/variated.py
+1
-1
product/ERP5/mixin/variated.py
product/ERP5/mixin/variated.py
+10
-0
No files found.
product/ERP5/Document/Amount.py
View file @
d4fb0385
...
...
@@ -32,6 +32,7 @@ from collections import defaultdict
from
math
import
log
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5.mixin.variated
import
VariatedMixin
from
Products.ERP5.VariationValue
import
VariationValue
from
Products.ERP5Type
import
Permissions
,
PropertySheet
,
interfaces
from
Products.ERP5Type.Base
import
Base
from
Products.CMFCategory.Renderer
import
Renderer
...
...
@@ -46,6 +47,9 @@ class Amount(Base, VariatedMixin):
A mix-in class which provides some utilities
(variations, conversions, etc.)
Utilities include
- getVariation accesors (allows to access variations of whatever)
-
"""
...
...
@@ -184,6 +188,28 @@ class Amount(Base, VariatedMixin):
self
.
getVariationBaseCategoryList
(),
display_id
=
display_id
,
**
kw
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getVariationValue'
)
def
getVariationValue
(
self
):
"""
New Method for dicrete and countinuous variations
using a VariantValue instance
A new instance of VariationValue is created with categories
and attributes set to what they should be.
A this point, we only implement discrete variations
"""
return
VariationValue
(
context
=
self
)
def
_setVariationValue
(
self
,
variation_value
):
return
variation_value
.
setVariationValue
(
self
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setVariationValue'
)
def
setVariationValue
(
self
,
variation_value
):
self
.
_setVariationValue
(
variation_value
)
self
.
reindexObject
()
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
\
'getVariationRangeCategoryItemList'
)
def
getVariationRangeCategoryItemList
(
self
,
*
args
,
**
kw
):
...
...
product/ERP5/VariationValue.py
0 → 100644
View file @
d4fb0385
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
Products.ERP5Type
import
interfaces
from
Products.ERP5Type.Context
import
Context
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5.mixin.variated
import
VariatedMixin
from
zope.interface
import
implements
def
newVariationValue
(
context
=
None
,
REQUEST
=
None
,
**
kw
):
# Create context object
context_obj
=
VariationValue
(
context
=
context
,
REQUEST
=
REQUEST
,
**
kw
)
# Wrap the context
if
context
is
not
None
:
return
context_obj
.
asContext
(
context
=
context
)
else
:
return
context_obj
class
VariationValue
(
Context
,
VariatedMixin
):
"""
Embodies a variation value. Implements discrete variations.
"""
# Declarative interfaces
implements
(
interfaces
.
IVariated
)
def
__init__
(
self
,
context
=
None
,
REQUEST
=
None
,
**
kw
):
Context
.
__init__
(
self
,
context
=
context
,
REQUEST
=
REQUEST
,
**
kw
)
if
hasattr
(
self
,
'categories'
):
self
.
categories
=
getattr
(
self
,
'categories'
)
elif
hasattr
(
REQUEST
,
'categories'
):
self
.
categories
=
getattr
(
REQUEST
,
'categories'
)
else
:
self
.
categories
=
context
.
getVariationCategoryList
()
def
setVariationValue
(
self
,
context
):
context
.
setVariationCategoryList
(
self
.
categories
)
def
__cmp__
(
self
,
other
):
same
=
0
a
=
getattr
(
self
,
'categories'
,
())
b
=
getattr
(
other
,
'categories'
,
())
for
ka
in
a
:
if
not
ka
in
b
:
same
=
1
for
kb
in
b
:
if
not
kb
in
a
:
same
=
-
1
return
same
InitializeClass
(
VariationValue
)
product/ERP5/interfaces/variated.py
View file @
d4fb0385
...
...
@@ -53,7 +53,7 @@ class IVariated(Interface):
# The following methods are intended to access to the
# variation value of a variated object. Discrete variations
# are based on categories. General variations are encapsulated
# into
Individual Variation
instances.
# into
VariationValue
instances.
# Property Variation Accessors
def
getVariationPropertyList
():
...
...
product/ERP5/mixin/variated.py
View file @
d4fb0385
...
...
@@ -370,6 +370,16 @@ class VariatedMixin:
# display is on left
return
[
x
[
1
]
for
x
in
vrcil
]
# Context related methods
security
.
declarePublic
(
'newVariationValue'
)
def
newVariationValue
(
self
,
context
=
None
,
REQUEST
=
None
,
**
kw
):
# PERFORMANCE ISSUE
from
Products.ERP5.VariationValue
import
newVariationValue
if
context
is
None
:
return
newVariationValue
(
REQUEST
=
REQUEST
,
**
kw
)
else
:
return
newVariationValue
(
context
=
context
,
REQUEST
=
REQUEST
,
**
kw
)
# Provide a string representation of variations
security
.
declarePublic
(
'getVariationText'
)
def
getVariationText
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment