Commit 03b97d72 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_trade: available to create stock report for different period

parent 5015f5ce
result_list = []
inventory_list_method_dict = {
'current': 'getCurrentInventoryList',
'future': 'getFutureInventoryList',
'available': 'getAvailableInventoryList',
}
if section_category:
kw['section_category'] = section_category
for brain in context.portal_simulation.getCurrentInventoryList(
for brain in getattr(context.portal_simulation, inventory_list_method_dict[simulation_period])(
node_category=node_category,
group_by_resource=True,
group_by_variation=True,
......
......@@ -50,11 +50,11 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>at_date=None, node_category=None, section_category=None, positive_stock=None, negative_stock=None, zero_stock=None, **kw</string> </value>
<value> <string>at_date=None, node_category=None, section_category=None, positive_stock=None, negative_stock=None, zero_stock=None, simulation_period="current", **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getBySiteCurrentStockList</string> </value>
<value> <string>Base_getBySiteStockList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -102,6 +102,7 @@
<string>your_node_category</string>
<string>your_section_category</string>
<string>your_at_date</string>
<string>your_simulation_period</string>
</list>
</value>
</item>
......
......@@ -212,7 +212,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>Base_getBySiteCurrentStockList</string> </value>
<value> <string>Base_getBySiteStockList</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>items</string>
<string>size</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_simulation_period</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list>
<tuple>
<string>Current</string>
<string>current</string>
</tuple>
<tuple>
<string>Future</string>
<string>future</string>
</tuple>
<tuple>
<string>Available</string>
<string>available</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Simulation Period</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>request/simulation_period</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(context.Base_translateString(x), y) for x, y in field.get_orig_value(\'items\')]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -96,6 +96,7 @@
<string>your_node_category</string>
<string>your_section_category</string>
<string>your_at_date</string>
<string>your_simulation_period</string>
<string>your_portal_skin</string>
<string>your_format</string>
<string>your_deferred_style</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>items</string>
<string>size</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_simulation_period</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list>
<tuple>
<string>Current</string>
<string>current</string>
</tuple>
<tuple>
<string>Future</string>
<string>future</string>
</tuple>
<tuple>
<string>Available</string>
<string>available</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Simulation Period</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(context.Base_translateString(x), y) for x, y in field.get_orig_value(\'items\')]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -43,7 +43,8 @@ class TestTradeReports(ERP5ReportTestCase):
def getBusinessTemplateList(self):
"""Returns list of BT to be installed."""
return ('erp5_core_proxy_field_legacy',
'erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_pdm', )
'erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_simulation',
'erp5_simulation_test', 'erp5_configurator_standard_trade_template', )
def login(self):
"""login with Manager roles."""
......@@ -70,6 +71,7 @@ class TestTradeReports(ERP5ReportTestCase):
self.sale_order_module = self.portal.sale_order_module
self.product_module = self.portal.product_module
self.portal_categories = self.portal.portal_categories
self.validateRules()
# Create site category
for site_id, codification in (
......@@ -195,6 +197,8 @@ class TestTradeReports(ERP5ReportTestCase):
list(self.inventory_module.objectIds()))
self.sale_order_module.manage_delObjects(
list(self.sale_order_module.objectIds()))
self.portal.sale_packing_list_module.manage_delObjects(
list(self.portal.sale_packing_list_module.objectIds()))
self.tic()
......@@ -931,6 +935,30 @@ class TestTradeReports(ERP5ReportTestCase):
self.tic()
def _createConfirmedSalePackingListForStockReportTest(self):
confirmed_sale_packing_list = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List',
title='%s 1' % self.id(),
destination_value=self.organisation_module.Organisation_1,
destination_section_value=self.organisation_module.Organisation_1,
source_value=self.organisation_module.Organisation_2,
source_section_value=self.organisation_module.Organisation_2,
start_date=DateTime(2006, 2, 2),
specialise = 'business_process_module/erp5_default_business_process',
description='The description',
)
confirmed_sale_packing_list.newContent(
portal_type='Sale Packing List Line',
resource_value=self.portal.product_module.product_A,
quantity=1,
price=10,
)
confirmed_sale_packing_list.confirm()
self.tic()
def testStockReport_when_section_category_is_empty(self):
self._createInventoryForStockReportTest()
request = self.portal.REQUEST
......@@ -945,6 +973,29 @@ class TestTradeReports(ERP5ReportTestCase):
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEqual(1, len(data_line_list))
def testStockReport_future_simulation_period(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'
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=1,
quantity_unit='G')
def testStockReport_old_date(self):
"""
Old date
......
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