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

trade: test Stock Report with unit conversions

parent e4d15dbe
......@@ -142,14 +142,33 @@ class TestTradeReports(ERP5ReportTestCase):
id='Organisation_3',)
# create unit categories
if not self.portal_categories.quantity_unit.has_key('mass'):
self.portal_categories.quantity_unit.newContent(
portal_type='Category',
id='mass')
for unit_id in ('kg', 'g',):
if not self.portal_categories['quantity_unit'].has_key(unit_id):
self.portal_categories.quantity_unit.newContent(
if not self.portal_categories.quantity_unit.mass.has_key(unit_id):
self.portal_categories.quantity_unit.mass.newContent(
portal_type='Category',
title=unit_id.title(),
reference=unit_id,
id=unit_id)
# and corresponding unit conversion group
if not self.portal.quantity_unit_conversion_module.has_key('mass_conversion_group'):
self.portal.quantity_unit_conversion_module.newContent(
portal_type='Quantity Unit Conversion Group',
id='mass_conversion_group',
quantity_unit_value=self.portal_categories.quantity_unit.mass.g,
).validate()
self.portal.quantity_unit_conversion_module.mass_conversion_group.newContent(
portal_type='Quantity Unit Conversion Definition',
id='ton',
quantity_unit_value=self.portal_categories.quantity_unit.mass.kg,
quantity=1000,
).validate()
self.tic()
# Create resources
module = self.portal.product_module
if not module.has_key('product_B'):
......@@ -158,7 +177,7 @@ class TestTradeReports(ERP5ReportTestCase):
id='product_B',
title='product_B',
reference='ref 1',
quantity_unit='kg'
quantity_unit='mass/kg'
)
if not module.has_key('product_A'):
product = module.newContent(
......@@ -166,7 +185,7 @@ class TestTradeReports(ERP5ReportTestCase):
id='product_A',
title='product_A',
reference='ref 2',
quantity_unit='g',
quantity_unit_list=('mass/g', 'mass/kg'),
default_purchase_supply_line_base_price=3,
default_internal_supply_line_base_price=5,
default_sale_supply_line_base_price=7,
......@@ -948,7 +967,7 @@ class TestTradeReports(ERP5ReportTestCase):
self.tic()
def _createConfirmedSalePackingListForStockReportTest(self):
def _createConfirmedSalePackingListForStockReportTest(self, quantity=1, quantity_unit_value=None):
confirmed_sale_packing_list = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List',
title='%s 1' % self.id(),
......@@ -964,8 +983,9 @@ class TestTradeReports(ERP5ReportTestCase):
confirmed_sale_packing_list.newContent(
portal_type='Sale Packing List Line',
resource_value=self.portal.product_module.product_A,
quantity=1,
quantity=quantity,
price=10,
quantity_unit_value=quantity_unit_value,
)
confirmed_sale_packing_list.confirm()
......@@ -1103,6 +1123,31 @@ class TestTradeReports(ERP5ReportTestCase):
inventory=66,
quantity_unit='')
def testStockReport_unit_conversion(self):
self._createConfirmedSalePackingListForStockReportTest(
quantity=0.5,
quantity_unit_value=self.portal.portal_categories.quantity_unit.mass.kg,
)
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'
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))
self.checkLineProperties(
data_line_list[0],
resource_title='product_A',
resource_reference='ref 2',
variation_category_item_list=[],
inventory=500,
quantity_unit='G')
def _createInventoryForStockReportWithPositiveOrNegativeOrZeroStockTest(self):
# Create inventories
first = self._makeOneInventory(
......
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