Commit 660ca7a3 authored by Fabien Morin's avatar Fabien Morin

2009-02-04 fabien

* when a specialise model is defined on a paysheet, apply it automatically
* rewrite the apply model script

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25445 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ae9367e6
...@@ -53,9 +53,18 @@ ...@@ -53,9 +53,18 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>Base_translateString = context.Base_translateString\n <value> <string encoding="cdata"><![CDATA[
Base_translateString = context.Base_translateString\n
paysheet = context\n paysheet = context\n
\n \n
# copy categories\n
category_list = [\n
\'destination_section\', \'source_section\', \'source_payment\',\n
\'destination_payment\', \'price_currency\', \'ressource\',\n
]\n
new_category_dict = {}\n
\n
model = paysheet.getSpecialiseValue()\n model = paysheet.getSpecialiseValue()\n
\n \n
if model is None:\n if model is None:\n
...@@ -73,24 +82,26 @@ def getPropertyFromModel(model, property_name):\n ...@@ -73,24 +82,26 @@ def getPropertyFromModel(model, property_name):\n
if v:\n if v:\n
return v\n return v\n
\n \n
# set source and destination from the model if there is no value yet defined\n for category in category_list:\n
if not paysheet.getDestinationSection():\n if force or not paysheet.getPropertyList(category):\n
paysheet.setDestinationSection(getPropertyFromModel(model, \'destination_section\'))\n v = getPropertyFromModel(model, category)\n
\n if v:\n
if not paysheet.getSourceSection():\n new_category_dict[category] = v\n
paysheet.setSourceSection(getPropertyFromModel(model, \'source_section\'))\n
\n
if not paysheet.getSourcePayment():\n
paysheet.setSourcePayment(getPropertyFromModel(model, \'source_payment\'))\n
\n
if not paysheet.getDestinationPayment():\n
paysheet.setDestinationPayment(getPropertyFromModel(model, \'destination_payment\'))\n
\n \n
if not paysheet.getPriceCurrency():\n def copyPaymentCondition(paysheet, model):\n
paysheet.setPriceCurrency(getPropertyFromModel(model, \'price_currency\'))\n filter_dict = {\'portal_type\': \'Payment Condition\'}\n
to_copy = model.contentIds(filter=filter_dict)\n
if len(to_copy) > 0 :\n
copy_data = model.manage_copyObjects(ids=to_copy)\n
paysheet.manage_pasteObjects(copy_data)\n
for other_models in model.getSpecialiseValueList():\n
copyPaymentCondition(paysheet, other_models)\n
\n \n
if not paysheet.getResource():\n filter_dict = {\'portal_type\': \'Payment Condition\'}\n
paysheet.setResource(getPropertyFromModel(model, \'price_currency\'))\n if force:\n
paysheet.manage_delObjects(list(paysheet.contentIds(filter=filter_dict)))\n
if len(paysheet.contentIds(filter=filter_dict)) == 0:\n
copyPaymentCondition(paysheet, model)\n
\n \n
# copy model sub objects into paysheet\n # copy model sub objects into paysheet\n
paysheet.PaySheetTransaction_copySubObject(\n paysheet.PaySheetTransaction_copySubObject(\n
...@@ -101,10 +112,14 @@ paysheet.PaySheetTransaction_copySubObject(\n ...@@ -101,10 +112,14 @@ paysheet.PaySheetTransaction_copySubObject(\n
property_list=(\'quantity\',))\n property_list=(\'quantity\',))\n
paysheet.PaySheetTransaction_copySubObject(\'Payment Condition\')\n paysheet.PaySheetTransaction_copySubObject(\'Payment Condition\')\n
\n \n
paysheet.edit(**new_category_dict)\n
\n
if not batch_mode:\n if not batch_mode:\n
return context.Base_redirect(form_id,\n return context.Base_redirect(form_id,\n
keep_items=dict(portal_status_message=Base_translateString(\'Pay Sheet Transaction updated.\')))\n keep_items=dict(portal_status_message=Base_translateString(\'Pay Sheet Transaction updated.\')))\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -114,7 +129,7 @@ if not batch_mode:\n ...@@ -114,7 +129,7 @@ if not batch_mode:\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>form_id=\'view\', batch_mode=0</string> </value> <value> <string>form_id=\'view\', batch_mode=0, force=0</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -134,7 +149,7 @@ if not batch_mode:\n ...@@ -134,7 +149,7 @@ if not batch_mode:\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>2</int> </value> <value> <int>3</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
...@@ -142,14 +157,26 @@ if not batch_mode:\n ...@@ -142,14 +157,26 @@ if not batch_mode:\n
<tuple> <tuple>
<string>form_id</string> <string>form_id</string>
<string>batch_mode</string> <string>batch_mode</string>
<string>force</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>Base_translateString</string> <string>Base_translateString</string>
<string>paysheet</string> <string>paysheet</string>
<string>category_list</string>
<string>new_category_dict</string>
<string>model</string> <string>model</string>
<string>None</string> <string>None</string>
<string>dict</string> <string>dict</string>
<string>getPropertyFromModel</string> <string>getPropertyFromModel</string>
<string>_getiter_</string>
<string>category</string>
<string>v</string>
<string>_write_</string>
<string>copyPaymentCondition</string>
<string>filter_dict</string>
<string>list</string>
<string>len</string>
<string>_apply_</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -164,6 +191,7 @@ if not batch_mode:\n ...@@ -164,6 +191,7 @@ if not batch_mode:\n
<tuple> <tuple>
<string>view</string> <string>view</string>
<int>0</int> <int>0</int>
<int>0</int>
</tuple> </tuple>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</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>_body</string> </key>
<value> <string>context.setSpecialiseUidList(relation_uid_list, portal_type=portal_type)\n
\n
if relation_uid_list:\n
context.PaySheetTransaction_applyModel(force=1)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>relation_uid_list, portal_type</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>relation_uid_list</string>
<string>portal_type</string>
<string>_getattr_</string>
<string>context</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaySheetTransaction_setSpecialiseAndApplyModel</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<string>base_category</string> <string>base_category</string>
<string>portal_type</string> <string>portal_type</string>
<string>catalog_index</string> <string>catalog_index</string>
<string>relation_setter_id</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -133,6 +134,10 @@ ...@@ -133,6 +134,10 @@
<key> <string>read_only</string> </key> <key> <string>read_only</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
</item> </item>
<item>
<key> <string>relation_setter_id</string> </key>
<value> <string>PaySheetTransaction_setSpecialiseAndApplyModel</string> </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>
......
2009-02-04 fabien
* when a specialise model is defined on a paysheet, apply it automatically
* rewrite the apply model script
2009-01-28 fabien 2009-01-28 fabien
* remove some unused script and refeactor some very similar scripts in a generic one * remove some unused script and refeactor some very similar scripts in a generic one
......
346 348
\ No newline at end of file \ No newline at end of file
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