diff --git a/product/ERP5/interfaces/id_generator.py b/product/ERP5/interfaces/id_generator.py new file mode 100644 index 0000000000000000000000000000000000000000..1431e5fee4a726133b6753f7b65bb07aedfc7c7e --- /dev/null +++ b/product/ERP5/interfaces/id_generator.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved. +# Sebastien Robin <seb@nexedi.com> +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +from zope.interface import Interface + +class IIdGenerator(Interface): + """ + Rounding tool interface + """ + + def generateNewId(id_group=None, default=None): + """ + Generate the next id in the sequence of ids of a particular group + + Parameters : + + id_group (string) + This is the name of a particular sequence if ids. + + default (string or int or float, depending on the generator) + Default value of the sequence (optional). + The first time an id is generated for that sequence, this + default will be returned. + + If the default value is incompatible with the generator, + ValueError will be raised. + + """ + + def generateNewIdList(id_group=None, default=None, id_count=1): + """ + Generate a list of next ids in the sequence of ids of a particular group + + Parameters : + + id_group (string) + This is the name of a particular sequence if ids. + + default (string or int or float, depending on the generator) + Default value of the sequence (optional). + The first time an id is generated for that sequence, this + default will be returned. + + If the default value is incompatible with the generator, + ValueError will be raised. + + method + This allows to customize the way id are generated. This + method should take as parameter the previously generated + id (optional). By default, ids are managed like integers and + are increased one by one + """ diff --git a/product/ERP5/interfaces/id_tool.py b/product/ERP5/interfaces/id_tool.py new file mode 100644 index 0000000000000000000000000000000000000000..17b81027505a5fa71636f845b35726b5b422a89b --- /dev/null +++ b/product/ERP5/interfaces/id_tool.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved. +# Sebastien Robin <seb@nexedi.com> +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly advised to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +from zope.interface import Interface + +class IIdTool(Interface): + """ + Id Tool interface + """ + + def generateNewId(id_group=None, default=None, id_generator=None): + """ + Generate the next id in the sequence of ids of a particular group + + Parameters : + + id_group (string) + This is the name of a particular sequence if ids. + + default (string or int or float, depending on the generator) + Default value of the sequence (optional). + The first time an id is generated for that sequence, this + default will be returned. + + If the default value is incompatible with the generator, + ValueError will be raised. + + id_generator (string) + Select an particular id generator (optional) by giving its + reference. This is not mandatory, a default generator will exist. + Only id generator of type application can be selected. + + Example : + my_new_id = portal_ids.generateNewId(id_group='sale_invoice', + default=100) + # this can returns '154' + """ + + def generateNewIdList(id_group=None, default=None, id_count=1, + id_generator=None): + """ + Generate a list of next ids in the sequence of ids of a particular group + + Parameters : + + id_group (string) + This is the name of a particular sequence if ids. + + default (string or int or float, depending on the generator) + Default value of the sequence (optional). + The first time an id is generated for that sequence, this + default will be returned. + + If the default value is incompatible with the generator, + ValueError will be raised. + + id_generator (string) + Select an particular id generator (optional) by giving its + reference. This is not mandatory, a default generator will exist. + Only id generator of type application can be selected. + + Example : + my_new_id_list = portal_ids.generateNewLengthIdList(id_group='sale_invoice', + default=100, id_count=3) + # this can returns ['154', '155', '156'] + """