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

make it possible to use another conversion rate that the one proposed by...

make it possible to use another conversion rate that the one proposed by system. This also make possible to use this action when no conversion has been found.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39046 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 91278f18
master ERP5Type_no_immediate_reindexation allow_login_change allow_login_change_differentiate_id_and_login allow_login_change_wip arnau arnau-kns arnau-kns-without-property-mapping arnau-merge arnau-poc auto_extend_select_list autoflake backup_erp5_workflow bk_erp5ish_actions_tool bk_sqlcatalog boc-interaction-drop cache catalog_fulltext catalog_fulltext_old cedric cedriclen cedriclen-eos certificate_authority cherry-pick-4a8e045d ckeditor_update cleanJSByJSLint clean_up_upgrader cmfactivity compact_title_no_reference credential_update_action datetimefield deferred_listbox douglas_forum dream_distributor drop-legacy-simulation echarts_with_event echarts_wrapper eos-dev erp5-component erp5-data-notebook erp5-forum erp5-preference erp5-release erp5-slapos-upgrade erp5-util-testing erp5-vifib erp5-vifib-cleanup erp5_calendar erp5_free_subscription erp5_officejs_fixing erp5_workflow fix/accounting_period_constraint_vs_acquired_node fix/change_state_priority fix/login_validate_check_consistency fix_system_processes_ownership for_private_testrunner_1 for_testrunner_1 for_testrunner_2 formbox gabriel gabriel-fix-rounding-in-accounting-generation gabriel-fix-rounding-in-accounting-generation2 gadget-json-value http_cache_fix import_zip_package improve_default_caching_policy_manager interaction-drop isDeletable item_tracking_graph_editor ivan jerome-bt-reference-doc jerome-test jerome_events jerome_graph_editor_renderjs jerome_new_style_solve_divergence jerome_promise_in_tests jerome_user_preference_time_zone jio jm/form-action-guard joblib-activity kns kns-kr lazy_simulation_causality lignan lingnan listbox-generator mame mame-bt5-cleanup mame-erp5_project-cleanup mame-naming-convention mame-naming-convention-list_method mame-test-stock-indexation mame-work mame2 master-erp5-test-result-scalability master-erp5-test-result-scalability-rebase master-test-fix-additionalbt5path master_calendar_wip_patches master_calendar_wip_patches_extend_security master_no_guard_on_workflow_transition master_no_guard_on_workflow_transition_plus_calendar_wip_patchs merge_xhtml_jquery mmariani-inventory mrp new-render-presentation nexedi-erp5-jp no_longer_simulated_state notebook_submodule notebook_submodule_backup officejs officejs_clean officejs_mixing_echarts pere portal_callables portal_solver_process_security_configuration presentation pyodide pyodide_submodule pyodide_webworker rebased_mrp reindex reindex_calendar_after_change_calendar_exception resursive_clone romain-fulltext scalability-master2 scalability-master2-rebase scalability-rebase shop-box simulation sms_more_than_140_characters strict_catalog submodule support_request support_request_1 support_request_2 support_request_3 support_request_4 support_request_update syncml test_page testnode_software_link timezones tristan tristan-merge tristan-performance ttr ttrm upgradeSite view-aggregated-amounts vivekpab_erp5webrenderjs_layoutconfig vivekpab_jabberclient vivekpab_renderjs_interfaces wenjie wenjie_branch xiaowu_newui yryr yryr-components-cp yryr-inventory-cache yryr-test yryr-with-components yusei erp5.util-0.4.46 erp5.util-0.4.44 erp5.util-0.4.43 erp5.util-0.4.41 erp5.util-0.4.40 erp5.util-0.4.37 erp5.util-0.4.1 erp5.util-0.4 erp5.util-0.3 erp5.util-0.2 erp5.util-0.1
No related merge requests found
......@@ -50,21 +50,18 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5.Document.Document import ConversionError\n
\n
"""\n
<value> <string>"""\n
Script to convert the prices used in the transaction to the \n
currency of the destination section\n
form_id : Page that action is called from\n
\n
\n
"""\n
\n
portal = context.getPortalObject()\n
#get the precision of the destination\n
precision =context.getDestinationSectionValue().getPriceCurrencyValue().getQuantityPrecision()\n
precision = context.getDestinationSectionValue().getPriceCurrencyValue().getQuantityPrecision()\n
#Get all transaction lines of the transaction \n
line_list= context.contentValues(\n
line_list = context.contentValues(\n
portal_type=portal.getPortalAccountingMovementTypeList())\n
"""\n
For each transaction line, calculate the price of the resource\n
......@@ -74,26 +71,24 @@ and start_date categories \n
"""\n
\n
for line in line_list:\n
if line.getDestinationSectionValue() is None:\n
raise AssertionError\n
else:\n
currency = line.getResourceValue()\n
exchange_ratio = currency.getPrice(context=line.asContext(\n
categories=[\'resource/%s\' % line.getResource(), \n
\'price_currency/currency_module/%s\' %\n
line.getDestinationSectionValue().getPriceCurrencyId()],\n
start_date=line.getStopDate()))\n
section = line.getDestinationSectionValue()\n
currency = line.getResourceValue()\n
if not exchange_rate:\n
exchange_rate = currency.getPrice(context=line.asContext(\n
categories=[line.getResource(base=True),\n
section.getPriceCurrency(base=True)],\n
start_date=line.getStopDate()))\n
\n
#redirect to previous page without doing the conversion\n
if exchange_ratio is None:\n
return context.Base_redirect(form_id,\n
# redirect to previous page without doing the conversion\n
if exchange_rate is None:\n
return context.Base_redirect(form_id,\n
keep_items=dict(\n
portal_status_message=context.Base_translateString(\'No exchange ratio found.\'))) \n
#update the corresponding price and round it according to the precision of\n
#the converted currency\n
line.setDestinationTotalAssetPrice(\n
round(exchange_ratio*(line.getQuantity()), precision))\n
portal_status_message=context.Base_translateString(\'No exchange ratio found.\')))\n
\n
# update the corresponding price and round it according to the precision of\n
# the converted currency\n
line.setDestinationTotalAssetPrice(\n
round(exchange_rate * (line.getQuantity()), precision))\n
\n
msg = context.Base_translateString(\'Price converted.\')\n
\n
......@@ -109,7 +104,7 @@ return context.Base_redirect(form_id,\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'view\'</string> </value>
<value> <string>exchange_rate=None, form_id=\'view\'</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -129,15 +124,14 @@ return context.Base_redirect(form_id,\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>exchange_rate</string>
<string>form_id</string>
<string>Products.ERP5.Document.Document</string>
<string>ConversionError</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
......@@ -145,10 +139,10 @@ return context.Base_redirect(form_id,\n
<string>line_list</string>
<string>_getiter_</string>
<string>line</string>
<string>None</string>
<string>AssertionError</string>
<string>section</string>
<string>currency</string>
<string>exchange_ratio</string>
<string>True</string>
<string>None</string>
<string>dict</string>
<string>round</string>
<string>msg</string>
......@@ -164,6 +158,7 @@ return context.Base_redirect(form_id,\n
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<string>view</string>
</tuple>
</value>
......
......@@ -50,16 +50,15 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5.Document.Document import ConversionError\n
"""\n
<value> <string>"""\n
Script to convert the prices used in the transaction to the \n
currency of the destination section\n
"""\n
portal = context.getPortalObject()\n
#get the precision of the destination\n
precision =context.getSourceSectionValue().getPriceCurrencyValue().getQuantityPrecision()\n
precision = context.getSourceSectionValue().getPriceCurrencyValue().getQuantityPrecision()\n
#Get all transaction lines of the transaction \n
line_list= context.contentValues(\n
line_list = context.contentValues(\n
portal_type=portal.getPortalAccountingMovementTypeList())\n
"""\n
For each transaction line, calculate the price of the resource\n
......@@ -69,27 +68,24 @@ and start_date categories \n
"""\n
\n
for line in line_list:\n
if line.getSourceSectionValue() is None:\n
raise AssertionError\n
else:\n
currency = line.getResourceValue()\n
exchange_ratio = currency.getPrice(context=line.asContext(\n
categories=[\'resource/%s\' % line.getResource(), \n
\'price_currency/currency_module/%s\' %\n
line.getSourceSectionValue().getPriceCurrencyId()],\n
section = line.getSourceSectionValue()\n
currency = line.getResourceValue()\n
if not exchange_rate:\n
exchange_rate = currency.getPrice(context=line.asContext(\n
categories=[line.getResource(base=True),\n
section.getPriceCurrency(base=True)],\n
start_date=line.getStartDate()))\n
#redirect to previous page without doing the conversion\n
if exchange_ratio is None:\n
return context.Base_redirect(form_id,\n
# redirect to previous page without doing the conversion\n
if exchange_rate is None:\n
return context.Base_redirect(form_id,\n
keep_items=dict(\n
portal_status_message=context.Base_translateString(\'No exchange ratio found.\'))) \n
\n
portal_status_message=context.Base_translateString(\'No exchange ratio found.\')))\n
\n
#update the corresponding price and round it according to the precision of\n
#the converted currency\n
line.setSourceTotalAssetPrice(\n
round(exchange_ratio * (-line.getQuantity()), precision))\n
\n
# update the corresponding price and round it according to the precision of\n
# the converted currency\n
line.setSourceTotalAssetPrice(\n
round(exchange_rate * (-line.getQuantity()), precision))\n
\n
msg = context.Base_translateString(\'Price converted.\')\n
\n
......@@ -105,7 +101,7 @@ return context.Base_redirect(form_id,\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'view\'</string> </value>
<value> <string>exchange_rate=None, form_id=\'view\'</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -125,15 +121,14 @@ return context.Base_redirect(form_id,\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>exchange_rate</string>
<string>form_id</string>
<string>Products.ERP5.Document.Document</string>
<string>ConversionError</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
......@@ -141,10 +136,10 @@ return context.Base_redirect(form_id,\n
<string>line_list</string>
<string>_getiter_</string>
<string>line</string>
<string>None</string>
<string>AssertionError</string>
<string>section</string>
<string>currency</string>
<string>exchange_ratio</string>
<string>True</string>
<string>None</string>
<string>dict</string>
<string>round</string>
<string>msg</string>
......@@ -160,6 +155,7 @@ return context.Base_redirect(form_id,\n
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<string>view</string>
</tuple>
</value>
......
......@@ -53,7 +53,7 @@
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>application/x-www-form-urlencoded</string> </value>
<value> <string>multipart/form-data</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
......@@ -143,6 +143,10 @@
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -10,10 +10,9 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>default</string>
<string>precision</string>
<string>editable</string>
<string>title</string>
</list>
</value>
</item>
......@@ -84,10 +83,6 @@
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_money_quantity</string> </value>
......
......@@ -53,7 +53,7 @@
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>application/x-www-form-urlencoded</string> </value>
<value> <string>multipart/form-data</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
......@@ -143,6 +143,10 @@
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -10,10 +10,9 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>default</string>
<string>precision</string>
<string>editable</string>
<string>title</string>
</list>
</value>
</item>
......@@ -84,10 +83,6 @@
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_money_quantity</string> </value>
......
1367
\ No newline at end of file
1368
\ 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