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
model = paysheet.getSpecialiseValue()\n
\n
if model is None:\n
redirect_url = \'%s/%s?%s\' % ( context.absolute_url(), form_id\n
, \'portal_status_message=\' + N_(\'No Pay Sheet Model.\'))\n
else:\n
return context.Base_redirect(form_id,\n
keep_items=dict(portal_status_message=N_(\'No Pay Sheet Model.\')))\n
\n
# set source and destination from the model if there is no value yet defined\n
if paysheet.getDestinationSectionTitle() is None:\n
paysheet.setDestinationSectionValue(model.getDestinationSectionValue())\n
if paysheet.getSourceSectionTitle() is None:\n
paysheet.setSourceSectionValue(model.getSourceSectionValue())\n
def getPropertyFromModel(model, property_name):\n
"""Get a property from the paysheet model, or from a specialised model.\n
"""\n
v = model.getProperty(property_name)\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
if paysheet.getPriceCurrency() is None:\n
paysheet.setPriceCurrencyValue(model.getPriceCurrencyValue())\n
# set source and destination from the model if there is no value yet defined\n
if not paysheet.getDestinationSection():\n
paysheet.setDestinationSection(getPropertyFromModel(model, \'destination_section\'))\n
\n
# copy model sub objects into paysheet\n
portal_type_list = [\'Annotation Line\', \'Payment Condition\', \n
\'Pay Sheet Model Ratio Line\']\n
paysheet.PaySheetTransaction_copySubObject(portal_type_list)\n
if not paysheet.getSourceSection():\n
paysheet.setSourceSection(getPropertyFromModel(model, \'source_section\'))\n
\n
if not paysheet.getPriceCurrency():\n
paysheet.setPriceCurrency(getPropertyFromModel(model, \'price_currency\'))\n
\n
redirect_url = \'%s/%s?%s\' % (context.absolute_url(), form_id,\n
\'portal_status_message=\'+ N_(\'Pay Sheet Transaction updated.\'))\n
if not paysheet.getResource():\n
paysheet.setResource(getPropertyFromModel(model, \'price_currency\'))\n
\n
if batch_mode:\n
return None\n
else:\n
context.REQUEST[ \'RESPONSE\' ].redirect( redirect_url.replace(\' \', \'+\') )\n
# copy model sub objects into paysheet\n
portal_type_list = [\'Annotation Line\', \'Payment Condition\', \n
\'Pay Sheet Model Ratio Line\']\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>
</item>
<item>
......@@ -113,7 +122,7 @@ else:\n
</item>
<item>
<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>
<key> <string>errors</string> </key>
......@@ -147,9 +156,9 @@ else:\n
<string>paysheet</string>
<string>model</string>
<string>None</string>
<string>redirect_url</string>
<string>dict</string>
<string>getPropertyFromModel</string>
<string>portal_type_list</string>
<string>_getitem_</string>
</tuple>
</value>
</item>
......@@ -162,6 +171,7 @@ else:\n
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<string>view</string>
<int>0</int>
</tuple>
</value>
......
223
\ No newline at end of file
229
\ 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