From 8e4d2c779e1f813a038485cf1f0e1801cca08498 Mon Sep 17 00:00:00 2001
From: Yusei Tahara <yusei@nexedi.com>
Date: Tue, 1 Dec 2009 02:34:13 +0000
Subject: [PATCH] 2009-12-1 yusei * Add calculation script field and create
 line field to trade model line view. * Modify quantity field on trade model
 line view to display floating number only if quantity property has value and
 is not set to None. * Modify resource field on trade model line and allow
 users to choose Product document.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30948 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_trade/TradeModelLine_view.xml        |   2 +
 .../my_calculation_script_id.xml              | 104 +++++++++++++
 .../TradeModelLine_view/my_create_line.xml    | 139 ++++++++++++++++++
 .../TradeModelLine_view/my_quantity.xml       |  35 +++++
 .../TradeModelLine_view/my_resource_title.xml |   6 +-
 bt5/erp5_trade/bt/change_log                  |   5 +
 bt5/erp5_trade/bt/revision                    |   2 +-
 7 files changed, 291 insertions(+), 2 deletions(-)
 create mode 100644 bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_calculation_script_id.xml
 create mode 100644 bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_create_line.xml

diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view.xml
index 481402ee3f..d958e4f52b 100644
--- a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view.xml
+++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view.xml
@@ -109,6 +109,8 @@
                         <string>my_quantity</string>
                         <string>my_efficiency</string>
                         <string>my_target_level</string>
+                        <string>my_calculation_script_id</string>
+                        <string>my_create_line</string>
                       </list>
                     </value>
                 </item>
diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_calculation_script_id.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_calculation_script_id.xml
new file mode 100644
index 0000000000..0c844b0d43
--- /dev/null
+++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_calculation_script_id.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>delegated_list</string> </key>
+            <value>
+              <list>
+                <string>description</string>
+                <string>title</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>my_calculation_script_id</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>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>tales</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>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>description</string> </key>
+                    <value> <string>This script is used for customization to handle complex requirements.</string> </value>
+                </item>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string>my_string_field</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewFieldLibrary</string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string>Click to edit the target</string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string>Custom Calculation Script</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_create_line.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_create_line.xml
new file mode 100644
index 0000000000..b123b01ec5
--- /dev/null
+++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_create_line.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>delegated_list</string> </key>
+            <value>
+              <list>
+                <string>default</string>
+                <string>description</string>
+                <string>title</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>my_create_line</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>
+                <item>
+                    <key> <string>target</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>description</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>target</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> <int>0</int> </value>
+                </item>
+                <item>
+                    <key> <string>description</string> </key>
+                    <value> <string>Useful for intermediated lines.</string> </value>
+                </item>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string>my_checkbox</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewFieldLibrary</string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string>Click to edit the target</string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string>Create Line</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <global name="TALESMethod" module="Products.Formulator.TALESField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_text</string> </key>
+            <value> <string>here/isCreateLine</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_quantity.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_quantity.xml
index 3be0984ad8..229c1136cb 100644
--- a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_quantity.xml
+++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_quantity.xml
@@ -13,6 +13,7 @@
             <key> <string>delegated_list</string> </key>
             <value>
               <list>
+                <string>default</string>
                 <string>description</string>
                 <string>title</string>
               </list>
@@ -56,6 +57,16 @@
             <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>description</string> </key>
+                    <value> <string></string> </value>
+                </item>
                 <item>
                     <key> <string>field_id</string> </key>
                     <value> <string></string> </value>
@@ -68,6 +79,10 @@
                     <key> <string>target</string> </key>
                     <value> <string></string> </value>
                 </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string></string> </value>
+                </item>
               </dictionary>
             </value>
         </item>
@@ -75,6 +90,10 @@
             <key> <string>values</string> </key>
             <value>
               <dictionary>
+                <item>
+                    <key> <string>default</string> </key>
+                    <value> <string></string> </value>
+                </item>
                 <item>
                     <key> <string>description</string> </key>
                     <value> <string>Trade Model Line with a Fixed Quantity. If this is set, Ratio is ignored.</string> </value>
@@ -101,4 +120,20 @@
       </dictionary>
     </pickle>
   </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <global name="TALESMethod" module="Products.Formulator.TALESField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_text</string> </key>
+            <value> <string>python:test(here.getQuantity(None) is None, \'\', here.getQuantity())</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
 </ZopeData>
diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_resource_title.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_resource_title.xml
index 75ba65ac71..0d342e2184 100644
--- a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_resource_title.xml
+++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/TradeModelLine_view/my_resource_title.xml
@@ -13,8 +13,8 @@
             <key> <string>delegated_list</string> </key>
             <value>
               <list>
-                <string>title</string>
                 <string>portal_type</string>
+                <string>title</string>
               </list>
             </value>
         </item>
@@ -91,6 +91,10 @@
                           <string>Service</string>
                           <string>Service</string>
                         </tuple>
+                        <tuple>
+                          <string>Product</string>
+                          <string>Product</string>
+                        </tuple>
                       </list>
                     </value>
                 </item>
diff --git a/bt5/erp5_trade/bt/change_log b/bt5/erp5_trade/bt/change_log
index d20a85aa9e..46aca2f300 100644
--- a/bt5/erp5_trade/bt/change_log
+++ b/bt5/erp5_trade/bt/change_log
@@ -1,3 +1,8 @@
+2009-12-1 yusei
+* Add calculation script field and create line field to trade model line view.
+* Modify quantity field on trade model line view to display floating number only if quantity property has value and is not set to None.
+* Modify resource field on trade model line and allow users to choose Product document.
+
 2009-11-26 yusei
 * Add target level field to trade model line view.
 
diff --git a/bt5/erp5_trade/bt/revision b/bt5/erp5_trade/bt/revision
index 35d29653bf..4d5b34789e 100644
--- a/bt5/erp5_trade/bt/revision
+++ b/bt5/erp5_trade/bt/revision
@@ -1 +1 @@
-791
\ No newline at end of file
+793
\ No newline at end of file
-- 
2.30.9