From bfbef96e5b79b4007ae29bc956457a176b93029c Mon Sep 17 00:00:00 2001
From: Nicolas Wavrant <nicolas.wavrant@nexedi.com>
Date: Tue, 30 Jul 2019 03:48:17 +0000
Subject: [PATCH] erp5_trade_ui_test: add functional tests on the use of "price
 per slice"

---
 .../testInternalSupplyLinePricePerSlice.xml   |  58 +++++
 .../testInternalSupplyLinePricePerSlice.zpt   | 217 ++++++++++++++++++
 .../testPurchaseSupplyLinePricePerSlice.xml   |  58 +++++
 .../testPurchaseSupplyLinePricePerSlice.zpt   | 217 ++++++++++++++++++
 .../testSaleSupplyLinePricePerSlice.xml       |  58 +++++
 .../testSaleSupplyLinePricePerSlice.zpt       | 216 +++++++++++++++++
 .../Zuite_CommonTemplateForTradeZuite.zpt     |  12 +
 ...Zuite_createTradeConditionForTradeZuite.py |  36 +++
 ...uite_createTradeConditionForTradeZuite.xml |  62 +++++
 .../Zuite_deleteDataForTradeZuite.py          |  18 +-
 10 files changed, 948 insertions(+), 4 deletions(-)
 create mode 100644 bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testInternalSupplyLinePricePerSlice.xml
 create mode 100644 bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testInternalSupplyLinePricePerSlice.zpt
 create mode 100644 bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testPurchaseSupplyLinePricePerSlice.xml
 create mode 100644 bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testPurchaseSupplyLinePricePerSlice.zpt
 create mode 100644 bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testSaleSupplyLinePricePerSlice.xml
 create mode 100644 bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testSaleSupplyLinePricePerSlice.zpt
 create mode 100644 bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_createTradeConditionForTradeZuite.py
 create mode 100644 bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_createTradeConditionForTradeZuite.xml

diff --git a/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testInternalSupplyLinePricePerSlice.xml b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testInternalSupplyLinePricePerSlice.xml
new file mode 100644
index 0000000000..af49321d23
--- /dev/null
+++ b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testInternalSupplyLinePricePerSlice.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>content_type</string> </key>
+            <value> <string>text/html</string> </value>
+        </item>
+        <item>
+            <key> <string>expand</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>testInternalSupplyLinePricePerSlice</string> </value>
+        </item>
+        <item>
+            <key> <string>output_encoding</string> </key>
+            <value> <string>utf-8</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <unicode></unicode> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testInternalSupplyLinePricePerSlice.zpt b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testInternalSupplyLinePricePerSlice.zpt
new file mode 100644
index 0000000000..2ff7ac919b
--- /dev/null
+++ b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testInternalSupplyLinePricePerSlice.zpt
@@ -0,0 +1,217 @@
+<html>
+<head><title>Test toggling price per slice updates internal supply cells correctly</title></head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="4">
+Test quantity steps for price on internal supply line
+</td></tr>
+</thead>
+<tbody tal:define="init_method string:PdmZuite_createDelivery?state=draft&delivery_type=Internal">
+<!-- Setup {{{ -->
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/init" />
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_deleteDataForTradeZuite</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Deleted Successfully.</td>
+  <td></td>
+</tr>
+
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_waitForActivities</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Done.</td>
+  <td></td>
+</tr>
+
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_resetForTradeZuite</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Reset Successfully.</td>
+  <td></td>
+</tr>
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/Zuite_createTradeConditionForTradeZuite?delivery_type=Internal" />
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Internal Trade Condition Created.</td>
+  <td></td>
+</tr>
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_waitForActivities</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Done.</td>
+  <td></td>
+</tr>
+<!-- }}} -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/internal_trade_condition_module/erp5_trade_ui_test_trade_condition/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>field_my_base_unit_price</td>
+  <td>0.00001</td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>link=Base Price</td>
+  <td></td>
+</tr>
+<!-- Enter quantity step list and check -->
+<tr>
+  <td>type</td>
+  <td>field_my_quantity_step_list</td>
+  <td>11<br />21</td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>field_my_quantity_step_list</td>
+  <td>11.0 21.0</td>
+<tr>
+  <td>assertText</td>
+  <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
+  <td>Quantity &lt; 11.0</td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>//input[@name="field_matrixbox_base_price_cell_1_0_0"]/../../../td[1]</td>
+  <td>11.0 &lt;= Quantity &lt; 21.0</td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>//input[@name="field_matrixbox_base_price_cell_2_0_0"]/../../../td[1]</td>
+  <td>21.0 &lt;= Quantity</td>
+</tr>
+<tr>
+<!-- Enter price per quantity step and check-->
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/enterAndCheckPricePerSliceInSupplyLine" />
+<!-- Open Delivery Line with the product and check price is correct -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/internal_packing_list_module/erp5_pdm_ui_test_delivery/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>//input[@name="field_my_quantity"]</td>
+  <td>15</td>
+</tr>
+  <tr>
+  <td>type</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertFloatValue</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td>9</td>
+</tr>
+<!-- Select the new method "Price per slice" on the Internal Supply
+     and enter the prices again-->
+<tr>
+  <td>open</td>
+  <td>${base_url}/internal_trade_condition_module/erp5_trade_ui_test_trade_condition/1/InternalSupplyLine_viewBasePrice</td>
+  <td></td>
+</tr>
+<tal:block metal:use-macro="here/Zuite_CommonTemplateForTradeZuite/macros/toggleSupplyLineBasePricePerSlice" />
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/enterAndCheckPricePerSliceInSupplyLine" />
+<!-- Open Delivery Line with the product and check price is correct -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/internal_packing_list_module/erp5_pdm_ui_test_delivery/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>//input[@name="field_my_quantity"]</td>
+  <td>15</td>
+</tr>
+  <tr>
+  <td>type</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertFloatValue</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td>9.66667</td>
+</tr>
+<!-- Unselect the new method "Price per slice" on the Internal Supply
+     and enter the prices again-->
+<tr>
+  <td>open</td>
+  <td>${base_url}/internal_trade_condition_module/erp5_trade_ui_test_trade_condition/1/InternalSupplyLine_viewBasePrice</td>
+  <td></td>
+</tr>
+<tal:block metal:use-macro="here/Zuite_CommonTemplateForTradeZuite/macros/toggleSupplyLineBasePricePerSlice" />
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/enterAndCheckPricePerSliceInSupplyLine" />
+<!-- Open Delivery Line with the product and check price is correct -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/internal_packing_list_module/erp5_pdm_ui_test_delivery/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>//input[@name="field_my_quantity"]</td>
+  <td>15</td>
+</tr>
+  <tr>
+  <td>type</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertFloatValue</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td>9</td>
+</tr>
+</tbody></table>
+</body>
+</html>
\ No newline at end of file
diff --git a/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testPurchaseSupplyLinePricePerSlice.xml b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testPurchaseSupplyLinePricePerSlice.xml
new file mode 100644
index 0000000000..5c731f0d8f
--- /dev/null
+++ b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testPurchaseSupplyLinePricePerSlice.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>content_type</string> </key>
+            <value> <string>text/html</string> </value>
+        </item>
+        <item>
+            <key> <string>expand</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>testPurchaseSupplyLinePricePerSlice</string> </value>
+        </item>
+        <item>
+            <key> <string>output_encoding</string> </key>
+            <value> <string>utf-8</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <unicode></unicode> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testPurchaseSupplyLinePricePerSlice.zpt b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testPurchaseSupplyLinePricePerSlice.zpt
new file mode 100644
index 0000000000..e2520d860b
--- /dev/null
+++ b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testPurchaseSupplyLinePricePerSlice.zpt
@@ -0,0 +1,217 @@
+<html>
+<head><title>Test toggling price per slice updates purchase supply cells correctly</title></head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="4">
+Test quantity steps for price on purchase supply line
+</td></tr>
+</thead>
+<tbody tal:define="init_method string:PdmZuite_createDelivery?state=draft&delivery_type=Purchase">
+<!-- Setup {{{ -->
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/init" />
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_deleteDataForTradeZuite</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Deleted Successfully.</td>
+  <td></td>
+</tr>
+
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_waitForActivities</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Done.</td>
+  <td></td>
+</tr>
+
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_resetForTradeZuite</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Reset Successfully.</td>
+  <td></td>
+</tr>
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/Zuite_createTradeConditionForTradeZuite?delivery_type=Purchase" />
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Purchase Trade Condition Created.</td>
+  <td></td>
+</tr>
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_waitForActivities</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Done.</td>
+  <td></td>
+</tr>
+<!-- }}} -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/purchase_trade_condition_module/erp5_trade_ui_test_trade_condition/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>field_my_base_unit_price</td>
+  <td>0.00001</td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>link=Base Price</td>
+  <td></td>
+</tr>
+<!-- Enter quantity step list and check -->
+<tr>
+  <td>type</td>
+  <td>field_my_quantity_step_list</td>
+  <td>11<br />21</td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>field_my_quantity_step_list</td>
+  <td>11.0 21.0</td>
+<tr>
+  <td>assertText</td>
+  <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
+  <td>Quantity &lt; 11.0</td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>//input[@name="field_matrixbox_base_price_cell_1_0_0"]/../../../td[1]</td>
+  <td>11.0 &lt;= Quantity &lt; 21.0</td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>//input[@name="field_matrixbox_base_price_cell_2_0_0"]/../../../td[1]</td>
+  <td>21.0 &lt;= Quantity</td>
+</tr>
+<tr>
+<!-- Enter price per quantity step and check-->
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/enterAndCheckPricePerSliceInSupplyLine" />
+<!-- Open Delivery Line with the product and check price is correct -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/purchase_packing_list_module/erp5_pdm_ui_test_delivery/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>//input[@name="field_my_quantity"]</td>
+  <td>15</td>
+</tr>
+  <tr>
+  <td>type</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertFloatValue</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td>9</td>
+</tr>
+<!-- Select the new method "Price per slice" on the Purchase Supply
+     and enter the prices again-->
+<tr>
+  <td>open</td>
+  <td>${base_url}/purchase_trade_condition_module/erp5_trade_ui_test_trade_condition/1/PurchaseSupplyLine_viewBasePrice</td>
+  <td></td>
+</tr>
+<tal:block metal:use-macro="here/Zuite_CommonTemplateForTradeZuite/macros/toggleSupplyLineBasePricePerSlice" />
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/enterAndCheckPricePerSliceInSupplyLine" />
+<!-- Open Delivery Line with the product and check price is correct -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/purchase_packing_list_module/erp5_pdm_ui_test_delivery/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>//input[@name="field_my_quantity"]</td>
+  <td>15</td>
+</tr>
+  <tr>
+  <td>type</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertFloatValue</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td>9.66667</td>
+</tr>
+<!-- Unselect the new method "Price per slice" on the Purchase Supply
+     and enter the prices again-->
+<tr>
+  <td>open</td>
+  <td>${base_url}/purchase_trade_condition_module/erp5_trade_ui_test_trade_condition/1/PurchaseSupplyLine_viewBasePrice</td>
+  <td></td>
+</tr>
+<tal:block metal:use-macro="here/Zuite_CommonTemplateForTradeZuite/macros/toggleSupplyLineBasePricePerSlice" />
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/enterAndCheckPricePerSliceInSupplyLine" />
+<!-- Open Delivery Line with the product and check price is correct -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/purchase_packing_list_module/erp5_pdm_ui_test_delivery/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>//input[@name="field_my_quantity"]</td>
+  <td>15</td>
+</tr>
+  <tr>
+  <td>type</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertFloatValue</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td>9</td>
+</tr>
+</tbody></table>
+</body>
+</html>
\ No newline at end of file
diff --git a/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testSaleSupplyLinePricePerSlice.xml b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testSaleSupplyLinePricePerSlice.xml
new file mode 100644
index 0000000000..87d10b4296
--- /dev/null
+++ b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testSaleSupplyLinePricePerSlice.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>content_type</string> </key>
+            <value> <string>text/html</string> </value>
+        </item>
+        <item>
+            <key> <string>expand</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>testSaleSupplyLinePricePerSlice</string> </value>
+        </item>
+        <item>
+            <key> <string>output_encoding</string> </key>
+            <value> <string>utf-8</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <unicode></unicode> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testSaleSupplyLinePricePerSlice.zpt b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testSaleSupplyLinePricePerSlice.zpt
new file mode 100644
index 0000000000..cee7bc88cb
--- /dev/null
+++ b/bt5/erp5_trade_ui_test/PathTemplateItem/portal_tests/trade_zuite/testSaleSupplyLinePricePerSlice.zpt
@@ -0,0 +1,216 @@
+<html>
+<head><title>Test toggling price per slice updates sale supply cells correctly</title></head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="4">
+Test quantity steps for price on sale supply line
+</td></tr>
+</thead>
+<tbody tal:define="init_method string:PdmZuite_createDelivery?state=draft">
+<!-- Setup {{{ -->
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/init" />
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_deleteDataForTradeZuite</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Deleted Successfully.</td>
+  <td></td>
+</tr>
+
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_waitForActivities</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Done.</td>
+  <td></td>
+</tr>
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_resetForTradeZuite</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Reset Successfully.</td>
+  <td></td>
+</tr>
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/Zuite_createTradeConditionForTradeZuite" />
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Sale Trade Condition Created.</td>
+  <td></td>
+</tr>
+<tr>
+  <td>open</td>
+  <td>${base_url}/Zuite_waitForActivities</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Done.</td>
+  <td></td>
+</tr>
+<!-- }}} -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/sale_trade_condition_module/erp5_trade_ui_test_trade_condition/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>field_my_base_unit_price</td>
+  <td>0.00001</td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>link=Base Price</td>
+  <td></td>
+</tr>
+<!-- Enter quantity step list and check -->
+<tr>
+  <td>type</td>
+  <td>field_my_quantity_step_list</td>
+  <td>11<br />21</td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>field_my_quantity_step_list</td>
+  <td>11.0 21.0</td>
+<tr>
+  <td>assertText</td>
+  <td>//input[@name="field_matrixbox_base_price_cell_0_0_0"]/../../../td[1]</td>
+  <td>Quantity &lt; 11.0</td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>//input[@name="field_matrixbox_base_price_cell_1_0_0"]/../../../td[1]</td>
+  <td>11.0 &lt;= Quantity &lt; 21.0</td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>//input[@name="field_matrixbox_base_price_cell_2_0_0"]/../../../td[1]</td>
+  <td>21.0 &lt;= Quantity</td>
+</tr>
+<tr>
+<!-- Enter price per quantity step and check-->
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/enterAndCheckPricePerSliceInSupplyLine" />
+<!-- Open Delivery Line with the product and check price is correct -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/sale_packing_list_module/erp5_pdm_ui_test_delivery/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>//input[@name="field_my_quantity"]</td>
+  <td>15</td>
+</tr>
+  <tr>
+  <td>type</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertFloatValue</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td>9</td>
+</tr>
+<!-- Select the new method "Price per slice" on the Sale Supply
+     and enter the prices again-->
+<tr>
+  <td>open</td>
+  <td>${base_url}/sale_trade_condition_module/erp5_trade_ui_test_trade_condition/1/SaleSupplyLine_viewBasePrice</td>
+  <td></td>
+</tr>
+<tal:block metal:use-macro="here/Zuite_CommonTemplateForTradeZuite/macros/toggleSupplyLineBasePricePerSlice" />
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/enterAndCheckPricePerSliceInSupplyLine" />
+<!-- Open Delivery Line with the product and check price is correct -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/sale_packing_list_module/erp5_pdm_ui_test_delivery/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>//input[@name="field_my_quantity"]</td>
+  <td>15</td>
+</tr>
+  <tr>
+  <td>type</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertFloatValue</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td>9.66667</td>
+</tr>
+<!-- Unselect the new method "Price per slice" on the Sale Supply
+     and enter the prices again-->
+<tr>
+  <td>open</td>
+  <td>${base_url}/sale_trade_condition_module/erp5_trade_ui_test_trade_condition/1/SaleSupplyLine_viewBasePrice</td>
+  <td></td>
+</tr>
+<tal:block metal:use-macro="here/Zuite_CommonTemplateForTradeZuite/macros/toggleSupplyLineBasePricePerSlice" />
+<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/enterAndCheckPricePerSliceInSupplyLine" />
+<!-- Open Delivery Line with the product and check price is correct -->
+<tr>
+  <td>open</td>
+  <td tal:content="string:$${base_url}/sale_packing_list_module/erp5_pdm_ui_test_delivery/1" />
+  <td></td>
+</tr>
+<tr>
+  <td>type</td>
+  <td>//input[@name="field_my_quantity"]</td>
+  <td>15</td>
+</tr>
+  <tr>
+  <td>type</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td></td>
+</tr>
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_edit:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertFloatValue</td>
+  <td>//input[@name="field_my_price"]</td>
+  <td>9</td>
+</tr>
+</tbody></table>
+</body>
+</html>
\ No newline at end of file
diff --git a/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_CommonTemplateForTradeZuite.zpt b/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_CommonTemplateForTradeZuite.zpt
index a7905788d7..53903945ef 100644
--- a/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_CommonTemplateForTradeZuite.zpt
+++ b/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_CommonTemplateForTradeZuite.zpt
@@ -66,4 +66,16 @@
       <td></td>
     </tr>
   </tal:block>
+  <tal:block metal:define-macro="toggleSupplyLineBasePricePerSlice">
+    <tr>
+      <td>click</td>
+      <td>//input[@name="field_my_base_price_per_slice"]</td>
+      <td></td>
+    </tr>
+    <tr>
+      <td>clickAndWait</td>
+      <td>Base_edit:method</td>
+      <td></td>
+    </tr>
+  </tal:block>
 </tal:block>
\ No newline at end of file
diff --git a/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_createTradeConditionForTradeZuite.py b/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_createTradeConditionForTradeZuite.py
new file mode 100644
index 0000000000..cd48c3ad6b
--- /dev/null
+++ b/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_createTradeConditionForTradeZuite.py
@@ -0,0 +1,36 @@
+from DateTime import DateTime
+
+portal = context.getPortalObject()
+trade_condition_portal_type = "%s Trade Condition" % delivery_type
+supply_line_portal_type = "%s Supply Line" % delivery_type
+
+trade_condition_id = "erp5_trade_ui_test_trade_condition"
+trade_condition_title = "erp5_trade_ui_test_trade_condition_title"
+
+resource_id = "erp5_pdm_ui_test_product"
+
+delivery_portal_type = "%s Packing List" % delivery_type
+
+# Create Trade Condition
+module = portal.getDefaultModule(trade_condition_portal_type)
+trade_condition = module.newContent(
+  portal_type=trade_condition_portal_type,
+  id=trade_condition_id,
+  title=trade_condition_title,
+)
+trade_condition.newContent(
+  portal_type=supply_line_portal_type,
+  resource="product_module/" + resource_id
+)
+
+trade_condition.validate()
+
+# Set it as specialise to the Delivery created by PdmZuite_createDelivery
+module = portal.getDefaultModule(delivery_portal_type)
+delivery = getattr(module, "erp5_pdm_ui_test_delivery", None)
+if delivery is not None:
+  delivery.setSpecialiseValue(trade_condition)
+else:
+  raise ValueError('Delivery not found')
+
+return trade_condition_portal_type + " Created."
diff --git a/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_createTradeConditionForTradeZuite.xml b/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_createTradeConditionForTradeZuite.xml
new file mode 100644
index 0000000000..cfa80c3f46
--- /dev/null
+++ b/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_createTradeConditionForTradeZuite.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>delivery_type="Sale"</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Zuite_createTradeConditionForTradeZuite</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_deleteDataForTradeZuite.py b/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_deleteDataForTradeZuite.py
index 5981506d99..ebeb22e277 100644
--- a/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_deleteDataForTradeZuite.py
+++ b/bt5/erp5_trade_ui_test/SkinTemplateItem/portal_skins/erp5_trade_ui_test/Zuite_deleteDataForTradeZuite.py
@@ -1,5 +1,15 @@
-try:
-  context.sale_order_module.manage_delObjects(ids=['erp5_trade_ui_test_sale_order_1'])
-except:
-  pass
+portal = context.getPortalObject()
+
+object_value_list = [
+  getattr(context.sale_order_module, 'erp5_trade_ui_test_sale_order_1', None)
+] + [
+  getattr(portal.getDefaultModule(portal_type), "erp5_trade_ui_test_trade_condition", None)
+  for portal_type in ("Internal Trade Condition", "Purchase Trade Condition", "Sale Trade Condition")
+]
+
+for object_value in object_value_list:
+  if object_value is None:
+    continue
+  object_value.getParentValue().manage_delObjects(ids=[object_value.getId()])
+
 return "Deleted Successfully."
-- 
2.30.9