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

Look on the whole model hierarchy to get properties when applying model.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20131 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5e0acedf
...@@ -71,32 +71,41 @@ paysheet = context\n ...@@ -71,32 +71,41 @@ paysheet = context\n
model = paysheet.getSpecialiseValue()\n model = paysheet.getSpecialiseValue()\n
\n \n
if model is None:\n if model is None:\n
redirect_url = \'%s/%s?%s\' % ( context.absolute_url(), form_id\n return context.Base_redirect(form_id,\n
, \'portal_status_message=\' + N_(\'No Pay Sheet Model.\'))\n keep_items=dict(portal_status_message=N_(\'No Pay Sheet Model.\')))\n
else:\n
\n \n
# set source and destination from the model if there is no value yet defined\n def getPropertyFromModel(model, property_name):\n
if paysheet.getDestinationSectionTitle() is None:\n """Get a property from the paysheet model, or from a specialised model.\n
paysheet.setDestinationSectionValue(model.getDestinationSectionValue())\n """\n
if paysheet.getSourceSectionTitle() is None:\n v = model.getProperty(property_name)\n
paysheet.setSourceSectionValue(model.getSourceSectionValue())\n if v:\n
return v\n
for specialised_model in model.getSpecialiseValueList():\n
v = getPropertyFromModel(specialised_model, property_name)\n
if v:\n
return v\n
\n \n
if paysheet.getPriceCurrency() is None:\n # set source and destination from the model if there is no value yet defined\n
paysheet.setPriceCurrencyValue(model.getPriceCurrencyValue())\n if not paysheet.getDestinationSection():\n
paysheet.setDestinationSection(getPropertyFromModel(model, \'destination_section\'))\n
\n \n
# copy model sub objects into paysheet\n if not paysheet.getSourceSection():\n
portal_type_list = [\'Annotation Line\', \'Payment Condition\', \n paysheet.setSourceSection(getPropertyFromModel(model, \'source_section\'))\n
\'Pay Sheet Model Ratio Line\']\n
paysheet.PaySheetTransaction_copySubObject(portal_type_list)\n
\n \n
if not paysheet.getPriceCurrency():\n
paysheet.setPriceCurrency(getPropertyFromModel(model, \'price_currency\'))\n
\n \n
redirect_url = \'%s/%s?%s\' % (context.absolute_url(), form_id,\n if not paysheet.getResource():\n
\'portal_status_message=\'+ N_(\'Pay Sheet Transaction updated.\'))\n paysheet.setResource(getPropertyFromModel(model, \'price_currency\'))\n
\n \n
if batch_mode:\n # copy model sub objects into paysheet\n
return None\n portal_type_list = [\'Annotation Line\', \'Payment Condition\', \n
else:\n \'Pay Sheet Model Ratio Line\']\n
context.REQUEST[ \'RESPONSE\' ].redirect( redirect_url.replace(\' \', \'+\') )\n paysheet.PaySheetTransaction_copySubObject(portal_type_list)\n
\n
if not batch_mode:\n
return context.Base_redirect(form_id,\n
keep_items=dict(portal_status_message=N_(\'Pay Sheet Transaction updated.\')))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -113,7 +122,7 @@ else:\n ...@@ -113,7 +122,7 @@ else:\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>form_id, batch_mode=0</string> </value> <value> <string>form_id=\'view\', batch_mode=0</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -147,9 +156,9 @@ else:\n ...@@ -147,9 +156,9 @@ else:\n
<string>paysheet</string> <string>paysheet</string>
<string>model</string> <string>model</string>
<string>None</string> <string>None</string>
<string>redirect_url</string> <string>dict</string>
<string>getPropertyFromModel</string>
<string>portal_type_list</string> <string>portal_type_list</string>
<string>_getitem_</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -162,6 +171,7 @@ else:\n ...@@ -162,6 +171,7 @@ else:\n
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<tuple> <tuple>
<string>view</string>
<int>0</int> <int>0</int>
</tuple> </tuple>
</value> </value>
......
223 229
\ 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