Commit 25e5ba3b authored by Jérome Perrin's avatar Jérome Perrin

use portal_ids.generateNewLengthId with compatibility with previous storage

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30839 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8fc5a5b9
...@@ -141,9 +141,13 @@ for (node, section, mirror_section), line_info_list in lines_per_node.items():\n ...@@ -141,9 +141,13 @@ for (node, section, mirror_section), line_info_list in lines_per_node.items():\n
if default_currency is not None:\n if default_currency is not None:\n
total_price = round(total_price, default_currency.getQuantityPrecision())\n total_price = round(total_price, default_currency.getQuantityPrecision())\n
if total_price == 0 or allow_grouping_with_different_quantity:\n if total_price == 0 or allow_grouping_with_different_quantity:\n
# get a grouping reference id\n id_group = (\'grouping_reference\', node, section, mirror_section)\n
grouping_reference = portal.portal_ids.generateNewId(\n # before, we where using generateNewId, we are now using generateNewLengthId which\n
(\'grouping_reference\', node, section, mirror_section))\n # is using another storage. Get the last value generated with generateNewId and use it as default.\n
previous_default = context.portal_ids.getLastGeneratedId(id_group=id_group, default=0)\n
grouping_reference = portal.portal_ids.generateNewLengthId(\n
id_group=id_group,\n
default=previous_default + 1)\n
\n \n
# convert from int to letters\n # convert from int to letters\n
string_reference = int2letter(grouping_reference)\n string_reference = int2letter(grouping_reference)\n
...@@ -224,6 +228,8 @@ return changed_lines\n ...@@ -224,6 +228,8 @@ return changed_lines\n
<string>default_currency</string> <string>default_currency</string>
<string>section_obj</string> <string>section_obj</string>
<string>round</string> <string>round</string>
<string>id_group</string>
<string>previous_default</string>
<string>grouping_reference</string> <string>grouping_reference</string>
<string>string_reference</string> <string>string_reference</string>
<string>line_obj</string> <string>line_obj</string>
......
...@@ -76,13 +76,15 @@ if destination_section_value is not None \\\n ...@@ -76,13 +76,15 @@ if destination_section_value is not None \\\n
destination_section = destination_section_value.getRelativeUrl()\n destination_section = destination_section_value.getRelativeUrl()\n
\n \n
id_generator = state_change.getPortal().portal_ids.generateNewLengthId\n id_generator = state_change.getPortal().portal_ids.generateNewLengthId\n
previous_id_getter = state_change.getPortal().portal_ids.getLastGeneratedId\n
\n \n
# Invoice Reference is automatically filled only for Sale Invoice Transaction.\n # Invoice Reference is automatically filled only for Sale Invoice Transaction.\n
if transaction.getPortalType() == \'Sale Invoice Transaction\':\n if transaction.getPortalType() == \'Sale Invoice Transaction\':\n
if not transaction.getReference():\n if not transaction.getReference():\n
invoice_id_group = (\'accounting\', \'invoice\', source_section)\n invoice_id_group = (\'accounting\', \'invoice\', source_section)\n
invoice_reference = id_generator(id_group=invoice_id_group,\n invoice_reference = id_generator(id_group=invoice_id_group,\n
default=1)\n default=previous_id_getter(invoice_id_group,\n
default=0) + 1)\n
transaction.setReference(invoice_reference)\n transaction.setReference(invoice_reference)\n
\n \n
\n \n
...@@ -95,7 +97,9 @@ if not transaction.getSourceReference():\n ...@@ -95,7 +97,9 @@ if not transaction.getSourceReference():\n
if not period_code:\n if not period_code:\n
period_code = str(transaction.getStartDate().year())\n period_code = str(transaction.getStartDate().year())\n
source_id_group = (\'accounting\', \'section\', source_section, period_code)\n source_id_group = (\'accounting\', \'section\', source_section, period_code)\n
source_reference = id_generator(id_group=source_id_group, default=1)\n source_reference = id_generator(id_group=source_id_group,\n
default=previous_id_getter(source_id_group,\n
default=0) + 1)\n
transaction.setSourceReference(\'%s-%s\' % (period_code, source_reference))\n transaction.setSourceReference(\'%s-%s\' % (period_code, source_reference))\n
\n \n
if not transaction.getDestinationReference():\n if not transaction.getDestinationReference():\n
...@@ -106,7 +110,9 @@ if not transaction.getDestinationReference():\n ...@@ -106,7 +110,9 @@ if not transaction.getDestinationReference():\n
if not period_code:\n if not period_code:\n
period_code = str(transaction.getStopDate().year())\n period_code = str(transaction.getStopDate().year())\n
destination_id_group = (\'accounting\', \'section\', destination_section, period_code)\n destination_id_group = (\'accounting\', \'section\', destination_section, period_code)\n
destination_reference = id_generator(id_group=destination_id_group, default=1)\n destination_reference = id_generator(id_group=destination_id_group,\n
default=previous_id_getter(destination_id_group,\n
default=0) + 1)\n
transaction.setDestinationReference(\'%s-%s\' % (period_code, destination_reference))\n transaction.setDestinationReference(\'%s-%s\' % (period_code, destination_reference))\n
</string> </value> </string> </value>
</item> </item>
...@@ -162,6 +168,7 @@ if not transaction.getDestinationReference():\n ...@@ -162,6 +168,7 @@ if not transaction.getDestinationReference():\n
<string>destination_section</string> <string>destination_section</string>
<string>destination_section_value</string> <string>destination_section_value</string>
<string>id_generator</string> <string>id_generator</string>
<string>previous_id_getter</string>
<string>invoice_id_group</string> <string>invoice_id_group</string>
<string>invoice_reference</string> <string>invoice_reference</string>
<string>period</string> <string>period</string>
......
1054 1061
\ 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