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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gabriel Monnerat
erp5
Commits
6291d0f6
Commit
6291d0f6
authored
May 13, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New method to get the current amount generator line from custom base_amount script
parent
103aa8b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
product/ERP5/mixin/amount_generator.py
product/ERP5/mixin/amount_generator.py
+12
-6
product/ERP5/tests/testPayroll.py
product/ERP5/tests/testPayroll.py
+3
-2
No files found.
product/ERP5/mixin/amount_generator.py
View file @
6291d0f6
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
import
random
import
random
import
zope.interface
import
zope.interface
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Acquisition
import
Implicit
from
Acquisition
import
aq_base
,
Implicit
from
Products.ERP5.AggregatedAmountList
import
AggregatedAmountList
from
Products.ERP5.AggregatedAmountList
import
AggregatedAmountList
from
Products.ERP5Type
import
Permissions
,
interfaces
from
Products.ERP5Type
import
Permissions
,
interfaces
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
...
@@ -55,8 +55,14 @@ class BaseAmountDict(Implicit):
...
@@ -55,8 +55,14 @@ class BaseAmountDict(Implicit):
self
.
_cache
=
cache
self
.
_cache
=
cache
self
.
_method_kw
=
method_kw
self
.
_method_kw
=
method_kw
getAmountGeneratorLine__roles__
=
None
# public
def
getAmountGeneratorLine
(
self
):
# Use aq_base to avoid additional wrapping.
return
aq_base
(
self
).
_amount_generator_line
def
setAmountGeneratorLine
(
self
,
amount_generator_line
):
def
setAmountGeneratorLine
(
self
,
amount_generator_line
):
self
.
_amount_generator_line
=
amount_generator_line
# Use aq_base to keep acquisition context.
self
.
aq_base
.
_amount_generator_line
=
amount_generator_line
def
recurseMovementList
(
self
,
movement_list
):
def
recurseMovementList
(
self
,
movement_list
):
for
amount
in
movement_list
:
for
amount
in
movement_list
:
...
@@ -87,9 +93,9 @@ class BaseAmountDict(Implicit):
...
@@ -87,9 +93,9 @@ class BaseAmountDict(Implicit):
return
self
.
_dict
[
variated_base_amount
]
return
self
.
_dict
[
variated_base_amount
]
except
KeyError
:
except
KeyError
:
value
=
0
value
=
0
amount_generator_line
=
self
.
_amount_generator_line
amount_generator_line
=
self
.
aq_base
.
_amount_generator_line
for
base_amount_dict
in
self
.
_amount_list
:
for
base_amount_dict
in
self
.
_amount_list
:
base_amount_dict
.
_amount_generator_line
=
amount_generator_line
base_amount_dict
.
aq_base
.
_amount_generator_line
=
amount_generator_line
value
+=
base_amount_dict
.
getGeneratedAmountQuantity
(
value
+=
base_amount_dict
.
getGeneratedAmountQuantity
(
*
variated_base_amount
)
*
variated_base_amount
)
self
.
_dict
[
variated_base_amount
]
=
value
self
.
_dict
[
variated_base_amount
]
=
value
...
@@ -120,12 +126,12 @@ class BaseAmountDict(Implicit):
...
@@ -120,12 +126,12 @@ class BaseAmountDict(Implicit):
try
:
try
:
method
=
self
.
_cache
[
base_amount
]
method
=
self
.
_cache
[
base_amount
]
except
KeyError
:
except
KeyError
:
method
=
self
.
_amount_generator_line
.
_getTypeBasedMethod
(
method
=
self
.
aq_base
.
_amount_generator_line
.
_getTypeBasedMethod
(
'getBaseAmountQuantityMethod'
)
'getBaseAmountQuantityMethod'
)
if
method
is
not
None
:
if
method
is
not
None
:
method
=
method
(
base_amount
)
method
=
method
(
base_amount
)
if
method
is
None
:
if
method
is
None
:
method
=
self
.
_amount_generator_line
.
getBaseAmountQuantity
method
=
self
.
aq_base
.
_amount_generator_line
.
getBaseAmountQuantity
self
.
_cache
[
base_amount
]
=
method
self
.
_cache
[
base_amount
]
=
method
if
variation_category_list
:
if
variation_category_list
:
kw
=
dict
(
self
.
_method_kw
,
kw
=
dict
(
self
.
_method_kw
,
...
...
product/ERP5/tests/testPayroll.py
View file @
6291d0f6
...
@@ -96,9 +96,10 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
...
@@ -96,9 +96,10 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
def getBaseAmountQuantity(delivery_amount, base_application,
def getBaseAmountQuantity(delivery_amount, base_application,
variation_category_list=(), **kw):
variation_category_list=(), **kw):
if variation_category_list:
if variation_category_list:
model = delivery_amount.getAmountGeneratorLine().getParentValue()
for variation in variation_category_list:
for variation in variation_category_list:
if variation.startswith('salary_range'):
if variation.startswith('salary_range
/
'):
cell =
delivery_amount.getSpecialiseValue()
.getCell(variation)
cell =
model
.getCell(variation)
if cell is not None:
if cell is not None:
model_slice_min = cell.getQuantityRangeMin()
model_slice_min = cell.getQuantityRangeMin()
model_slice_max = cell.getQuantityRangeMax()
model_slice_max = cell.getQuantityRangeMax()
...
...
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