コード例 #1
0
 def calculateExchangeFromParameters(from_currency=None,
                                     to_currency=None,
                                     currency_exchange_type='sale',
                                     start_date=None,**kw):
   if start_date is None:
     from DateTime import DateTime
     start_date = DateTime()
   from Products.ERP5Type.Document import newTempBase
   # Note: SupplyCell is the class of Currency Exchange Line portal type objects
   # But in reality, anything should do.
   from Products.ERP5Type.Document import newTempSupplyCell as newTemp
   temp_object = newTemp(context.getPortalObject(),'temp_object')
   temp_kw = {'category_list':['resource/%s' % from_currency,
                               'price_currency/%s' % to_currency],
              'start_date':start_date
             }
   if currency_exchange_type is not None:
     temp_kw['category_list'].append('currency_exchange_type/%s' % currency_exchange_type)
   temp_object.edit(**temp_kw)
   object = temp_object
   mapped_value = context.portal_domains.generateMappedValue(object, 
                                                     has_cell_content=0, 
                                                     validation_state='validated',
                                                     sort_method=sort_by_date)
   base_price = getattr(mapped_value, 'base_price', None)
   discount = getattr(mapped_value, 'discount', None)
   if base_price is None and discount is None:
     mapped_value = context.portal_domains.generateMappedValue(object, 
                                                     has_cell_content=1, 
                                                     validation_state='validated',
                                                     sort_method=sort_by_date)
     base_price = getattr(mapped_value, 'base_price', None)
     discount = getattr(mapped_value, 'discount', None)
   result = [base_price, discount]
   return result
コード例 #2
0
 def calculateExchangeFromParameters(from_currency=None,
                                     to_currency=None,
                                     currency_exchange_type='sale',
                                     start_date=None,
                                     **kw):
     if start_date is None:
         from DateTime import DateTime
         start_date = DateTime()
     from Products.ERP5Type.Document import newTempBase
     # Note: SupplyCell is the class of Currency Exchange Line portal type objects
     # But in reality, anything should do.
     from Products.ERP5Type.Document import newTempSupplyCell as newTemp
     temp_object = newTemp(context.getPortalObject(), 'temp_object')
     temp_kw = {
         'category_list':
         ['resource/%s' % from_currency,
          'price_currency/%s' % to_currency],
         'start_date':
         start_date
     }
     if currency_exchange_type is not None:
         temp_kw['category_list'].append('currency_exchange_type/%s' %
                                         currency_exchange_type)
     temp_object.edit(**temp_kw)
     object = temp_object
     mapped_value = context.portal_domains.generateMappedValue(
         object,
         has_cell_content=0,
         validation_state='validated',
         sort_method=sort_by_date)
     base_price = getattr(mapped_value, 'base_price', None)
     discount = getattr(mapped_value, 'discount', None)
     if base_price is None and discount is None:
         mapped_value = context.portal_domains.generateMappedValue(
             object,
             has_cell_content=1,
             validation_state='validated',
             sort_method=sort_by_date)
         base_price = getattr(mapped_value, 'base_price', None)
         discount = getattr(mapped_value, 'discount', None)
     result = [base_price, discount]
     return result
コード例 #3
0
exchange_line = state_change["object"]

# In this script, we will make sure it is impossible to get two
# exchange lines opened in the same time.

if exchange_line.getBasePrice() in (None, 0, 0.0):
    msg = Message(domain="ui", message="Sorry, you must define a fixing price.")
    raise ValidationFailed, (msg,)


# We have to looking for other currency exchanges lines
# Note: SupplyCell is the class of Currency Exchange Line portal type objects
# But in reality, anything should do.
from Products.ERP5Type.Document import newTempSupplyCell as newTemp

temp_object = newTemp(context.getPortalObject(), "temp_object")
start_date = exchange_line.getStartDate()
temp_kw = {
    "category_list": [
        "resource/%s" % exchange_line.getParentValue().getRelativeUrl(),
        "price_currency/%s" % exchange_line.getPriceCurrency(),
    ],
    "start_date": start_date,
}
temp_object.edit(**temp_kw)
line_list = [
    x
    for x in exchange_line.portal_domains.searchPredicateList(
        temp_object, portal_type="Currency Exchange Line", validation_state="validated", test=1
    )
    if x.getUid() != exchange_line.getUid()
コード例 #4
0
exchange_line = state_change['object']

# In this script, we will make sure it is impossible to get two
# exchange lines opened in the same time.

if exchange_line.getBasePrice() in (None, 0, 0.0):
    msg = Message(domain='ui',
                  message='Sorry, you must define a fixing price.')
    raise ValidationFailed, (msg, )

# We have to looking for other currency exchanges lines
# Note: SupplyCell is the class of Currency Exchange Line portal type objects
# But in reality, anything should do.
from Products.ERP5Type.Document import newTempSupplyCell as newTemp
temp_object = newTemp(context.getPortalObject(), 'temp_object')
start_date = exchange_line.getStartDate()
temp_kw = {
    'category_list': [
        'resource/%s' % exchange_line.getParentValue().getRelativeUrl(),
        'price_currency/%s' % exchange_line.getPriceCurrency()
    ],
    'start_date':
    start_date
}
temp_object.edit(**temp_kw)
line_list = [
    x for x in exchange_line.portal_domains.searchPredicateList(
        temp_object,
        portal_type='Currency Exchange Line',
        validation_state='validated',