Commit 7a8017c6 authored by Arnaud Fontaine's avatar Arnaud Fontaine

newTemp*() deprecation (1bce8563, 04b49859): Replace static/direct newTemp*() calls.

parent 35176926
...@@ -22,9 +22,8 @@ else: ...@@ -22,9 +22,8 @@ else:
shopping_cart_id = 'shopping_cart' shopping_cart_id = 'shopping_cart'
session = portal_sessions[session_id] session = portal_sessions[session_id]
if not shopping_cart_id in session.keys(): if not shopping_cart_id in session.keys():
from Products.ERP5Type.Document import newTempOrder
web_site = context.getWebSiteValue() web_site = context.getWebSiteValue()
shopping_cart = newTempOrder(portal_sessions, shopping_cart_id) shopping_cart = context.getPortalObject().newContent(temp_object=True, portal_type='Order', id=shopping_cart_id)
shopping_cart.setPriceCurrency(web_site.WebSite_getShoppingCartDefaultCurrency().getRelativeUrl()) shopping_cart.setPriceCurrency(web_site.WebSite_getShoppingCartDefaultCurrency().getRelativeUrl())
session[shopping_cart_id] = shopping_cart session[shopping_cart_id] = shopping_cart
......
...@@ -58,9 +58,9 @@ class TestContributionRegistryTool(ERP5TypeTestCase): ...@@ -58,9 +58,9 @@ class TestContributionRegistryTool(ERP5TypeTestCase):
##parameters=predicate=None ##parameters=predicate=None
##title= ##title=
## ##
from Products.ERP5Type.Document import newTempEvent
event = newTempEvent(context, 'subobject', data=context.getData()) event = context.newContent(temp_object=True, portal_type='Event',
id='subobject', data=context.getData())
subject = event.getContentInformation().get('Subject', None) subject = event.getContentInformation().get('Subject', None)
if subject == 'Fax': if subject == 'Fax':
......
from Products.ERP5Type.Document import newTempDomain
portal = context.getPortalObject() portal = context.getPortalObject()
portal_type_list = portal.getPortalEventTypeList() portal_type_list = portal.getPortalEventTypeList()
portal_types = portal.portal_types portal_types = portal.portal_types
......
request = context.REQUEST request = context.REQUEST
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from Products.ERP5Type.Document import newTempMappedValue
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
u=getSecurityManager().getUser() u=getSecurityManager().getUser()
......
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from Products.ERP5Type.Document import newTempDocument
return_list = [] return_list = []
i = 1 i = 1
portal = context.getPortalObject() portal = context.getPortalObject()
...@@ -9,7 +8,7 @@ for worklist in context.portal_workflow.listActionInfos(): ...@@ -9,7 +8,7 @@ for worklist in context.portal_workflow.listActionInfos():
# Worklist translation process is a bit tricky. We translate only the first part of "X to Validate (count)" # Worklist translation process is a bit tricky. We translate only the first part of "X to Validate (count)"
title, count = title.split(' (', 1) title, count = title.split(' (', 1)
title = "%s (%s" % ( translateString(title), count ) title = "%s (%s" % ( translateString(title), count )
o = newTempDocument(portal, str(i)) o = portal.newContent(temp_object=True, portal_type='Document', id=str(i))
o.edit( o.edit(
count=worklist['count'], count=worklist['count'],
title=title, title=title,
......
...@@ -2,7 +2,6 @@ import zope ...@@ -2,7 +2,6 @@ import zope
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.Document import newTempDocument
import hashlib import hashlib
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
import datetime import datetime
...@@ -343,7 +342,7 @@ class PayzenService(XMLObject, PayzenSOAP): ...@@ -343,7 +342,7 @@ class PayzenService(XMLObject, PayzenSOAP):
if message_list: if message_list:
raise ValidationFailed, message_list raise ValidationFailed, message_list
temp_document = newTempDocument(self, 'id') temp_document = self.newContent(temp_object=True, portal_type='Document', id='id')
temp_document.edit( temp_document.edit(
link_url_string=self.getLinkUrlString(), link_url_string=self.getLinkUrlString(),
title='title', title='title',
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>This portal type is an abstract portal type, so that newTempOrder calls can succeed; one should never have to use this portal type for persistent objects.</string> </value> <value> <string>This portal type is an abstract portal type, so that newContent(temp_object=True) calls can succeed; one should never have to use this portal type for persistent objects.</string> </value>
</item> </item>
<item> <item>
<key> <string>factory</string> </key> <key> <string>factory</string> </key>
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
import hashlib import hashlib
import json import json
import validictory import validictory
from Products.ERP5Type.Document import newTempFile
from Products.ERP5Type.UnrestrictedMethod import super_user from Products.ERP5Type.UnrestrictedMethod import super_user
...@@ -71,7 +70,7 @@ def WebSection_getDocumentValue(self, key, portal=None, language=None,\ ...@@ -71,7 +70,7 @@ def WebSection_getDocumentValue(self, key, portal=None, language=None,\
follow_up_uid=data_set.getUid(), follow_up_uid=data_set.getUid(),
validation_state='published')] validation_state='published')]
temp_file = newTempFile(self, '%s.txt' % key) temp_file = self.newContent(temp_object=True, portal_type='File', id='%s.txt' % key)
temp_file.setData(json.dumps(document_list)) temp_file.setData(json.dumps(document_list))
temp_file.setContentType('application/json') temp_file.setContentType('application/json')
return temp_file.getObject() return temp_file.getObject()
......
...@@ -401,7 +401,6 @@ class BalanceTransaction(AccountingTransaction, Inventory): ...@@ -401,7 +401,6 @@ class BalanceTransaction(AccountingTransaction, Inventory):
This method must return a function that accepts properties keywords This method must return a function that accepts properties keywords
arguments and returns a temp object edited with those properties. arguments and returns a temp object edited with those properties.
""" """
from Products.ERP5Type.Document import newTempAccountingTransactionLine
# When have to reindex temp objects with quantity 0 in # When have to reindex temp objects with quantity 0 in
# order to update stock if delta become 0, but but redefining # order to update stock if delta become 0, but but redefining
# isMovement we do not insert 0 lines in stock # isMovement we do not insert 0 lines in stock
...@@ -409,8 +408,10 @@ class BalanceTransaction(AccountingTransaction, Inventory): ...@@ -409,8 +408,10 @@ class BalanceTransaction(AccountingTransaction, Inventory):
return self.getProperty('total_price', 0) != 0 or \ return self.getProperty('total_price', 0) != 0 or \
self.getProperty('quantity', 0) != 0 self.getProperty('quantity', 0) != 0
def factory(*args, **kw): def factory(*args, **kw):
doc = newTempAccountingTransactionLine(self, kw.pop('id', self.getId()), doc = self.newContent(temp_object=True,
uid=self.getUid()) portal_type='Accounting Transaction Line',
id=kw.pop('id', self.getId()),
uid=self.getUid())
doc.portal_type = 'Balance Transaction Line' doc.portal_type = 'Balance Transaction Line'
relative_url = kw.pop('relative_url', None) relative_url = kw.pop('relative_url', None)
destination_total_asset_price = kw.pop('total_price', None) destination_total_asset_price = kw.pop('total_price', None)
......
...@@ -144,7 +144,9 @@ class Inventory(Delivery): ...@@ -144,7 +144,9 @@ class Inventory(Delivery):
if temp_constructor is None: if temp_constructor is None:
from Products.ERP5Type.Document import newTempMovement as temp_constructor def temp_constructor(self, id, *args, **kw):
return self.newContent(temp_object=True, portal_type='Movement',
id=id, *args, **kw)
stop_date = self.getStopDate() stop_date = self.getStopDate()
stock_object_list = [] stock_object_list = []
......
...@@ -51,10 +51,10 @@ from zLOG import LOG, WARNING ...@@ -51,10 +51,10 @@ from zLOG import LOG, WARNING
def getExchangeRate(currency_value, section_currency, date): def getExchangeRate(currency_value, section_currency, date):
currency = currency_value.getRelativeUrl() currency = currency_value.getRelativeUrl()
if currency != section_currency: if currency != section_currency:
from Products.ERP5Type.Document import newTempAccountingTransactionLine return currency_value.getPrice(context=currency_value.getPortalObject().newContent(
return currency_value.getPrice(context=newTempAccountingTransactionLine( temp_object=True,
currency_value.getPortalObject(), portal_type='Accounting Transaction Line',
"accounting_line", id="accounting_line",
resource=currency, resource=currency,
start_date=date, start_date=date,
price_currency=section_currency price_currency=section_currency
......
...@@ -82,7 +82,6 @@ class Order(Delivery): ...@@ -82,7 +82,6 @@ class Order(Delivery):
# Find amounts from the result of getAggregatedAmountList. # Find amounts from the result of getAggregatedAmountList.
# Call getAggregatedAmountList and sum all the amounts which # Call getAggregatedAmountList and sum all the amounts which
# base_contribution category is matched with. # base_contribution category is matched with.
from Products.ERP5Type.Document import newTempTradeModelLine
from Products.ERP5.PropertySheet.TradeModelLine import TARGET_LEVEL_MOVEMENT from Products.ERP5.PropertySheet.TradeModelLine import TARGET_LEVEL_MOVEMENT
trade_condition = self.getSpecialiseValue() trade_condition = self.getSpecialiseValue()
if trade_condition is None: if trade_condition is None:
...@@ -103,8 +102,9 @@ class Order(Delivery): ...@@ -103,8 +102,9 @@ class Order(Delivery):
# We cannot find any amount so that the result is 0. # We cannot find any amount so that the result is 0.
return 0 return 0
current_aggregated_amount_list = trade_condition.getAggregatedAmountList(self, rounding=rounding, force_create_line=True) current_aggregated_amount_list = trade_condition.getAggregatedAmountList(self, rounding=rounding, force_create_line=True)
trade_model_line = newTempTradeModelLine( trade_model_line = self.newContent(temp_object=True,
self, '_temp_' + self.getId(), notify_workflow=False) portal_type='Trade Model Line',
id='_temp_' + self.getId(), notify_workflow=False)
# prevent invoking interaction workflows. # prevent invoking interaction workflows.
trade_model_line.portal_type = '' trade_model_line.portal_type = ''
trade_model_line.edit(target_level=TARGET_LEVEL_MOVEMENT, price=1, trade_model_line.edit(target_level=TARGET_LEVEL_MOVEMENT, price=1,
......
...@@ -74,7 +74,6 @@ class GeneratedAmountList(list): ...@@ -74,7 +74,6 @@ class GeneratedAmountList(list):
Groups amounts with same price, efficiency, reference and categories, merge Groups amounts with same price, efficiency, reference and categories, merge
them by summing their quantities, and return the new amounts in a new list. them by summing their quantities, and return the new amounts in a new list.
""" """
from Products.ERP5Type.Document import newTempAmount
# XXX: Do we handle rounding correctly ? # XXX: Do we handle rounding correctly ?
# What to do if only total price is rounded ?? # What to do if only total price is rounded ??
aggregate_dict = {} aggregate_dict = {}
...@@ -92,7 +91,10 @@ class GeneratedAmountList(list): ...@@ -92,7 +91,10 @@ class GeneratedAmountList(list):
# Before we ignore 'quantity==0' amount here for better performance, # Before we ignore 'quantity==0' amount here for better performance,
# but it is not a good idea, especially when the first expand causes # but it is not a good idea, especially when the first expand causes
# non-zero quantity and then quantity becomes zero. # non-zero quantity and then quantity becomes zero.
aggregate = newTempAmount(amount.aq_parent, '', notify_workflow=False) aggregate = amount.aq_parent.newContent(temp_object=True,
portal_type='Amount',
id='',
notify_workflow=False)
aggregate.__dict__.update(amount.aq_base.__dict__) aggregate.__dict__.update(amount.aq_base.__dict__)
aggregate._setQuantity(quantity) aggregate._setQuantity(quantity)
if isinstance(amount, RoundingProxy): if isinstance(amount, RoundingProxy):
......
...@@ -47,8 +47,7 @@ class ContributionRegistryTool(BaseTool): ...@@ -47,8 +47,7 @@ class ContributionRegistryTool(BaseTool):
# if a context is passed, ignore other arguments # if a context is passed, ignore other arguments
if context is None: if context is None:
# Build a temp object edited with provided parameters # Build a temp object edited with provided parameters
from Products.ERP5Type.Document import newTempFile context = self.newContent(temp_object=True, portal_type='File', id='_')
context = newTempFile(self, '_')
context.edit(**kw) context.edit(**kw)
for predicate in self.objectValues(sort_on='int_index'): for predicate in self.objectValues(sort_on='int_index'):
......
...@@ -412,8 +412,7 @@ class NotificationTool(BaseTool): ...@@ -412,8 +412,7 @@ class NotificationTool(BaseTool):
else: else:
# CRM is not installed - only notification by email is possible # CRM is not installed - only notification by email is possible
# So create a temp object directly # So create a temp object directly
from Products.ERP5Type.Document import newTempEvent new_event = self.newContent(temp_object=True, portal_type='Event', id='_')
new_event = newTempEvent(self, '_')
event_list = [new_event] event_list = [new_event]
if event in event_list: if event in event_list:
......
...@@ -987,7 +987,6 @@ class TemplateTool (BaseTool): ...@@ -987,7 +987,6 @@ class TemplateTool (BaseTool):
update_only: return only bt that needs to be updated update_only: return only bt that needs to be updated
template_list: only returns bt within the given list template_list: only returns bt within the given list
""" """
from Products.ERP5Type.Document import newTempBusinessTemplate
result_list = [] result_list = []
template_set = None template_set = None
if template_list is not None: if template_list is not None:
...@@ -1051,13 +1050,16 @@ class TemplateTool (BaseTool): ...@@ -1051,13 +1050,16 @@ class TemplateTool (BaseTool):
installed_revision = '' installed_revision = ''
version_state = 'new' version_state = 'new'
uid = self.encodeRepositoryBusinessTemplateUid(repository, id) uid = self.encodeRepositoryBusinessTemplateUid(repository, id)
obj = newTempBusinessTemplate(self, 'temp_' + uid, obj = self.newContent(temp_object=True,
version_state = version_state, portal_type='Business Template',
version_state_title=version_state.title(), id='temp_' + uid,
filename = filename, version_state=version_state,
installed_version = installed_version, version_state_title=version_state.title(),
installed_revision = installed_revision, filename=filename,
repository = repository, **property_dict) installed_version=installed_version,
installed_revision=installed_revision,
repository=repository,
**property_dict)
obj.setUid(uid) obj.setUid(uid)
result_list.append(obj) result_list.append(obj)
result_list.sort(key=lambda x: x.getTitle()) result_list.sort(key=lambda x: x.getTitle())
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>This portal type is an abstract portal type, so that newTempAmount calls can succeed; one should never have to use this portal type for persistent objects.</string> </value> <value> <string>This portal type is an abstract portal type, so that Amount temp_objects can be created; one should never have to use this portal type for persistent objects.</string> </value>
</item> </item>
<item> <item>
<key> <string>factory</string> </key> <key> <string>factory</string> </key>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>The purpose of an Event object is to keep track of the interface between the ERP and third parties.\n <value> <string>The purpose of an Event object is to keep track of the interface between the ERP and third parties.\n
\n \n
This portal type is an abstract portal type, so that newTempEvent calls can succeed; one should never have to use this portal type for persistent objects.</string> </value> This portal type is an abstract portal type, so that Event temp_objects can be created; one should never have to use this portal type for persistent objects.</string> </value>
</item> </item>
<item> <item>
<key> <string>factory</string> </key> <key> <string>factory</string> </key>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>This portal type is an abstract portal type, so that newTempMovement calls can succeed; one should never have to use this portal type for persistent objects.</string> </value> <value> <string>This portal type is an abstract portal type, so that Movement temp_objects can be created; one should never have to use this portal type for persistent objects.</string> </value>
</item> </item>
<item> <item>
<key> <string>factory</string> </key> <key> <string>factory</string> </key>
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
# is a list of variation categories that are relevant for the produced resource # is a list of variation categories that are relevant for the produced resource
from Products.ERP5Type.Document import newTempMovement
# List of dictionaries: # List of dictionaries:
# { id:resource_id, # { id:resource_id,
...@@ -22,7 +21,8 @@ for transformation_relative_url, variation_list_list in transformation_item_list ...@@ -22,7 +21,8 @@ for transformation_relative_url, variation_list_list in transformation_item_list
if resource is None: if resource is None:
continue continue
for variation_list in variation_list_list: for variation_list in variation_list_list:
movement = newTempMovement(resource, 'temp', movement = resource.newContent(temp_object=True, portal_type='Movement',
id='temp',
specialise_value=transformation, specialise_value=transformation,
variation_category_list=variation_list, variation_category_list=variation_list,
resource_value=resource, resource_value=resource,
......
...@@ -273,7 +273,6 @@ class AmountGeneratorMixin: ...@@ -273,7 +273,6 @@ class AmountGeneratorMixin:
very likely not - proxying before or after must be decided very likely not - proxying before or after must be decided
""" """
# It is the only place where we can import this # It is the only place where we can import this
from Products.ERP5Type.Document import newTempAmount
portal = self.getPortalObject() portal = self.getPortalObject()
getRoundingProxy = portal.portal_roundings.getRoundingProxy getRoundingProxy = portal.portal_roundings.getRoundingProxy
amount_generator_line_type_list = \ amount_generator_line_type_list = \
...@@ -470,9 +469,9 @@ class AmountGeneratorMixin: ...@@ -470,9 +469,9 @@ class AmountGeneratorMixin:
if getattr(self.aq_base, 'create_line', None) == 0: if getattr(self.aq_base, 'create_line', None) == 0:
property_dict['resource'] = None property_dict['resource'] = None
# Create an Amount object # Create an Amount object
amount = newTempAmount(portal, amount = portal.newContent(temp_object=True, portal_type='Amount',
# we only want the id to be unique so we pick a random causality # we only want the id to be unique so we pick a random causality
property_dict['causality_value_list'][-1] id=property_dict['causality_value_list'][-1]
.getRelativeUrl().replace('/', '_'), .getRelativeUrl().replace('/', '_'),
notify_workflow=False) notify_workflow=False)
amount._setCategoryList(property_dict.pop('category_list', ())) amount._setCategoryList(property_dict.pop('category_list', ()))
......
...@@ -902,16 +902,17 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): ...@@ -902,16 +902,17 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
def stepCreateMatchableInvoiceMovements(self, sequence, **kw) : def stepCreateMatchableInvoiceMovements(self, sequence, **kw) :
""" Create a temp movement that will be matched by the """ Create a temp movement that will be matched by the
default_invoice_transaction_rule """ default_invoice_transaction_rule """
from Products.ERP5Type.Document import newTempMovement product_notebook_region_france_movement = sequence.get('invoice').newContent(
product_notebook_region_france_movement = newTempMovement( temp_object=True,
sequence.get('invoice'), portal_type='Movement',
'test1', id='test1',
resource = sequence.get('notebook').getRelativeUrl(), resource = sequence.get('notebook').getRelativeUrl(),
destination = sequence.get('client_fr').getRelativeUrl(), destination = sequence.get('client_fr').getRelativeUrl(),
) )
product_barebone_region_france_movement = newTempMovement( product_barebone_region_france_movement = sequence.get('invoice').newContent(
sequence.get('invoice'), temp_object=True,
'test2', portal_type='Movement',
id='test2',
resource = sequence.get('barebone').getRelativeUrl(), resource = sequence.get('barebone').getRelativeUrl(),
destination = sequence.get('client_fr').getRelativeUrl(), destination = sequence.get('client_fr').getRelativeUrl(),
) )
...@@ -1005,16 +1006,17 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): ...@@ -1005,16 +1006,17 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
def stepCreateNotMatchableInvoiceMovements(self, sequence, **kw) : def stepCreateNotMatchableInvoiceMovements(self, sequence, **kw) :
""" create a temp movement that not any cell could match. """ """ create a temp movement that not any cell could match. """
from Products.ERP5Type.Document import newTempMovement bad_movement1 = sequence.get("invoice").newContent(
bad_movement1 = newTempMovement( temp_object=True,
sequence.get("invoice"), portal_type='Movement',
'test3', id='test3',
product = None, product = None,
destination = sequence.get('client').getRelativeUrl(), destination = sequence.get('client').getRelativeUrl(),
) )
bad_movement2 = newTempMovement( bad_movement2 = sequence.get("invoice").newContent(
sequence.get("invoice"), temp_object=True,
'test4', portal_type='Movement',
id='test4',
gap = 'gap/1', gap = 'gap/1',
destination = sequence.get('client').getRelativeUrl(), destination = sequence.get('client').getRelativeUrl(),
) )
......
...@@ -82,8 +82,8 @@ class CurrencyExchangeTestCase(AccountingTestCase): ...@@ -82,8 +82,8 @@ class CurrencyExchangeTestCase(AccountingTestCase):
def _getPriceContext(self, **kw): def _getPriceContext(self, **kw):
"""Returns a temp movement that we can use for getPrice(context= """Returns a temp movement that we can use for getPrice(context=
""" """
from Products.ERP5Type.Document import newTempMovement return self.portal.newContent(temp_object=True, portal_type='Movement',
return newTempMovement(self.portal, 'tmp', **kw) id='tmp', **kw)
class TestCurrencyExchangeLine(CurrencyExchangeTestCase): class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
......
...@@ -826,10 +826,9 @@ return getBaseAmountQuantity""") ...@@ -826,10 +826,9 @@ return getBaseAmountQuantity""")
('tax_share/A',): .5, ('tax_share/A',): .5,
('tax_share/B',): .6, ('tax_share/B',): .6,
}, base_application=(0,)) }, base_application=(0,))
from Products.ERP5Type.Document import newTempAmount
for x in ((100, 30, 10, 0, 0, 20, 5, 12), for x in ((100, 30, 10, 0, 0, 20, 5, 12),
(500, 150, 20, 90, 40, 120, 55, 96)): (500, 150, 20, 90, 40, 120, 55, 96)):
amount = newTempAmount(self.portal, '_', amount = self.portal.newContent(temp_object=True, portal_type='Amount', id='_',
quantity=x[0], price=1, quantity=x[0], price=1,
base_contribution=base_amount) base_contribution=base_amount)
amount_list = trade_condition.getGeneratedAmountList((amount,)) amount_list = trade_condition.getGeneratedAmountList((amount,))
...@@ -882,10 +881,9 @@ return context""" % (base_amount, base_amount)) ...@@ -882,10 +881,9 @@ return context""" % (base_amount, base_amount))
sum((x.getTotalPrice() for x in amount_list), total_price)) sum((x.getTotalPrice() for x in amount_list), total_price))
def test_05_dependencyResolution(self): def test_05_dependencyResolution(self):
from Products.ERP5Type.Document import newTempAmount, newTempTradeModelLine
from Products.ERP5.mixin.amount_generator import BaseAmountResolver from Products.ERP5.mixin.amount_generator import BaseAmountResolver
delivery_amount = newTempAmount(self.portal, '') delivery_amount = self.portal.newContent(temp_object=True, portal_type='Amount', id='')
trade_model_line = newTempTradeModelLine(self.portal, '') trade_model_line = self.portal.newContent(temp_object=True, portal_type='Trade Model Line', id='')
def case(*lines): def case(*lines):
return BaseAmountResolver({}, {}), [{ return BaseAmountResolver({}, {}), [{
None: trade_model_line, None: trade_model_line,
......
...@@ -309,14 +309,15 @@ class TestTransformation(TestTransformationMixin, BaseTestUnitConversion): ...@@ -309,14 +309,15 @@ class TestTransformation(TestTransformationMixin, BaseTestUnitConversion):
) )
swimsuit_quantity = 4.0 swimsuit_quantity = 4.0
from Products.ERP5Type.Document import newTempAmount
n = 1 n = 1
# Check that getAggregatedAmount returns the expected results, a.k.a. # Check that getAggregatedAmount returns the expected results, a.k.a.
# that our Transformation is set up correctly. # that our Transformation is set up correctly.
for i, size in enumerate(self.size_category_list): for i, size in enumerate(self.size_category_list):
for colour in self.colour_category_list: for colour in self.colour_category_list:
# id does not matter, just make it unique # id does not matter, just make it unique
temp_amount = newTempAmount(transformation, "foo_%s_%s" % (size, colour)) temp_amount = transformation.newContent(temp_object=True,
portal_type='Amount',
id="foo_%s_%s" % (size, colour))
temp_amount.edit( temp_amount.edit(
quantity = swimsuit_quantity, quantity = swimsuit_quantity,
variation_category_list = [size, colour], variation_category_list = [size, colour],
......
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