Commit 8221492f authored by Łukasz Nowak's avatar Łukasz Nowak

- use system preferences list of categories to recognise resources

 - update test to use it


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26676 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 60795f30
No related merge requests found
......@@ -34,6 +34,7 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.Amount import Amount
from Products.ERP5.AggregatedAmountList import AggregatedAmountList
import zope.interface
class TradeModelLine(Amount):
......@@ -68,9 +69,13 @@ class TradeModelLine(Amount):
def getAggregatedAmountList(self, context, movement_list = None,
current_aggregated_amount_list = None, **kw):
from Products.ERP5Type.Document import newTempMovement
normal_resource_use_category_list = self.\
portal_preferences.getPreferredNormalResourceUseCategoryList()
if normal_resource_use_category_list is None:
raise ValueError('preferred_normal_resource_use_category is not ' + \
'configured in System Preferences')
if current_aggregated_amount_list is None:
current_aggregated_amount_list = []
......@@ -102,9 +107,9 @@ class TradeModelLine(Amount):
for movement in context.getMovementList():
movement_resource = movement.getResourceValue()
if movement_resource is not None:
if movement_resource.getUse() not in ['', None]:
continue
movement_list.append(movement)
if movement_resource.getUse() in \
normal_resource_use_category_list:
movement_list.append(movement)
aggregated_amount_list = AggregatedAmountList()
base_application_list = self.getBaseApplicationList()
......
......@@ -58,6 +58,9 @@ class TestBPMMixin(ERP5TypeTestCase):
modified_order_line_price_ratio = 2.0
modified_order_line_quantity_ratio = 2.5
normal_resource_use_category_list = ['normal']
invoicing_resource_use_category_list = ['discount', 'tax']
def setUpOnce(self):
self.portal = self.getPortalObject()
self.validateRules()
......@@ -70,10 +73,13 @@ class TestBPMMixin(ERP5TypeTestCase):
@reindex
def createCategories(self):
category_tool = getToolByName(self.portal,'portal_categories')
self.createCategoriesInCategory(category_tool.base_amount,['discount', 'tax'])
self.createCategoriesInCategory(category_tool.use,['discount', 'tax'])
self.createCategoriesInCategory(category_tool.trade_phase,['default',])
category_tool = getToolByName(self.portal, 'portal_categories')
self.createCategoriesInCategory(category_tool.base_amount, ['discount',
'tax'])
self.createCategoriesInCategory(category_tool.use,
self.normal_resource_use_category_list + \
self.invoicing_resource_use_category_list)
self.createCategoriesInCategory(category_tool.trade_phase, ['default',])
self.createCategoriesInCategory(category_tool.trade_phase.default,
['accounting', 'delivery', 'invoicing', 'discount', 'tax', 'payment'])
......@@ -158,9 +164,33 @@ class TestBPMMixin(ERP5TypeTestCase):
portal_type='Applied Rule')
return applied_rule.newContent(portal_type='Simulation Movement')
@reindex
def setSystemPreference(self):
preference_tool = getToolByName(self.portal, 'portal_preferences')
system_preference_list = preference_tool.contentValues(
portal_type='System Preference')
if len(system_preference_list) > 1:
raise AttributeError('More than one System Preference, cannot test')
if len(system_preference_list) == 0:
system_preference = preference_tool.newContent(portal_type='System Preference')
else:
system_preference = system_preference_list[0]
system_preference.edit(
preferred_invoicing_resource_use_category_list = \
self.invoicing_resource_use_category_list,
preferred_normal_resource_use_category_list = \
self.normal_resource_use_category_list,
priority = 1,
)
if system_preference.getPreferenceState() == 'disabled':
system_preference.enable()
@reindex
def afterSetUp(self):
self.createCategories()
self.setSystemPreference()
# XXX for testing purpose only...
# This builder is not supporting yet deeper simulation tree
......@@ -630,18 +660,21 @@ class TestBPMMixin(ERP5TypeTestCase):
sequence.edit(product_taxed = self.createResource('Product',
title='Product Taxed',
base_contribution=['base_amount/tax'],
use='normal',
))
def stepCreateProductDiscounted(self, sequence=None, **kw):
sequence.edit(product_discounted = self.createResource('Product',
title='Product Discounted',
base_contribution=['base_amount/discount'],
use='normal',
))
def stepCreateProductDiscountedTaxed(self, sequence=None, **kw):
sequence.edit(product_discounted_taxed = self.createResource('Product',
title='Product Discounted & Taxed',
base_contribution=['base_amount/discount', 'base_amount/tax'],
use='normal',
))
def stepCreateServiceTax(self, sequence=None, **kw):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment