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

Change AccountingTransaction_isDestination/SourceCurrencyConvertible so that...

Change AccountingTransaction_isDestination/SourceCurrencyConvertible so that conversion tab is always visible when conversion is set on lines, even if the resource is the same as the section's accounting currency.
Change accounting workflow to refuse validation of a transaction if conversion is set on lines (to a value different from quantity) when it should not be.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23717 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e6201ba4
......@@ -9,22 +9,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -73,8 +61,19 @@ if section_value is None or \\\n
return 0\n
\n
transaction_currency = context.getResource()\n
return transaction_currency is not None and\\\n
transaction_currency != section_value.getProperty(\'price_currency\', None)\n
if transaction_currency is not None and\\\n
transaction_currency != section_value.getProperty(\'price_currency\', None):\n
return 1\n
\n
for line in context.getMovementList(\n
portal_type=context.getPortalAccountingMovementTypeList()):\n
if ((line.getDestinationCredit() !=\n
line.getDestinationInventoriatedTotalAssetCredit()) or (\n
line.getDestinationDebit() !=\n
line.getDestinationInventoriatedTotalAssetDebit())):\n
return 1\n
\n
return 0\n
</string> </value>
</item>
<item>
......@@ -83,12 +82,6 @@ return transaction_currency is not None and\\\n
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......@@ -122,6 +115,8 @@ return transaction_currency is not None and\\\n
<string>section_value</string>
<string>None</string>
<string>transaction_currency</string>
<string>_getiter_</string>
<string>line</string>
</tuple>
</value>
</item>
......
......@@ -9,22 +9,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -73,8 +61,19 @@ if section_value is None or \\\n
return 0\n
\n
transaction_currency = context.getResource()\n
return transaction_currency is not None and\\\n
transaction_currency != section_value.getProperty(\'price_currency\', None)\n
if transaction_currency is not None and\\\n
transaction_currency != section_value.getProperty(\'price_currency\', None):\n
return 1\n
\n
for line in context.getMovementList(\n
portal_type=context.getPortalAccountingMovementTypeList()):\n
if ((line.getSourceCredit() !=\n
line.getSourceInventoriatedTotalAssetCredit()) or (\n
line.getSourceDebit() !=\n
line.getSourceInventoriatedTotalAssetDebit())):\n
return 1\n
\n
return 0\n
</string> </value>
</item>
<item>
......@@ -83,12 +82,6 @@ return transaction_currency is not None and\\\n
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......@@ -122,6 +115,8 @@ return transaction_currency is not None and\\\n
<string>section_value</string>
<string>None</string>
<string>transaction_currency</string>
<string>_getiter_</string>
<string>line</string>
</tuple>
</value>
</item>
......
......@@ -72,6 +72,7 @@ N_ = lambda msg, **kw: Message(\'erp5_ui\', msg, **kw)\n
# first of all, validate the transaction itself\n
container.validateTransaction(state_change)\n
\n
\n
# Check that all lines uses open accounts, and doesn\'t use invalid third\n
# parties or bank accounts\n
for line in transaction.contentValues(filter=dict(\n
......@@ -117,6 +118,32 @@ for line in transaction.contentValues(filter=dict(\n
"uses ${bank_account_currency} as default currency.",\n
mapping=dict(bank_account_reference=unicode(bank_account.getReference(), \'utf8\'),\n
bank_account_currency=unicode(bank_account.getPriceCurrencyReference(), \'utf8\')))\n
\n
source_currency = None\n
source_section = line.getSourceSectionValue()\n
if source_section is not None:\n
source_currency = source_section.getProperty(\'price_currency\')\n
\n
if source_currency == line.getResource():\n
if ((line.getSourceCredit() !=\n
line.getSourceInventoriatedTotalAssetCredit()) or (\n
line.getSourceDebit() !=\n
line.getSourceInventoriatedTotalAssetDebit())):\n
raise ValidationFailed(translateString(\n
"Source conversion should not be set."))\n
\n
destination_currency = None\n
destination_section = line.getDestinationSectionValue()\n
if destination_section is not None:\n
destination_currency = destination_section.getProperty(\'price_currency\')\n
\n
if destination_currency == line.getResource():\n
if ((line.getDestinationCredit() !=\n
line.getDestinationInventoriatedTotalAssetCredit()) or (\n
line.getDestinationDebit() !=\n
line.getDestinationInventoriatedTotalAssetDebit())):\n
raise ValidationFailed(translateString(\n
"Destination conversion should not be set."))\n
\n
# Delete empty lines\n
transaction.AccountingTransaction_deleteEmptyLines(redirect=0)\n
......@@ -197,6 +224,10 @@ transaction.AccountingTransaction_deleteEmptyLines(redirect=0)\n
<string>None</string>
<string>unicode</string>
<string>bank_account_currency</string>
<string>source_currency</string>
<string>source_section</string>
<string>destination_currency</string>
<string>destination_section</string>
</tuple>
</value>
</item>
......
775
\ No newline at end of file
777
\ 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