Add mid price value field
This commit is contained in:
@@ -126,10 +126,11 @@ class ImportPrices(Wizard):
|
||||
REQUIRED_COLUMNS = {
|
||||
'priceindex': 'price_index',
|
||||
'pricedate': 'price_date',
|
||||
'highprice': 'high_price',
|
||||
'lowprice': 'low_price',
|
||||
'openprice': 'open_price',
|
||||
'pricevalue': 'price_value',
|
||||
'highprice': 'high_price',
|
||||
'lowprice': 'low_price',
|
||||
'midprice': 'mid_price',
|
||||
'openprice': 'open_price',
|
||||
'pricevalue': 'price_value',
|
||||
}
|
||||
|
||||
def transition_import_(self):
|
||||
@@ -301,10 +302,11 @@ class ImportPrices(Wizard):
|
||||
return {
|
||||
'price': price.id,
|
||||
'price_date': price_date,
|
||||
'high_price': cls._as_float(row.get('high_price')),
|
||||
'low_price': cls._as_float(row.get('low_price')),
|
||||
'open_price': cls._as_float(row.get('open_price')),
|
||||
'price_value': cls._as_float(row.get('price_value')),
|
||||
'high_price': cls._as_float(row.get('high_price')),
|
||||
'low_price': cls._as_float(row.get('low_price')),
|
||||
'mid_price': cls._as_float(row.get('mid_price')),
|
||||
'open_price': cls._as_float(row.get('open_price')),
|
||||
'price_value': cls._as_float(row.get('price_value')),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
@@ -357,10 +359,12 @@ class ImportPrices(Wizard):
|
||||
@staticmethod
|
||||
def _price_summary(values):
|
||||
parts = []
|
||||
for name in ('price_value', 'open_price', 'low_price', 'high_price'):
|
||||
value = values.get(name)
|
||||
if value is not None:
|
||||
parts.append('%s=%s' % (name, value))
|
||||
for name in (
|
||||
'price_value', 'open_price', 'low_price', 'mid_price',
|
||||
'high_price'):
|
||||
value = values.get(name)
|
||||
if value is not None:
|
||||
parts.append('%s=%s' % (name, value))
|
||||
return ', '.join(parts) or 'price imported'
|
||||
|
||||
@classmethod
|
||||
@@ -461,6 +465,7 @@ class ImportPrices(Wizard):
|
||||
'price_date': price_date,
|
||||
'high_price': price_value,
|
||||
'low_price': price_value,
|
||||
'mid_price': price_value,
|
||||
'open_price': price_value,
|
||||
'price_value': price_value,
|
||||
})
|
||||
|
||||
@@ -5160,7 +5160,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
|
||||
@with_transaction()
|
||||
def test_import_forward_prices_copies_value_to_ohl_fields(self):
|
||||
'forward import uses price values for open, low and high prices'
|
||||
'forward import uses price values for open, low, mid and high prices'
|
||||
ImportPrices = Pool().get('purchase_trade.import_prices')
|
||||
ns = {'s': 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'}
|
||||
sheet = ElementTree.fromstring('''
|
||||
@@ -5187,6 +5187,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(result[0]['price_value'], '75.25')
|
||||
self.assertEqual(result[0]['open_price'], '75.25')
|
||||
self.assertEqual(result[0]['low_price'], '75.25')
|
||||
self.assertEqual(result[0]['mid_price'], '75.25')
|
||||
self.assertEqual(result[0]['high_price'], '75.25')
|
||||
|
||||
def test_pricing_component_matrix_returns_generic_line_price(self):
|
||||
|
||||
Reference in New Issue
Block a user