Commit fe941384 authored by Jérome Perrin's avatar Jérome Perrin

trade: support "Asset Price" valuation method in stock report

This shows the asset price from `stock.total_price` which can be just the
movement prices or the evaluated prices if getDestinationAssetPrice and/or
getSourceAssetPrice type based methods are defined.
parent 196975c0
...@@ -249,6 +249,10 @@ ...@@ -249,6 +249,10 @@
<string>Default Sales Price</string> <string>Default Sales Price</string>
<string>default_sale_price</string> <string>default_sale_price</string>
</tuple> </tuple>
<tuple>
<string>Asset Price</string>
<string>asset_price</string>
</tuple>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -39,6 +39,9 @@ def getPriceFromDefaultSupplyLine(brain, supply_line_id): ...@@ -39,6 +39,9 @@ def getPriceFromDefaultSupplyLine(brain, supply_line_id):
return None return None
return brain.inventory * base_price return brain.inventory * base_price
if inventory_valuation_method == 'asset_price':
return context.total_price
if inventory_valuation_method: if inventory_valuation_method:
supply_line_id_mapping = { supply_line_id_mapping = {
'default_purchase_price': 'default_psl', 'default_purchase_price': 'default_psl',
......
...@@ -1651,6 +1651,35 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -1651,6 +1651,35 @@ class TestTradeReports(ERP5ReportTestCase):
total_price=7, total_price=7,
) )
def testStockReport_valuation_method_asset_price(self):
self._createConfirmedSalePackingListForStockReportTest()
request = self.portal.REQUEST
request.form['at_date'] = DateTime(2007, 3, 3)
request.form['node_category'] = 'site/demo_site_A'
request.form['simulation_period'] = 'future'
request.form['inventory_valuation_method'] = 'asset_price'
line_list = self.portal.inventory_module.Base_viewStockReportBySite.listbox.\
get_value('default',
render_format='list', REQUEST=self.portal.REQUEST)
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEqual(1, len(data_line_list))
data_line = data_line_list[0]
self.assertEqual(
data_line.column_id_list,
['resource_title', 'resource_reference', 'variation_category_item_list', 'inventory', 'quantity_unit', 'total_price'])
self.checkLineProperties(
data_line_list[0],
resource_title='product_A',
resource_reference='ref 2',
variation_category_item_list=[],
inventory=1,
quantity_unit='G',
total_price=10,
)
def testStockReport_valuation_and_quantity_unit_conversion(self): def testStockReport_valuation_and_quantity_unit_conversion(self):
self._createConfirmedSalePackingListForStockReportTest( self._createConfirmedSalePackingListForStockReportTest(
quantity=0.5, quantity=0.5,
......
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