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

Fixes for Order, Packing Lists and Invoice Report

See merge request !1345
parents 0039aa3f fe42394c
Pipeline #13308 failed with stage
...@@ -89,13 +89,13 @@ ...@@ -89,13 +89,13 @@
<key> <string>left</string> </key> <key> <string>left</string> </key>
<value> <value>
<list> <list>
<string>your_aggregation_level</string> <string>your_section_category</string>
<string>your_from_date</string>
<string>your_at_date</string> <string>your_at_date</string>
<string>your_delivery_mode</string> <string>your_delivery_mode</string>
<string>your_from_date</string>
<string>your_group_by</string>
<string>your_incoterm</string> <string>your_incoterm</string>
<string>your_section_category</string> <string>your_aggregation_level</string>
<string>your_group_by</string>
<string>your_simulation_state</string> <string>your_simulation_state</string>
</list> </list>
</value> </value>
......
...@@ -88,7 +88,7 @@ portal.portal_catalog.activate(tag=tag).searchAndActivate( ...@@ -88,7 +88,7 @@ portal.portal_catalog.activate(tag=tag).searchAndActivate(
'date_format' : date_format, 'date_format' : date_format,
'report_type' : report_type, 'report_type' : report_type,
'report_group_by' : report_group_by}, 'report_group_by' : report_group_by},
select_method_id = 'OrderModule_filterOrderStatResul', select_method_id = 'OrderModule_filterOrderStatResult',
activate_kw = {'priority' : 7, activate_kw = {'priority' : 7,
'tag' : tag, 'tag' : tag,
}, },
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>OrderModule_filterOrderStatResul</string> </value> <value> <string>OrderModule_filterOrderStatResult</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -14,10 +14,16 @@ if "Sale" in context.getPortalType(): ...@@ -14,10 +14,16 @@ if "Sale" in context.getPortalType():
report_type = "sale" report_type = "sale"
line_portal_type = "Sale Order Line" line_portal_type = "Sale Order Line"
doc_portal_type = "Sale Order" doc_portal_type = "Sale Order"
if "Packing List" in context.getPortalType():
line_portal_type = "Sale Packing List Line"
doc_portal_type = "Sale Packing List"
elif "Purchase" in context.getPortalType(): elif "Purchase" in context.getPortalType():
report_type = "purchase" report_type = "purchase"
line_portal_type = "Purchase Order Line" line_portal_type = "Purchase Order Line"
doc_portal_type = "Purchase Order" doc_portal_type = "Purchase Order"
if "Packing List" in context.getPortalType():
line_portal_type = "Purchase Packing List Line"
doc_portal_type = "Purchase Packing List"
elif request.get('order_report_document_portal_type'): elif request.get('order_report_document_portal_type'):
doc_portal_type = request.get('order_report_document_portal_type') doc_portal_type = request.get('order_report_document_portal_type')
if doc_portal_type == 'Purchase Invoice Transaction': if doc_portal_type == 'Purchase Invoice Transaction':
...@@ -61,7 +67,7 @@ interval_list = interval_list_dict[aggregation_level] ...@@ -61,7 +67,7 @@ interval_list = interval_list_dict[aggregation_level]
interval_column_list = [] interval_column_list = []
if group_by == "client": if group_by == "client":
interval_column_list.extend([("Amount %s" %x,"Amount %s" %x) for x in interval_list]) interval_column_list.extend([("Amount %s" %x,"Amount %s" %x) for x in interval_list])
selection_columns = [('client', "Client")] selection_columns = [('client', "Third Party")]
total_column_list = [('total amount', 'Total Amount'),] total_column_list = [('total amount', 'Total Amount'),]
stat_columns = [('client', "client")] stat_columns = [('client', "client")]
total_stat_list = [('total amount', 'total amount'),] total_stat_list = [('total amount', 'total amount'),]
...@@ -70,7 +76,7 @@ else: ...@@ -70,7 +76,7 @@ else:
selection_columns = [('product', "Product")] selection_columns = [('product', "Product")]
stat_columns = [('product', "product")] stat_columns = [('product', "product")]
else: else:
selection_columns = [('client', "Client"), ('product', "Product")] selection_columns = [('client', "Third Party"), ('product', "Product")]
stat_columns = [('client', "client"), ('product', "product")] stat_columns = [('client', "client"), ('product', "product")]
for x in interval_list: for x in interval_list:
interval_column_list.extend([("Amount %s" %x,"Amount %s" %x), ("Quantity %s" %x,"Quantity %s" %x), interval_column_list.extend([("Amount %s" %x,"Amount %s" %x), ("Quantity %s" %x,"Quantity %s" %x),
......
...@@ -89,14 +89,14 @@ ...@@ -89,14 +89,14 @@
<key> <string>left</string> </key> <key> <string>left</string> </key>
<value> <value>
<list> <list>
<string>your_aggregation_level</string> <string>your_section_category</string>
<string>your_from_date</string>
<string>your_at_date</string> <string>your_at_date</string>
<string>your_delivery_mode</string> <string>your_delivery_mode</string>
<string>your_from_date</string>
<string>your_group_by</string>
<string>your_incoterm</string> <string>your_incoterm</string>
<string>your_order</string> <string>your_order</string>
<string>your_section_category</string> <string>your_aggregation_level</string>
<string>your_group_by</string>
<string>your_simulation_state</string> <string>your_simulation_state</string>
</list> </list>
</value> </value>
......
...@@ -95,14 +95,14 @@ ...@@ -95,14 +95,14 @@
<key> <string>left</string> </key> <key> <string>left</string> </key>
<value> <value>
<list> <list>
<string>your_aggregation_level</string> <string>your_section_category</string>
<string>your_from_date</string>
<string>your_at_date</string> <string>your_at_date</string>
<string>your_delivery_mode</string> <string>your_delivery_mode</string>
<string>your_from_date</string>
<string>your_group_by</string>
<string>your_incoterm</string> <string>your_incoterm</string>
<string>your_order</string> <string>your_order</string>
<string>your_section_category</string> <string>your_aggregation_level</string>
<string>your_group_by</string>
<string>your_simulation_state</string> <string>your_simulation_state</string>
</list> </list>
</value> </value>
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
<item> <item>
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list/> <list>
<string>items</string>
</list>
</value> </value>
</item> </item>
<item> <item>
...@@ -58,6 +60,12 @@ ...@@ -58,6 +60,12 @@
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>target</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -77,6 +85,12 @@ ...@@ -77,6 +85,12 @@
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string>Base_viewTradeFieldLibrary</string> </value> <value> <string>Base_viewTradeFieldLibrary</string> </value>
</item> </item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item> <item>
<key> <string>target</string> </key> <key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value> <value> <string>Click to edit the target</string> </value>
...@@ -87,4 +101,17 @@ ...@@ -87,4 +101,17 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </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:here.Base_getTranslatedWorkflowStateItemList(wf_id=\'packing_list_workflow\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -267,6 +267,22 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -267,6 +267,22 @@ class TestTradeReports(ERP5ReportTestCase):
return sale_order return sale_order
@reindex
def _makeOneSalePackingList(self, resource_dict=None, **kw):
"""
Create a sale packing list
"""
if resource_dict is None:
resource_dict = {}
sale_packing_list = self.portal.sale_packing_list_module.newContent(portal_type="Sale Packing List", **kw)
for product, values in resource_dict.iteritems():
sale_packing_list.newContent(
portal_type="Sale Packing List Line",
resource=product,
quantity=values["quantity"],
price=values["price"])
return sale_packing_list
def _createSaleOrdersForSaleOrderReportTest(self): def _createSaleOrdersForSaleOrderReportTest(self):
# Create sales orders to be used in testSaleOrderReportXXX tests # Create sales orders to be used in testSaleOrderReportXXX tests
self._makeOneSaleOrder( self._makeOneSaleOrder(
...@@ -318,6 +334,19 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -318,6 +334,19 @@ class TestTradeReports(ERP5ReportTestCase):
cancel=True cancel=True
) )
# create also packing lists
self._makeOneSalePackingList(
title='SPL 1 (same as SO 3, but delivered state)',
destination_value=self.organisation_module.Organisation_2,
destination_section_value=self.organisation_module.Organisation_2,
destination_decision_value=self.organisation_module.Organisation_2,
source_value=self.organisation_module.Organisation_1,
source_section_value=self.organisation_module.Organisation_1,
source_decision_value=self.organisation_module.Organisation_1,
start_date=DateTime(2006, 2, 22),
resource_dict = {'product_module/product_A':{"quantity":5, "price":3},
'product_module/product_B':{"quantity":1, "price":6},}
)
self.tic() self.tic()
def testSaleOrderReportBefore2006(self): def testSaleOrderReportBefore2006(self):
...@@ -889,8 +918,88 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -889,8 +918,88 @@ class TestTradeReports(ERP5ReportTestCase):
'total quantity': None} 'total quantity': None}
self.checkLineProperties(stat_line_list[0],**d) self.checkLineProperties(stat_line_list[0],**d)
def testSalePackingListReport(self):
"""Using Sale Packing Lists, not sales Order
"""
self._createSaleOrdersForSaleOrderReportTest()
request = self.portal.REQUEST
request['from_date'] = DateTime(2006, 1, 1)
request['at_date'] = DateTime(2006, 12, 31)
request['simulation_state'] = ['draft',]
request['aggregation_level'] = "year"
request['group_by'] = "both"
request['section_category'] = 'group/g1'
parameter_dict, _, _ = self.portal.sale_packing_list_module.OrderModule_getOrderReportParameterDict()
active_process = self.portal.sale_packing_list_module.OrderModule_activateGetOrderStatList(tag="unit_test", **parameter_dict)
request['active_process'] = active_process.getPath()
self.tic()
report_section_list = self.getReportSectionList(self.portal.sale_packing_list_module,
'OrderModule_viewOrderReport')
self.assertEqual(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()]
stat_line_list = [l for l in line_list if l.isStatLine()]
self.assertEqual(3, len(data_line_list))
# test columns values
line = data_line_list[0]
self.assertEqual(line.column_id_list, ['client',
'product',
'Amount 2006',
'Quantity 2006',
'Quantity Unit 2006',
'total amount',
'total quantity'])
d = {
'Amount 2006': 21.0,
'Quantity 2006': None,
'Quantity Unit 2006': None,
'client': 'Organisation_2',
'product': None,
'total amount': 21.0,
'total quantity': None,
}
self.checkLineProperties(data_line_list[0],**d)
d = {
'Amount 2006': 15.0,
'Quantity 2006': 5.0,
'Quantity Unit 2006': 'G',
'client': None,
'product': 'product_A',
'total amount': 15.0,
'total quantity': 5.0,
}
self.checkLineProperties(data_line_list[1],**d)
d = {
'Amount 2006': 6.0,
'Quantity 2006': 1.0,
'Quantity Unit 2006': 'Kg',
'client': None,
'product': 'product_B',
'total amount': 6.0,
'total quantity': 1.0,
}
self.checkLineProperties(data_line_list[2],**d)
# stat line
d = {
'Amount 2006': 21.0,
'Quantity 2006': None,
'Quantity Unit 2006': None,
'client': 'Total',
'product': None,
'total amount': 21.0,
'total quantity': None,
}
self.checkLineProperties(stat_line_list[0],**d)
def _createInventoryForStockReportTest(self): def _createInventoryForStockReportTest(self):
# Create inventories
# Create inventories # Create inventories
self._makeOneInventory( self._makeOneInventory(
title='Inventory 1', title='Inventory 1',
......
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