Commit 14b2b1f4 authored by Jérome Perrin's avatar Jérome Perrin

AccountingTransaction_guessGroupedLines : generate better grouping reference...

AccountingTransaction_guessGroupedLines : generate better grouping reference letters, using this scheme:
A, B, C ..., Z, AA, AB, ..., AZ, BA, BBB, ..., ZZ, AAA, AAB,
it was mistakenly using this one:
A, B, C ..., Z, AA, AB, ...AZ, AAA, AAB

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20321 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e6aa7509
...@@ -65,7 +65,9 @@ ...@@ -65,7 +65,9 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""Guess a grouping references for lines whose uids are passed as\n <value> <string encoding="cdata"><![CDATA[
"""Guess a grouping references for lines whose uids are passed as\n
accounting_transaction_line_uid_list.\n accounting_transaction_line_uid_list.\n
If accounting_transaction_line_uid_list is not passed, this script assumes that\n If accounting_transaction_line_uid_list is not passed, this script assumes that\n
it\'s called on the context of an accounting transaction and it guess the group\n it\'s called on the context of an accounting transaction and it guess the group\n
...@@ -82,6 +84,16 @@ ctool = portal.portal_catalog\n ...@@ -82,6 +84,16 @@ ctool = portal.portal_catalog\n
allow_grouping_with_different_quantity = portal.portal_preferences.getPreference(\n allow_grouping_with_different_quantity = portal.portal_preferences.getPreference(\n
\'preferred_grouping_with_different_quantities\', 0)\n \'preferred_grouping_with_different_quantities\', 0)\n
\n \n
def int2letter(i):\n
"""Convert an integer to letters, to use as a grouping reference code.\n
A, B, C ..., Z, AA, AB, ..., AZ, BA, ..., ZZ, AAA ...\n
"""\n
if i < 26:\n
return (chr(i + ord(\'A\')))\n
d, m = divmod(i, 26)\n
return int2letter(d - 1) + int2letter(m)\n
\n
\n
def isSource(accounting_transaction):\n def isSource(accounting_transaction):\n
section_cat = portal.portal_preferences\\\n section_cat = portal.portal_preferences\\\n
.getPreferredAccountingTransactionSectionCategory()\n .getPreferredAccountingTransactionSectionCategory()\n
...@@ -136,9 +148,7 @@ for (node, section, mirror_section), line_info_list in lines_per_node.items():\n ...@@ -136,9 +148,7 @@ for (node, section, mirror_section), line_info_list in lines_per_node.items():\n
(\'grouping_reference\', node, section, mirror_section))\n (\'grouping_reference\', node, section, mirror_section))\n
\n \n
# convert from int to letters\n # convert from int to letters\n
d, m = divmod(grouping_reference, 26)\n string_reference = int2letter(grouping_reference)\n
string_reference = \'A\' * d\n
string_reference += (chr(m + ord(\'A\')))\n
\n \n
for line in line_info_list:\n for line in line_info_list:\n
line_obj = portal.restrictedTraverse(line[\'path\'])\n line_obj = portal.restrictedTraverse(line[\'path\'])\n
...@@ -146,7 +156,9 @@ for (node, section, mirror_section), line_info_list in lines_per_node.items():\n ...@@ -146,7 +156,9 @@ for (node, section, mirror_section), line_info_list in lines_per_node.items():\n
changed_lines.append(line[\'path\'])\n changed_lines.append(line[\'path\'])\n
\n \n
return changed_lines\n return changed_lines\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -201,6 +213,7 @@ return changed_lines\n ...@@ -201,6 +213,7 @@ return changed_lines\n
<string>portal</string> <string>portal</string>
<string>ctool</string> <string>ctool</string>
<string>allow_grouping_with_different_quantity</string> <string>allow_grouping_with_different_quantity</string>
<string>int2letter</string>
<string>isSource</string> <string>isSource</string>
<string>accounting_transaction_line_value_list</string> <string>accounting_transaction_line_value_list</string>
<string>None</string> <string>None</string>
...@@ -224,13 +237,7 @@ return changed_lines\n ...@@ -224,13 +237,7 @@ return changed_lines\n
<string>default_currency</string> <string>default_currency</string>
<string>round</string> <string>round</string>
<string>grouping_reference</string> <string>grouping_reference</string>
<string>divmod</string>
<string>d</string>
<string>m</string>
<string>string_reference</string> <string>string_reference</string>
<string>_inplacevar_</string>
<string>chr</string>
<string>ord</string>
<string>line_obj</string> <string>line_obj</string>
</tuple> </tuple>
</value> </value>
......
669 670
\ 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