From 14b2b1f45e07dd110f83ea1c523d0cd8d8080aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Mon, 7 Apr 2008 12:23:09 +0000 Subject: [PATCH] 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 --- ...ccountingTransaction_guessGroupedLines.xml | 29 ++++++++++++------- bt5/erp5_accounting/bt/revision | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_guessGroupedLines.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_guessGroupedLines.xml index 82db054e23..db01994825 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_guessGroupedLines.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_guessGroupedLines.xml @@ -65,7 +65,9 @@ </item> <item> <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 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 @@ -82,6 +84,16 @@ ctool = portal.portal_catalog\n allow_grouping_with_different_quantity = portal.portal_preferences.getPreference(\n \'preferred_grouping_with_different_quantities\', 0)\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 section_cat = portal.portal_preferences\\\n .getPreferredAccountingTransactionSectionCategory()\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 \n # convert from int to letters\n - d, m = divmod(grouping_reference, 26)\n - string_reference = \'A\' * d\n - string_reference += (chr(m + ord(\'A\')))\n + string_reference = int2letter(grouping_reference)\n \n for line in line_info_list:\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 changed_lines.append(line[\'path\'])\n \n return changed_lines\n -</string> </value> + + +]]></string> </value> </item> <item> <key> <string>_code</string> </key> @@ -201,6 +213,7 @@ return changed_lines\n <string>portal</string> <string>ctool</string> <string>allow_grouping_with_different_quantity</string> + <string>int2letter</string> <string>isSource</string> <string>accounting_transaction_line_value_list</string> <string>None</string> @@ -224,13 +237,7 @@ return changed_lines\n <string>default_currency</string> <string>round</string> <string>grouping_reference</string> - <string>divmod</string> - <string>d</string> - <string>m</string> <string>string_reference</string> - <string>_inplacevar_</string> - <string>chr</string> - <string>ord</string> <string>line_obj</string> </tuple> </value> diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision index 0552576c87..4ffc0cd9c1 100644 --- a/bt5/erp5_accounting/bt/revision +++ b/bt5/erp5_accounting/bt/revision @@ -1 +1 @@ -669 \ No newline at end of file +670 \ No newline at end of file -- 2.30.9