From e03afc5fb691504f32b261365a5fdf4052f58af8 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Fri, 26 Feb 2016 18:30:50 +0100 Subject: [PATCH 01/27] Unique partners in registrations. This module allows you to avoid having a partner registrated twice in the same event. --- event_registration_partner_unique/README.rst | 75 +++++++++++++++++++ event_registration_partner_unique/__init__.py | 6 ++ .../__openerp__.py | 18 +++++ event_registration_partner_unique/hooks.py | 36 +++++++++ event_registration_partner_unique/i18n/es.po | 44 +++++++++++ .../models/__init__.py | 5 ++ .../models/event_registration.py | 15 ++++ 7 files changed, 199 insertions(+) create mode 100644 event_registration_partner_unique/README.rst create mode 100644 event_registration_partner_unique/__init__.py create mode 100644 event_registration_partner_unique/__openerp__.py create mode 100644 event_registration_partner_unique/hooks.py create mode 100644 event_registration_partner_unique/i18n/es.po create mode 100644 event_registration_partner_unique/models/__init__.py create mode 100644 event_registration_partner_unique/models/event_registration.py diff --git a/event_registration_partner_unique/README.rst b/event_registration_partner_unique/README.rst new file mode 100644 index 000000000..c940ce786 --- /dev/null +++ b/event_registration_partner_unique/README.rst @@ -0,0 +1,75 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================== +Unique Partner per Event +======================== + +This module extends the functionality of events to support forbidding to duplicate the same partner in an event. + +Installation +============ + +To install this module, you need to: + +* Remove all duplicated registrations from events. + +Usage +===== + +To use this module, you need to: + +* Go to *Marketing > Events > Registrations*. +* Try to create 2 registrations for the same partner and event. +* You cannot. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/199/8.0 + +Known issues / Roadmap +====================== + +* It would be nice to deduplicate at install, but that's quite destructive. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed `feedback +`_. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Rafael Blasco +* Jairo Llopis + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/event_registration_partner_unique/__init__.py b/event_registration_partner_unique/__init__.py new file mode 100644 index 000000000..b9aa79e22 --- /dev/null +++ b/event_registration_partner_unique/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models +from .hooks import pre_init_hook diff --git a/event_registration_partner_unique/__openerp__.py b/event_registration_partner_unique/__openerp__.py new file mode 100644 index 000000000..7bdf285aa --- /dev/null +++ b/event_registration_partner_unique/__openerp__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Unique Partner per Event", + "summary": "Enforces 1 registration per partner and event", + "version": "8.0.1.0.0", + "category": "Events", + "website": "http://www.antiun.com", + "author": "Antiun Ingeniería S.L., Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "pre_init_hook": "pre_init_hook", + "depends": [ + "event", + ], +} diff --git a/event_registration_partner_unique/hooks.py b/event_registration_partner_unique/hooks.py new file mode 100644 index 000000000..69c2c1f4f --- /dev/null +++ b/event_registration_partner_unique/hooks.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import _, exceptions + + +def pre_init_hook(cr): + """Ensure no duplicates before installing.""" + cr.execute(""" + SELECT + event_event.name, + res_partner.name, + COUNT(*) AS duplicates + FROM + event_registration + + INNER JOIN event_event + ON event_event.id = event_registration.event_id + + INNER JOIN res_partner + ON res_partner.id = event_registration.partner_id + GROUP BY + event_registration.event_id, + event_event.name, + event_registration.partner_id, + res_partner.name + HAVING + COUNT(*) > 1 + """) + rows = cr.fetchall() + if rows: + message = _("Event %s; Partner %s; %d duplicates.") + details = "\n".join(message % row for row in rows) + raise exceptions.ValidationError( + _("Remove duplicates before installing:\n%s") % details) diff --git a/event_registration_partner_unique/i18n/es.po b/event_registration_partner_unique/i18n/es.po new file mode 100644 index 000000000..1af1b5bd2 --- /dev/null +++ b/event_registration_partner_unique/i18n/es.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * event_registration_partner_unique +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-02-26 17:29+0000\n" +"PO-Revision-Date: 2016-02-26 18:30+0100\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"Language: es\n" +"X-Generator: Poedit 1.8.6\n" + +#. module: event_registration_partner_unique +#: sql_constraint:event.registration:0 +msgid "Cannot repeat partner in the same event." +msgstr "No puede repetir una empresa en el mismo evento." + +#. module: event_registration_partner_unique +#: code:addons/event_registration_partner_unique/hooks.py:33 +#, python-format +msgid "Event %s; Partner %s; %d duplicates." +msgstr "Evento %s; Empresa %s; %d duplicados." + +#. module: event_registration_partner_unique +#: model:ir.model,name:event_registration_partner_unique.model_event_registration +msgid "Event Registration" +msgstr "Registro del evento" + +#. module: event_registration_partner_unique +#: code:addons/event_registration_partner_unique/hooks.py:36 +#, python-format +msgid "" +"Remove duplicates before installing:\n" +"%s" +msgstr "" +"Borre los duplicados antes de instalar:\n" +"%s" diff --git a/event_registration_partner_unique/models/__init__.py b/event_registration_partner_unique/models/__init__.py new file mode 100644 index 000000000..c275c52a2 --- /dev/null +++ b/event_registration_partner_unique/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import event_registration diff --git a/event_registration_partner_unique/models/event_registration.py b/event_registration_partner_unique/models/event_registration.py new file mode 100644 index 000000000..efd6e7936 --- /dev/null +++ b/event_registration_partner_unique/models/event_registration.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import models + + +class EventRegistration(models.Model): + _inherit = "event.registration" + + _sql_constraints = [ + ("unique_partner_event", + "UNIQUE(partner_id, event_id)", + "Cannot repeat partner in the same event.") + ] From 20e59fdc33077a78c6e94b2a5f1509fd9eb59896 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 3 Mar 2016 17:59:55 +0100 Subject: [PATCH 02/27] Depends now on event_sale to fix [this bug][1]. It has to declare unique indexes instead of constraints to work. [1]: https://github.com/OCA/event/pull/38#issuecomment-191525863 --- event_registration_partner_unique/__init__.py | 2 +- .../__openerp__.py | 4 ++- event_registration_partner_unique/hooks.py | 31 ++++++++++++++++ event_registration_partner_unique/i18n/es.po | 29 +++++++++------ .../models/__init__.py | 2 +- .../models/event_registration.py | 15 -------- .../models/sale_order.py | 35 +++++++++++++++++++ 7 files changed, 89 insertions(+), 29 deletions(-) delete mode 100644 event_registration_partner_unique/models/event_registration.py create mode 100644 event_registration_partner_unique/models/sale_order.py diff --git a/event_registration_partner_unique/__init__.py b/event_registration_partner_unique/__init__.py index b9aa79e22..40c563976 100644 --- a/event_registration_partner_unique/__init__.py +++ b/event_registration_partner_unique/__init__.py @@ -3,4 +3,4 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models -from .hooks import pre_init_hook +from .hooks import pre_init_hook, post_init_hook, uninstall_hook diff --git a/event_registration_partner_unique/__openerp__.py b/event_registration_partner_unique/__openerp__.py index 7bdf285aa..61a67b6e1 100644 --- a/event_registration_partner_unique/__openerp__.py +++ b/event_registration_partner_unique/__openerp__.py @@ -12,7 +12,9 @@ "application": False, "installable": True, "pre_init_hook": "pre_init_hook", + "post_init_hook": "post_init_hook", + "uninstall_hook": "uninstall_hook", "depends": [ - "event", + "event_sale", ], } diff --git a/event_registration_partner_unique/hooks.py b/event_registration_partner_unique/hooks.py index 69c2c1f4f..35607719f 100644 --- a/event_registration_partner_unique/hooks.py +++ b/event_registration_partner_unique/hooks.py @@ -34,3 +34,34 @@ def pre_init_hook(cr): details = "\n".join(message % row for row in rows) raise exceptions.ValidationError( _("Remove duplicates before installing:\n%s") % details) + + +def post_init_hook(cr, registry): + """Using custom unique indexes because of null values in tickets. + + See http://stackoverflow.com/a/8289253/1468388. + """ + indexes = ( + """ + CREATE UNIQUE INDEX + event_registration_unique_partner_ticket_null + ON event_registration (partner_id, event_id) + WHERE event_ticket_id IS NULL + """, + """ + CREATE UNIQUE INDEX + event_registration_unique_partner_ticket_fill + ON event_registration (partner_id, event_id, event_ticket_id) + WHERE event_ticket_id IS NOT NULL + """, + ) + for index in indexes: + cr.execute(index) + + +def uninstall_hook(cr, registry): + """Remove manual unique indexes.""" + cr.execute( + "DROP INDEX IF EXISTS event_registration_unique_partner_ticket_null") + cr.execute( + "DROP INDEX IF EXISTS event_registration_unique_partner_ticket_fill") diff --git a/event_registration_partner_unique/i18n/es.po b/event_registration_partner_unique/i18n/es.po index 1af1b5bd2..d35a667b6 100644 --- a/event_registration_partner_unique/i18n/es.po +++ b/event_registration_partner_unique/i18n/es.po @@ -6,21 +6,22 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-02-26 17:29+0000\n" -"PO-Revision-Date: 2016-02-26 18:30+0100\n" +"POT-Creation-Date: 2016-03-03 17:59+0100\n" +"PO-Revision-Date: 2016-03-03 17:59+0100\n" "Last-Translator: <>\n" "Language-Team: \n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: \n" -"Language: es\n" "X-Generator: Poedit 1.8.6\n" #. module: event_registration_partner_unique -#: sql_constraint:event.registration:0 -msgid "Cannot repeat partner in the same event." -msgstr "No puede repetir una empresa en el mismo evento." +#: code:addons/event_registration_partner_unique/models/sale_order.py:32 +#, python-format +msgid "%d new registrations sold in %s." +msgstr "%d nuevos registros vendidos en %s." #. module: event_registration_partner_unique #: code:addons/event_registration_partner_unique/hooks.py:33 @@ -28,11 +29,6 @@ msgstr "No puede repetir una empresa en el mismo evento." msgid "Event %s; Partner %s; %d duplicates." msgstr "Evento %s; Empresa %s; %d duplicados." -#. module: event_registration_partner_unique -#: model:ir.model,name:event_registration_partner_unique.model_event_registration -msgid "Event Registration" -msgstr "Registro del evento" - #. module: event_registration_partner_unique #: code:addons/event_registration_partner_unique/hooks.py:36 #, python-format @@ -42,3 +38,14 @@ msgid "" msgstr "" "Borre los duplicados antes de instalar:\n" "%s" + +#. module: event_registration_partner_unique +#: model:ir.model,name:event_registration_partner_unique.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línea del pedido de ventas" + +#~ msgid "Cannot repeat partner in the same event." +#~ msgstr "No puede repetir una empresa en el mismo evento." + +#~ msgid "Event Registration" +#~ msgstr "Registro del evento" diff --git a/event_registration_partner_unique/models/__init__.py b/event_registration_partner_unique/models/__init__.py index c275c52a2..c25866d17 100644 --- a/event_registration_partner_unique/models/__init__.py +++ b/event_registration_partner_unique/models/__init__.py @@ -2,4 +2,4 @@ # © 2016 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import event_registration +from . import sale_order diff --git a/event_registration_partner_unique/models/event_registration.py b/event_registration_partner_unique/models/event_registration.py deleted file mode 100644 index efd6e7936..000000000 --- a/event_registration_partner_unique/models/event_registration.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2016 Antiun Ingeniería S.L. - Jairo Llopis -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openerp import models - - -class EventRegistration(models.Model): - _inherit = "event.registration" - - _sql_constraints = [ - ("unique_partner_event", - "UNIQUE(partner_id, event_id)", - "Cannot repeat partner in the same event.") - ] diff --git a/event_registration_partner_unique/models/sale_order.py b/event_registration_partner_unique/models/sale_order.py new file mode 100644 index 000000000..4cb230bdd --- /dev/null +++ b/event_registration_partner_unique/models/sale_order.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from psycopg2 import IntegrityError +from openerp import _, api, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + @api.multi + def button_confirm(self): + """Add registrations to the already existing record if possible.""" + registrations = self.env["event.registration"] + + for s in self: + try: + with self.env.cr.savepoint(): + super(SaleOrderLine, s).button_confirm() + + # A registration already exists + except IntegrityError: + match = registrations.search([ + ("event_id", "=", s.event_id.id), + ("event_ticket_id", "=", s.event_ticket_id.id), + ("partner_id", "=", s.order_id.partner_id.id), + ]) + qty = int(s.product_uom_qty) + match.nb_register += qty + match = match.with_context(mail_create_nolog=True) + match.message_post(_("%d new registrations sold in %s.") % + (qty, s.order_id.display_name)) + + return True From 7c83608e60228ca1002e0e234f140e4a8c2a8eb2 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 7 Mar 2016 18:08:30 +0100 Subject: [PATCH 03/27] Refactor module. - Remove dependency on event_sale. - Add custom field that allows to choose in which events to disable duplicates. - Add tests. - Add custom exception to be used in upcoming submodule (for event_sale). --- event_registration_partner_unique/README.rst | 17 ++--- event_registration_partner_unique/__init__.py | 1 - .../__openerp__.py | 8 +-- .../exceptions.py | 21 ++++++ event_registration_partner_unique/hooks.py | 67 ------------------- event_registration_partner_unique/i18n/es.po | 43 +++++------- .../models/__init__.py | 2 +- .../models/event.py | 49 ++++++++++++++ .../models/sale_order.py | 35 ---------- .../tests/__init__.py | 5 ++ .../tests/test_event.py | 41 ++++++++++++ .../views/event_event_view.xml | 20 ++++++ 12 files changed, 165 insertions(+), 144 deletions(-) create mode 100644 event_registration_partner_unique/exceptions.py delete mode 100644 event_registration_partner_unique/hooks.py create mode 100644 event_registration_partner_unique/models/event.py delete mode 100644 event_registration_partner_unique/models/sale_order.py create mode 100644 event_registration_partner_unique/tests/__init__.py create mode 100644 event_registration_partner_unique/tests/test_event.py create mode 100644 event_registration_partner_unique/views/event_event_view.xml diff --git a/event_registration_partner_unique/README.rst b/event_registration_partner_unique/README.rst index c940ce786..d8e856047 100644 --- a/event_registration_partner_unique/README.rst +++ b/event_registration_partner_unique/README.rst @@ -6,23 +6,18 @@ Unique Partner per Event ======================== -This module extends the functionality of events to support forbidding to duplicate the same partner in an event. - -Installation -============ - -To install this module, you need to: - -* Remove all duplicated registrations from events. +This module extends the functionality of events to support forbidding to +duplicate the same partner in an event. Usage ===== To use this module, you need to: -* Go to *Marketing > Events > Registrations*. -* Try to create 2 registrations for the same partner and event. -* You cannot. +#. Go to *Marketing > Events > Create*. +#. Enable *Forbid duplicates*. +#. Try to create 2 registrations for the same partner in this event. +#. You cannot. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot diff --git a/event_registration_partner_unique/__init__.py b/event_registration_partner_unique/__init__.py index 40c563976..ac009a203 100644 --- a/event_registration_partner_unique/__init__.py +++ b/event_registration_partner_unique/__init__.py @@ -3,4 +3,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models -from .hooks import pre_init_hook, post_init_hook, uninstall_hook diff --git a/event_registration_partner_unique/__openerp__.py b/event_registration_partner_unique/__openerp__.py index 61a67b6e1..89445f41c 100644 --- a/event_registration_partner_unique/__openerp__.py +++ b/event_registration_partner_unique/__openerp__.py @@ -11,10 +11,10 @@ "license": "AGPL-3", "application": False, "installable": True, - "pre_init_hook": "pre_init_hook", - "post_init_hook": "post_init_hook", - "uninstall_hook": "uninstall_hook", "depends": [ - "event_sale", + "event", + ], + "data": [ + "views/event_event_view.xml", ], } diff --git a/event_registration_partner_unique/exceptions.py b/event_registration_partner_unique/exceptions.py new file mode 100644 index 000000000..41b095f96 --- /dev/null +++ b/event_registration_partner_unique/exceptions.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import _, exceptions + + +class UniqueRegistrationPartnerValidationError(exceptions.ValidationError): + """Base class for this module's validation errors.""" + def __init__(self, *args, **kwargs): + self._args, self._kwargs = args, kwargs + value = self._message() + super(UniqueRegistrationPartnerValidationError, self).__init__(value) + + def _message(self): + """Format the message.""" + return self.__doc__.format(*self._args, **self._kwargs) + + +class DuplicatedPartnerError(UniqueRegistrationPartnerValidationError): + __doc__ = _("Duplicated partners found in event {0}: {1}.") diff --git a/event_registration_partner_unique/hooks.py b/event_registration_partner_unique/hooks.py deleted file mode 100644 index 35607719f..000000000 --- a/event_registration_partner_unique/hooks.py +++ /dev/null @@ -1,67 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2016 Antiun Ingeniería S.L. - Jairo Llopis -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openerp import _, exceptions - - -def pre_init_hook(cr): - """Ensure no duplicates before installing.""" - cr.execute(""" - SELECT - event_event.name, - res_partner.name, - COUNT(*) AS duplicates - FROM - event_registration - - INNER JOIN event_event - ON event_event.id = event_registration.event_id - - INNER JOIN res_partner - ON res_partner.id = event_registration.partner_id - GROUP BY - event_registration.event_id, - event_event.name, - event_registration.partner_id, - res_partner.name - HAVING - COUNT(*) > 1 - """) - rows = cr.fetchall() - if rows: - message = _("Event %s; Partner %s; %d duplicates.") - details = "\n".join(message % row for row in rows) - raise exceptions.ValidationError( - _("Remove duplicates before installing:\n%s") % details) - - -def post_init_hook(cr, registry): - """Using custom unique indexes because of null values in tickets. - - See http://stackoverflow.com/a/8289253/1468388. - """ - indexes = ( - """ - CREATE UNIQUE INDEX - event_registration_unique_partner_ticket_null - ON event_registration (partner_id, event_id) - WHERE event_ticket_id IS NULL - """, - """ - CREATE UNIQUE INDEX - event_registration_unique_partner_ticket_fill - ON event_registration (partner_id, event_id, event_ticket_id) - WHERE event_ticket_id IS NOT NULL - """, - ) - for index in indexes: - cr.execute(index) - - -def uninstall_hook(cr, registry): - """Remove manual unique indexes.""" - cr.execute( - "DROP INDEX IF EXISTS event_registration_unique_partner_ticket_null") - cr.execute( - "DROP INDEX IF EXISTS event_registration_unique_partner_ticket_fill") diff --git a/event_registration_partner_unique/i18n/es.po b/event_registration_partner_unique/i18n/es.po index d35a667b6..3d9831d93 100644 --- a/event_registration_partner_unique/i18n/es.po +++ b/event_registration_partner_unique/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-03-03 17:59+0100\n" -"PO-Revision-Date: 2016-03-03 17:59+0100\n" +"POT-Creation-Date: 2016-03-07 18:44+0100\n" +"PO-Revision-Date: 2016-03-07 18:46+0100\n" "Last-Translator: <>\n" "Language-Team: \n" "Language: es\n" @@ -18,34 +18,27 @@ msgstr "" "X-Generator: Poedit 1.8.6\n" #. module: event_registration_partner_unique -#: code:addons/event_registration_partner_unique/models/sale_order.py:32 -#, python-format -msgid "%d new registrations sold in %s." -msgstr "%d nuevos registros vendidos en %s." +#: help:event.event,forbid_duplicates:0 +msgid "Check this to disallow duplicate partners in an event" +msgstr "Active esto para impedir que haya registros de empresas duplicadas en el evento" #. module: event_registration_partner_unique -#: code:addons/event_registration_partner_unique/hooks.py:33 +#: code:addons/event_registration_partner_unique/exceptions.py:21 #, python-format -msgid "Event %s; Partner %s; %d duplicates." -msgstr "Evento %s; Empresa %s; %d duplicados." +msgid "Duplicated partners found in event {0}: {1}." +msgstr "Empresas duplicadas encontradas en el evento {0}: {1}." #. module: event_registration_partner_unique -#: code:addons/event_registration_partner_unique/hooks.py:36 -#, python-format -msgid "" -"Remove duplicates before installing:\n" -"%s" -msgstr "" -"Borre los duplicados antes de instalar:\n" -"%s" +#: model:ir.model,name:event_registration_partner_unique.model_event_event +msgid "Event" +msgstr "Evento" #. module: event_registration_partner_unique -#: model:ir.model,name:event_registration_partner_unique.model_sale_order_line -msgid "Sales Order Line" -msgstr "Línea del pedido de ventas" - -#~ msgid "Cannot repeat partner in the same event." -#~ msgstr "No puede repetir una empresa en el mismo evento." +#: model:ir.model,name:event_registration_partner_unique.model_event_registration +msgid "Event Registration" +msgstr "Registro del evento" -#~ msgid "Event Registration" -#~ msgstr "Registro del evento" +#. module: event_registration_partner_unique +#: field:event.event,forbid_duplicates:0 +msgid "Forbid duplicates" +msgstr "Prohibir duplicados" diff --git a/event_registration_partner_unique/models/__init__.py b/event_registration_partner_unique/models/__init__.py index c25866d17..29d29d9fb 100644 --- a/event_registration_partner_unique/models/__init__.py +++ b/event_registration_partner_unique/models/__init__.py @@ -2,4 +2,4 @@ # © 2016 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import sale_order +from . import event diff --git a/event_registration_partner_unique/models/event.py b/event_registration_partner_unique/models/event.py new file mode 100644 index 000000000..835a27279 --- /dev/null +++ b/event_registration_partner_unique/models/event.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import api, fields, models +from .. import exceptions + + +class EventEvent(models.Model): + _inherit = "event.event" + + forbid_duplicates = fields.Boolean( + help="Check this to disallow duplicate partners in this event's " + "registrations", + ) + + @api.multi + @api.constrains("forbid_duplicates", "registration_ids") + def _check_forbid_duplicates(self): + """Ensure no duplicated partners are found in the event.""" + return (self.filtered("forbid_duplicates") + .registration_ids._check_forbid_duplicates()) + + +class EventRegistration(models.Model): + _inherit = "event.registration" + + @api.multi + @api.constrains("event_id", "partner_id") + def _check_forbid_duplicates(self): + """Ensure no duplicated partners are found in the event.""" + for s in self.filtered("event_id.forbid_duplicates"): + dupes = self.search(s._duplicate_search_domain()) + if dupes: + raise exceptions.DuplicatedPartnerError( + s.event_id.display_name, + ", ".join(d.display_name + for d in dupes.mapped("partner_id")), + registrations=dupes, + ) + + @api.multi + def _duplicate_search_domain(self): + """What to look for when searching duplicates.""" + return [ + ("id", "!=", self.id), + ("event_id", "=", self.event_id.id), + ("partner_id", "=", self.partner_id.id), + ] diff --git a/event_registration_partner_unique/models/sale_order.py b/event_registration_partner_unique/models/sale_order.py deleted file mode 100644 index 4cb230bdd..000000000 --- a/event_registration_partner_unique/models/sale_order.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2016 Antiun Ingeniería S.L. - Jairo Llopis -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from psycopg2 import IntegrityError -from openerp import _, api, models - - -class SaleOrderLine(models.Model): - _inherit = "sale.order.line" - - @api.multi - def button_confirm(self): - """Add registrations to the already existing record if possible.""" - registrations = self.env["event.registration"] - - for s in self: - try: - with self.env.cr.savepoint(): - super(SaleOrderLine, s).button_confirm() - - # A registration already exists - except IntegrityError: - match = registrations.search([ - ("event_id", "=", s.event_id.id), - ("event_ticket_id", "=", s.event_ticket_id.id), - ("partner_id", "=", s.order_id.partner_id.id), - ]) - qty = int(s.product_uom_qty) - match.nb_register += qty - match = match.with_context(mail_create_nolog=True) - match.message_post(_("%d new registrations sold in %s.") % - (qty, s.order_id.display_name)) - - return True diff --git a/event_registration_partner_unique/tests/__init__.py b/event_registration_partner_unique/tests/__init__.py new file mode 100644 index 000000000..e467b70f8 --- /dev/null +++ b/event_registration_partner_unique/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_event diff --git a/event_registration_partner_unique/tests/test_event.py b/event_registration_partner_unique/tests/test_event.py new file mode 100644 index 000000000..fcfd60258 --- /dev/null +++ b/event_registration_partner_unique/tests/test_event.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from .. import exceptions +from openerp.tests.common import TransactionCase + + +class DuplicatedPartnerCase(TransactionCase): + def setUp(self): + super(DuplicatedPartnerCase, self).setUp() + self.event = self.env.ref("event.event_0") + self.partner = self.env.ref("base.res_partner_1") + self.registration = self.env["event.registration"].create({ + "event_id": self.event.id, + "partner_id": self.partner.id, + }) + + def test_allowed(self): + """No problem when it is not forbidden.""" + self.registration.copy() + + def test_forbidden(self): + """Cannot when it is forbidden.""" + self.event.forbid_duplicates = True + with self.assertRaises(exceptions.DuplicatedPartnerError): + self.registration.copy() + + def test_saved_in_exception(self): + """The failing partners are saved in the exception.""" + self.event.forbid_duplicates = True + try: + self.registration.copy() + except exceptions.DuplicatedPartnerError as error: + self.assertEqual(error._kwargs["registrations"], self.registration) + + def test_duplicates_already_exist(self): + """Cannot forbid what already happened.""" + self.registration.copy() + with self.assertRaises(exceptions.DuplicatedPartnerError): + self.event.forbid_duplicates = True diff --git a/event_registration_partner_unique/views/event_event_view.xml b/event_registration_partner_unique/views/event_event_view.xml new file mode 100644 index 000000000..8947fb238 --- /dev/null +++ b/event_registration_partner_unique/views/event_event_view.xml @@ -0,0 +1,20 @@ + + + + + + + + Add option to avoid duplicates + event.event + + + + + + + + + + From 7bbf356ce0c7d13b48c2e6a6ea67a5634b8d38d5 Mon Sep 17 00:00:00 2001 From: cubells Date: Tue, 10 Jan 2017 22:18:48 +0100 Subject: [PATCH 04/27] [9.0][MIG] event_registration_partner_unique module - Updated views - Updated README --- event_registration_partner_unique/README.rst | 11 ++++------- event_registration_partner_unique/__openerp__.py | 9 ++++++--- .../views/event_event_view.xml | 9 ++++----- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/event_registration_partner_unique/README.rst b/event_registration_partner_unique/README.rst index d8e856047..88509df7e 100644 --- a/event_registration_partner_unique/README.rst +++ b/event_registration_partner_unique/README.rst @@ -14,14 +14,14 @@ Usage To use this module, you need to: -#. Go to *Marketing > Events > Create*. +#. Go to *Events > Events > Create*. #. Enable *Forbid duplicates*. #. Try to create 2 registrations for the same partner in this event. #. You cannot. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/199/8.0 + :target: https://runbot.odoo-community.org/runbot/199/9.0 Known issues / Roadmap ====================== @@ -34,11 +34,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, -help us smashing it by providing a detailed and welcomed `feedback -`_. +help us smash it by providing detailed and welcomed feedback. Credits ======= @@ -53,6 +49,7 @@ Contributors * Rafael Blasco * Jairo Llopis +* Vicent Cubells Maintainer ---------- diff --git a/event_registration_partner_unique/__openerp__.py b/event_registration_partner_unique/__openerp__.py index 89445f41c..fae690d61 100644 --- a/event_registration_partner_unique/__openerp__.py +++ b/event_registration_partner_unique/__openerp__.py @@ -1,13 +1,16 @@ # -*- coding: utf-8 -*- -# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis +# Copyright 2017 Tecnativa - Vicent Cubells # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Unique Partner per Event", "summary": "Enforces 1 registration per partner and event", - "version": "8.0.1.0.0", + "version": "9.0.1.0.0", "category": "Events", "website": "http://www.antiun.com", - "author": "Antiun Ingeniería S.L., Odoo Community Association (OCA)", + "author": "Antiun Ingeniería S.L., " + "Tecnativa, " + "Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, diff --git a/event_registration_partner_unique/views/event_event_view.xml b/event_registration_partner_unique/views/event_event_view.xml index 8947fb238..dd97368b8 100644 --- a/event_registration_partner_unique/views/event_event_view.xml +++ b/event_registration_partner_unique/views/event_event_view.xml @@ -1,9 +1,9 @@ - - - + Add option to avoid duplicates @@ -16,5 +16,4 @@ - - + From 745dfe287966926a585599812e7cd2060bbd6c4a Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Fri, 3 Feb 2017 21:02:04 +0100 Subject: [PATCH 05/27] [FIX] event_registration_partner_unique: Change event view priority --- event_registration_partner_unique/views/event_event_view.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/event_registration_partner_unique/views/event_event_view.xml b/event_registration_partner_unique/views/event_event_view.xml index dd97368b8..7148c1cd2 100644 --- a/event_registration_partner_unique/views/event_event_view.xml +++ b/event_registration_partner_unique/views/event_event_view.xml @@ -8,6 +8,8 @@ Add option to avoid duplicates event.event + + From 6a8da8e35a6421f6218bb3f11ab75627b7a8f948 Mon Sep 17 00:00:00 2001 From: cristinamartinrod Date: Tue, 30 Oct 2018 17:19:12 +0100 Subject: [PATCH 06/27] [11.0][MIG] event_registration_partner_unique: Migration to 11.0 --- event_registration_partner_unique/README.rst | 92 ++-- event_registration_partner_unique/__init__.py | 2 - .../{__openerp__.py => __manifest__.py} | 14 +- .../exceptions.py | 5 +- .../models/__init__.py | 2 - .../models/event.py | 13 +- .../readme/CONTRIBUTORS.rst | 6 + .../readme/DESCRIPTION.rst | 2 + .../readme/USAGE.rst | 4 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 439 ++++++++++++++++++ .../tests/__init__.py | 2 - .../tests/test_event.py | 5 +- .../views/event_event_view.xml | 2 +- 14 files changed, 525 insertions(+), 63 deletions(-) rename event_registration_partner_unique/{__openerp__.py => __manifest__.py} (64%) create mode 100644 event_registration_partner_unique/readme/CONTRIBUTORS.rst create mode 100644 event_registration_partner_unique/readme/DESCRIPTION.rst create mode 100644 event_registration_partner_unique/readme/USAGE.rst create mode 100644 event_registration_partner_unique/static/description/icon.png create mode 100644 event_registration_partner_unique/static/description/index.html diff --git a/event_registration_partner_unique/README.rst b/event_registration_partner_unique/README.rst index 88509df7e..dae08e8ec 100644 --- a/event_registration_partner_unique/README.rst +++ b/event_registration_partner_unique/README.rst @@ -1,67 +1,87 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - ======================== Unique Partner per Event ======================== -This module extends the functionality of events to support forbidding to -duplicate the same partner in an event. - -Usage -===== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github + :target: https://github.com/OCA/event/tree/11.0/event_registration_partner_unique + :alt: OCA/event +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/event-11-0/event-11-0-event_registration_partner_unique + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/199/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| -To use this module, you need to: +This module extends the functionality of events to support forbidding to +duplicate the same Attendee in an event. -#. Go to *Events > Events > Create*. -#. Enable *Forbid duplicates*. -#. Try to create 2 registrations for the same partner in this event. -#. You cannot. +**Table of contents** -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/199/9.0 +.. contents:: + :local: -Known issues / Roadmap -====================== +Usage +===== -* It would be nice to deduplicate at install, but that's quite destructive. +#. Go to **Events > Events > Create**. +#. Enable **Forbid duplicates**. +#. Try to create 2 registrations for the same Attendee in this event. +#. You can't. Bug Tracker =========== -Bugs are tracked on `GitHub Issues -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smash it by providing detailed and welcomed feedback. +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* Tecnativa Contributors ------------- +~~~~~~~~~~~~ + +* `Tecnativa `_ -* Rafael Blasco -* Jairo Llopis -* Vicent Cubells + * Rafael Blasco + * Jairo Llopis + * Vicent Cubells + * Cristina Martin R. -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/event `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/event_registration_partner_unique/__init__.py b/event_registration_partner_unique/__init__.py index ac009a203..83e553ac4 100644 --- a/event_registration_partner_unique/__init__.py +++ b/event_registration_partner_unique/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# © 2016 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/event_registration_partner_unique/__openerp__.py b/event_registration_partner_unique/__manifest__.py similarity index 64% rename from event_registration_partner_unique/__openerp__.py rename to event_registration_partner_unique/__manifest__.py index fae690d61..2ae2f1171 100644 --- a/event_registration_partner_unique/__openerp__.py +++ b/event_registration_partner_unique/__manifest__.py @@ -1,21 +1,21 @@ -# -*- coding: utf-8 -*- -# Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis +# Copyright 2016 Tecnativa - Jairo Llopis # Copyright 2017 Tecnativa - Vicent Cubells +# Copyright 2018 Tecnativa - Cristina Martin R. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Unique Partner per Event", "summary": "Enforces 1 registration per partner and event", - "version": "9.0.1.0.0", - "category": "Events", - "website": "http://www.antiun.com", - "author": "Antiun Ingeniería S.L., " - "Tecnativa, " + "version": "11.0.1.0.0", + "category": "Marketing", + "website": "https://github.com/oca/event", + "author": "Tecnativa, " "Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, "depends": [ "event", + "partner_event", ], "data": [ "views/event_event_view.xml", diff --git a/event_registration_partner_unique/exceptions.py b/event_registration_partner_unique/exceptions.py index 41b095f96..ac3c186dd 100644 --- a/event_registration_partner_unique/exceptions.py +++ b/event_registration_partner_unique/exceptions.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- -# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import _, exceptions +from odoo import _, exceptions class UniqueRegistrationPartnerValidationError(exceptions.ValidationError): diff --git a/event_registration_partner_unique/models/__init__.py b/event_registration_partner_unique/models/__init__.py index 29d29d9fb..22dee4152 100644 --- a/event_registration_partner_unique/models/__init__.py +++ b/event_registration_partner_unique/models/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# © 2016 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import event diff --git a/event_registration_partner_unique/models/event.py b/event_registration_partner_unique/models/event.py index 835a27279..edc7b3336 100644 --- a/event_registration_partner_unique/models/event.py +++ b/event_registration_partner_unique/models/event.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- -# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import api, fields, models +from odoo import api, fields, models from .. import exceptions @@ -10,14 +9,14 @@ class EventEvent(models.Model): _inherit = "event.event" forbid_duplicates = fields.Boolean( - help="Check this to disallow duplicate partners in this event's " + help="Check this to disallow duplicate attendees in this event's " "registrations", ) @api.multi @api.constrains("forbid_duplicates", "registration_ids") def _check_forbid_duplicates(self): - """Ensure no duplicated partners are found in the event.""" + """Ensure no duplicated attendee are found in the event.""" return (self.filtered("forbid_duplicates") .registration_ids._check_forbid_duplicates()) @@ -28,7 +27,7 @@ class EventRegistration(models.Model): @api.multi @api.constrains("event_id", "partner_id") def _check_forbid_duplicates(self): - """Ensure no duplicated partners are found in the event.""" + """Ensure no duplicated attendees are found in the event.""" for s in self.filtered("event_id.forbid_duplicates"): dupes = self.search(s._duplicate_search_domain()) if dupes: @@ -45,5 +44,5 @@ def _duplicate_search_domain(self): return [ ("id", "!=", self.id), ("event_id", "=", self.event_id.id), - ("partner_id", "=", self.partner_id.id), + ("attendee_partner_id", "=", self.attendee_partner_id.id), ] diff --git a/event_registration_partner_unique/readme/CONTRIBUTORS.rst b/event_registration_partner_unique/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..47751e201 --- /dev/null +++ b/event_registration_partner_unique/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* `Tecnativa `_ + + * Rafael Blasco + * Jairo Llopis + * Vicent Cubells + * Cristina Martin R. diff --git a/event_registration_partner_unique/readme/DESCRIPTION.rst b/event_registration_partner_unique/readme/DESCRIPTION.rst new file mode 100644 index 000000000..e4b1d8834 --- /dev/null +++ b/event_registration_partner_unique/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module extends the functionality of events to support forbidding to +duplicate the same Attendee in an event. diff --git a/event_registration_partner_unique/readme/USAGE.rst b/event_registration_partner_unique/readme/USAGE.rst new file mode 100644 index 000000000..dbb71ec8a --- /dev/null +++ b/event_registration_partner_unique/readme/USAGE.rst @@ -0,0 +1,4 @@ +#. Go to **Events > Events > Create**. +#. Enable **Forbid duplicates**. +#. Try to create 2 registrations for the same Attendee in this event. +#. You can't. diff --git a/event_registration_partner_unique/static/description/icon.png b/event_registration_partner_unique/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;P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7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/event_registration_partner_unique/static/description/index.html b/event_registration_partner_unique/static/description/index.html new file mode 100644 index 000000000..229233990 --- /dev/null +++ b/event_registration_partner_unique/static/description/index.html @@ -0,0 +1,439 @@ + + + + + + +Unique Partner per Event + + + +
+

Unique Partner per Event

+ + +

Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runbot

+

This module extends the functionality of events to support forbidding to +duplicate the same Attendee in an event.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Events > Events > Create.
  2. +
  3. Enable Forbid duplicates.
  4. +
  5. Try to create 2 registrations for the same Attendee in this event.
  6. +
  7. You can’t.
  8. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa

    +
    +
      +
    • Rafael Blasco
    • +
    • Jairo Llopis
    • +
    • Vicent Cubells
    • +
    • Cristina Martin R.
    • +
    +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/event project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/event_registration_partner_unique/tests/__init__.py b/event_registration_partner_unique/tests/__init__.py index e467b70f8..3c5e143c6 100644 --- a/event_registration_partner_unique/tests/__init__.py +++ b/event_registration_partner_unique/tests/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# © 2016 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import test_event diff --git a/event_registration_partner_unique/tests/test_event.py b/event_registration_partner_unique/tests/test_event.py index fcfd60258..a9ab7d5a0 100644 --- a/event_registration_partner_unique/tests/test_event.py +++ b/event_registration_partner_unique/tests/test_event.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- -# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from .. import exceptions -from openerp.tests.common import TransactionCase +from odoo.tests.common import TransactionCase class DuplicatedPartnerCase(TransactionCase): diff --git a/event_registration_partner_unique/views/event_event_view.xml b/event_registration_partner_unique/views/event_event_view.xml index 7148c1cd2..e1b2f5210 100644 --- a/event_registration_partner_unique/views/event_event_view.xml +++ b/event_registration_partner_unique/views/event_event_view.xml @@ -1,5 +1,5 @@ - From 3721cce39acdb90c28adb223d3efbac27c7b2fa9 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 8 Nov 2018 16:39:24 +0100 Subject: [PATCH 07/27] [FIX] event_registration_partner_unique: Change all references to attendee_partner_id --- event_registration_partner_unique/models/event.py | 4 ++-- .../tests/test_event.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/event_registration_partner_unique/models/event.py b/event_registration_partner_unique/models/event.py index edc7b3336..faac8d2f6 100644 --- a/event_registration_partner_unique/models/event.py +++ b/event_registration_partner_unique/models/event.py @@ -25,7 +25,7 @@ class EventRegistration(models.Model): _inherit = "event.registration" @api.multi - @api.constrains("event_id", "partner_id") + @api.constrains("event_id", "attendee_partner_id") def _check_forbid_duplicates(self): """Ensure no duplicated attendees are found in the event.""" for s in self.filtered("event_id.forbid_duplicates"): @@ -34,7 +34,7 @@ def _check_forbid_duplicates(self): raise exceptions.DuplicatedPartnerError( s.event_id.display_name, ", ".join(d.display_name - for d in dupes.mapped("partner_id")), + for d in dupes.mapped("attendee_partner_id")), registrations=dupes, ) diff --git a/event_registration_partner_unique/tests/test_event.py b/event_registration_partner_unique/tests/test_event.py index a9ab7d5a0..b8a44a39a 100644 --- a/event_registration_partner_unique/tests/test_event.py +++ b/event_registration_partner_unique/tests/test_event.py @@ -13,6 +13,7 @@ def setUp(self): self.registration = self.env["event.registration"].create({ "event_id": self.event.id, "partner_id": self.partner.id, + "attendee_partner_id": self.partner.id, }) def test_allowed(self): @@ -23,18 +24,24 @@ def test_forbidden(self): """Cannot when it is forbidden.""" self.event.forbid_duplicates = True with self.assertRaises(exceptions.DuplicatedPartnerError): - self.registration.copy() + self.registration.copy({ + 'attendee_partner_id': self.registration.attendee_partner_id.id + }) def test_saved_in_exception(self): """The failing partners are saved in the exception.""" self.event.forbid_duplicates = True try: - self.registration.copy() + self.registration.copy({ + 'attendee_partner_id': self.registration.attendee_partner_id.id + }) except exceptions.DuplicatedPartnerError as error: self.assertEqual(error._kwargs["registrations"], self.registration) def test_duplicates_already_exist(self): """Cannot forbid what already happened.""" - self.registration.copy() + self.registration.copy({ + 'attendee_partner_id': self.registration.attendee_partner_id.id, + }) with self.assertRaises(exceptions.DuplicatedPartnerError): self.event.forbid_duplicates = True From 5f038f2d9a04483b00fa31c6141ee88463d76e72 Mon Sep 17 00:00:00 2001 From: "Victor M.M. Torres" Date: Mon, 26 Aug 2019 21:03:41 +0200 Subject: [PATCH 08/27] [MIG] event_registration_partner_unique: Migration to v12 --- event_registration_partner_unique/README.rst | 30 +++++++++--- .../__manifest__.py | 2 +- event_registration_partner_unique/i18n/es.po | 17 ++++--- .../event_registration_partner_unique.pot | 41 ++++++++++++++++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 4 +- .../readme/ROADMAP.rst | 11 +++++ .../static/description/index.html | 48 +++++++++++++------ 8 files changed, 123 insertions(+), 31 deletions(-) create mode 100644 event_registration_partner_unique/i18n/event_registration_partner_unique.pot create mode 100644 event_registration_partner_unique/readme/ROADMAP.rst diff --git a/event_registration_partner_unique/README.rst b/event_registration_partner_unique/README.rst index dae08e8ec..61bd83fc9 100644 --- a/event_registration_partner_unique/README.rst +++ b/event_registration_partner_unique/README.rst @@ -14,19 +14,19 @@ Unique Partner per Event :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github - :target: https://github.com/OCA/event/tree/11.0/event_registration_partner_unique + :target: https://github.com/OCA/event/tree/12.0/event_registration_partner_unique :alt: OCA/event .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/event-11-0/event-11-0-event_registration_partner_unique + :target: https://translation.odoo-community.org/projects/event-12-0/event-12-0-event_registration_partner_unique :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/199/11.0 + :target: https://runbot.odoo-community.org/runbot/199/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| -This module extends the functionality of events to support forbidding to -duplicate the same Attendee in an event. +This module intended used only with backend and extends the functionality of events +to support forbidding to duplicate the same Attendee in an event. **Table of contents** @@ -41,13 +41,28 @@ Usage #. Try to create 2 registrations for the same Attendee in this event. #. You can't. +Known issues / Roadmap +====================== + +* This modules intended used with backend, so the validation error + are enough to show user what is wrong, when *website_event* is installed + public user would try register attendees. + As soon try more than one attendee this will trigger validation error as + the attendee partner is duplicated the error shown is 500 internal server error + which is no appropriated. +* It would be necessary have a new module with depends on website_event and this + one to prevent this issue. +* Another kind of problem is with *event_sale* module that would try use Sale Order + contact as attendee that will lead to the issue of attendee duplicates if try to + buy two times same event. + Bug Tracker =========== Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -68,6 +83,7 @@ Contributors * Jairo Llopis * Vicent Cubells * Cristina Martin R. + * Victor M.M. Torres Maintainers ~~~~~~~~~~~ @@ -82,6 +98,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/event `_ project on GitHub. +This module is part of the `OCA/event `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/event_registration_partner_unique/__manifest__.py b/event_registration_partner_unique/__manifest__.py index 2ae2f1171..6e68ec6ef 100644 --- a/event_registration_partner_unique/__manifest__.py +++ b/event_registration_partner_unique/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Unique Partner per Event", "summary": "Enforces 1 registration per partner and event", - "version": "11.0.1.0.0", + "version": "12.0.1.0.0", "category": "Marketing", "website": "https://github.com/oca/event", "author": "Tecnativa, " diff --git a/event_registration_partner_unique/i18n/es.po b/event_registration_partner_unique/i18n/es.po index 3d9831d93..c0c60eadc 100644 --- a/event_registration_partner_unique/i18n/es.po +++ b/event_registration_partner_unique/i18n/es.po @@ -18,12 +18,16 @@ msgstr "" "X-Generator: Poedit 1.8.6\n" #. module: event_registration_partner_unique -#: help:event.event,forbid_duplicates:0 -msgid "Check this to disallow duplicate partners in an event" -msgstr "Active esto para impedir que haya registros de empresas duplicadas en el evento" +#: model:ir.model.fields,help:event_registration_partner_unique.field_event_event__forbid_duplicates +#, fuzzy +msgid "" +"Check this to disallow duplicate attendees in this event's registrations" +msgstr "" +"Active esto para impedir que haya registros de empresas duplicadas en el " +"evento" #. module: event_registration_partner_unique -#: code:addons/event_registration_partner_unique/exceptions.py:21 +#: code:addons/event_registration_partner_unique/exceptions.py:20 #, python-format msgid "Duplicated partners found in event {0}: {1}." msgstr "Empresas duplicadas encontradas en el evento {0}: {1}." @@ -39,6 +43,7 @@ msgid "Event Registration" msgstr "Registro del evento" #. module: event_registration_partner_unique -#: field:event.event,forbid_duplicates:0 -msgid "Forbid duplicates" +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__forbid_duplicates +#, fuzzy +msgid "Forbid Duplicates" msgstr "Prohibir duplicados" diff --git a/event_registration_partner_unique/i18n/event_registration_partner_unique.pot b/event_registration_partner_unique/i18n/event_registration_partner_unique.pot new file mode 100644 index 000000000..94c54f597 --- /dev/null +++ b/event_registration_partner_unique/i18n/event_registration_partner_unique.pot @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * event_registration_partner_unique +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: event_registration_partner_unique +#: model:ir.model.fields,help:event_registration_partner_unique.field_event_event__forbid_duplicates +msgid "Check this to disallow duplicate attendees in this event's registrations" +msgstr "" + +#. module: event_registration_partner_unique +#: code:addons/event_registration_partner_unique/exceptions.py:20 +#, python-format +msgid "Duplicated partners found in event {0}: {1}." +msgstr "" + +#. module: event_registration_partner_unique +#: model:ir.model,name:event_registration_partner_unique.model_event_event +msgid "Event" +msgstr "" + +#. module: event_registration_partner_unique +#: model:ir.model,name:event_registration_partner_unique.model_event_registration +msgid "Event Registration" +msgstr "" + +#. module: event_registration_partner_unique +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__forbid_duplicates +msgid "Forbid Duplicates" +msgstr "" + diff --git a/event_registration_partner_unique/readme/CONTRIBUTORS.rst b/event_registration_partner_unique/readme/CONTRIBUTORS.rst index 47751e201..6759f4fad 100644 --- a/event_registration_partner_unique/readme/CONTRIBUTORS.rst +++ b/event_registration_partner_unique/readme/CONTRIBUTORS.rst @@ -4,3 +4,4 @@ * Jairo Llopis * Vicent Cubells * Cristina Martin R. + * Victor M.M. Torres diff --git a/event_registration_partner_unique/readme/DESCRIPTION.rst b/event_registration_partner_unique/readme/DESCRIPTION.rst index e4b1d8834..96e21c4dd 100644 --- a/event_registration_partner_unique/readme/DESCRIPTION.rst +++ b/event_registration_partner_unique/readme/DESCRIPTION.rst @@ -1,2 +1,2 @@ -This module extends the functionality of events to support forbidding to -duplicate the same Attendee in an event. +This module intended used only with backend and extends the functionality of events +to support forbidding to duplicate the same Attendee in an event. diff --git a/event_registration_partner_unique/readme/ROADMAP.rst b/event_registration_partner_unique/readme/ROADMAP.rst new file mode 100644 index 000000000..dc42bfd49 --- /dev/null +++ b/event_registration_partner_unique/readme/ROADMAP.rst @@ -0,0 +1,11 @@ +* This modules intended used with backend, so the validation error + are enough to show user what is wrong, when *website_event* is installed + public user would try register attendees. + As soon try more than one attendee this will trigger validation error as + the attendee partner is duplicated the error shown is 500 internal server error + which is no appropriated. +* It would be necessary have a new module with depends on website_event and this + one to prevent this issue. +* Another kind of problem is with *event_sale* module that would try use Sale Order + contact as attendee that will lead to the issue of attendee duplicates if try to + buy two times same event. diff --git a/event_registration_partner_unique/static/description/index.html b/event_registration_partner_unique/static/description/index.html index 229233990..33213e730 100644 --- a/event_registration_partner_unique/static/description/index.html +++ b/event_registration_partner_unique/static/description/index.html @@ -367,18 +367,19 @@

Unique Partner per Event

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runbot

-

This module extends the functionality of events to support forbidding to -duplicate the same Attendee in an event.

+

Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runbot

+

This module intended used only with backend and extends the functionality of events +to support forbidding to duplicate the same Attendee in an event.

Table of contents

+
+

Known issues / Roadmap

+
    +
  • This modules intended used with backend, so the validation error +are enough to show user what is wrong, when website_event is installed +public user would try register attendees. +As soon try more than one attendee this will trigger validation error as +the attendee partner is duplicated the error shown is 500 internal server error +which is no appropriated.
  • +
  • It would be necessary have a new module with depends on website_event and this +one to prevent this issue.
  • +
  • Another kind of problem is with event_sale module that would try use Sale Order +contact as attendee that will lead to the issue of attendee duplicates if try to +buy two times same event.
  • +
+
-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Authors

+

Authors

  • Tecnativa
-

Contributors

+

Contributors

  • Tecnativa

    @@ -418,19 +435,20 @@

    Contributors

  • Jairo Llopis
  • Vicent Cubells
  • Cristina Martin R.
  • +
  • Victor M.M. Torres
-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/event project on GitHub.

+

This module is part of the OCA/event project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

From a0c045e297273cab958fe15123432572a1e488e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 9 Sep 2020 10:28:18 +0200 Subject: [PATCH 09/27] [IMP] event_registration_partner_unique: black, isort, prettier --- .../__manifest__.py | 12 ++----- .../exceptions.py | 1 + .../models/event.py | 13 +++++--- .../tests/test_event.py | 33 ++++++++++--------- .../views/event_event_view.xml | 29 ++++++++-------- 5 files changed, 43 insertions(+), 45 deletions(-) diff --git a/event_registration_partner_unique/__manifest__.py b/event_registration_partner_unique/__manifest__.py index 6e68ec6ef..0e1430603 100644 --- a/event_registration_partner_unique/__manifest__.py +++ b/event_registration_partner_unique/__manifest__.py @@ -8,16 +8,10 @@ "version": "12.0.1.0.0", "category": "Marketing", "website": "https://github.com/oca/event", - "author": "Tecnativa, " - "Odoo Community Association (OCA)", + "author": "Tecnativa, " "Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, - "depends": [ - "event", - "partner_event", - ], - "data": [ - "views/event_event_view.xml", - ], + "depends": ["event", "partner_event"], + "data": ["views/event_event_view.xml"], } diff --git a/event_registration_partner_unique/exceptions.py b/event_registration_partner_unique/exceptions.py index ac3c186dd..48ece2e2c 100644 --- a/event_registration_partner_unique/exceptions.py +++ b/event_registration_partner_unique/exceptions.py @@ -6,6 +6,7 @@ class UniqueRegistrationPartnerValidationError(exceptions.ValidationError): """Base class for this module's validation errors.""" + def __init__(self, *args, **kwargs): self._args, self._kwargs = args, kwargs value = self._message() diff --git a/event_registration_partner_unique/models/event.py b/event_registration_partner_unique/models/event.py index faac8d2f6..7be4a2317 100644 --- a/event_registration_partner_unique/models/event.py +++ b/event_registration_partner_unique/models/event.py @@ -2,6 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import api, fields, models + from .. import exceptions @@ -10,15 +11,16 @@ class EventEvent(models.Model): forbid_duplicates = fields.Boolean( help="Check this to disallow duplicate attendees in this event's " - "registrations", + "registrations", ) @api.multi @api.constrains("forbid_duplicates", "registration_ids") def _check_forbid_duplicates(self): """Ensure no duplicated attendee are found in the event.""" - return (self.filtered("forbid_duplicates") - .registration_ids._check_forbid_duplicates()) + return self.filtered( + "forbid_duplicates" + ).registration_ids._check_forbid_duplicates() class EventRegistration(models.Model): @@ -33,8 +35,9 @@ def _check_forbid_duplicates(self): if dupes: raise exceptions.DuplicatedPartnerError( s.event_id.display_name, - ", ".join(d.display_name - for d in dupes.mapped("attendee_partner_id")), + ", ".join( + d.display_name for d in dupes.mapped("attendee_partner_id") + ), registrations=dupes, ) diff --git a/event_registration_partner_unique/tests/test_event.py b/event_registration_partner_unique/tests/test_event.py index b8a44a39a..d678a3c99 100644 --- a/event_registration_partner_unique/tests/test_event.py +++ b/event_registration_partner_unique/tests/test_event.py @@ -1,20 +1,23 @@ # Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from .. import exceptions from odoo.tests.common import TransactionCase +from .. import exceptions + class DuplicatedPartnerCase(TransactionCase): def setUp(self): super(DuplicatedPartnerCase, self).setUp() self.event = self.env.ref("event.event_0") self.partner = self.env.ref("base.res_partner_1") - self.registration = self.env["event.registration"].create({ - "event_id": self.event.id, - "partner_id": self.partner.id, - "attendee_partner_id": self.partner.id, - }) + self.registration = self.env["event.registration"].create( + { + "event_id": self.event.id, + "partner_id": self.partner.id, + "attendee_partner_id": self.partner.id, + } + ) def test_allowed(self): """No problem when it is not forbidden.""" @@ -24,24 +27,24 @@ def test_forbidden(self): """Cannot when it is forbidden.""" self.event.forbid_duplicates = True with self.assertRaises(exceptions.DuplicatedPartnerError): - self.registration.copy({ - 'attendee_partner_id': self.registration.attendee_partner_id.id - }) + self.registration.copy( + {"attendee_partner_id": self.registration.attendee_partner_id.id} + ) def test_saved_in_exception(self): """The failing partners are saved in the exception.""" self.event.forbid_duplicates = True try: - self.registration.copy({ - 'attendee_partner_id': self.registration.attendee_partner_id.id - }) + self.registration.copy( + {"attendee_partner_id": self.registration.attendee_partner_id.id} + ) except exceptions.DuplicatedPartnerError as error: self.assertEqual(error._kwargs["registrations"], self.registration) def test_duplicates_already_exist(self): """Cannot forbid what already happened.""" - self.registration.copy({ - 'attendee_partner_id': self.registration.attendee_partner_id.id, - }) + self.registration.copy( + {"attendee_partner_id": self.registration.attendee_partner_id.id} + ) with self.assertRaises(exceptions.DuplicatedPartnerError): self.event.forbid_duplicates = True diff --git a/event_registration_partner_unique/views/event_event_view.xml b/event_registration_partner_unique/views/event_event_view.xml index e1b2f5210..9ccebf68e 100644 --- a/event_registration_partner_unique/views/event_event_view.xml +++ b/event_registration_partner_unique/views/event_event_view.xml @@ -1,21 +1,18 @@ - + - - - - Add option to avoid duplicates - event.event - - - - - - - - - - + + Add option to avoid duplicates + event.event + + + + + + + + + From 807971604c5f56345b1f87d844755447a58a0e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 9 Sep 2020 10:56:38 +0200 Subject: [PATCH 10/27] [MIG] event_registration_partner_unique: Migration to 13.0 --- event_registration_partner_unique/README.rst | 11 ++++++----- event_registration_partner_unique/__manifest__.py | 3 ++- event_registration_partner_unique/i18n/es.po | 2 +- .../i18n/event_registration_partner_unique.pot | 12 ++++++------ event_registration_partner_unique/models/event.py | 13 ++++++------- .../readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 7 ++++--- .../tests/test_event.py | 4 +++- 8 files changed, 29 insertions(+), 24 deletions(-) diff --git a/event_registration_partner_unique/README.rst b/event_registration_partner_unique/README.rst index 61bd83fc9..7a6459760 100644 --- a/event_registration_partner_unique/README.rst +++ b/event_registration_partner_unique/README.rst @@ -14,13 +14,13 @@ Unique Partner per Event :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github - :target: https://github.com/OCA/event/tree/12.0/event_registration_partner_unique + :target: https://github.com/OCA/event/tree/13.0/event_registration_partner_unique :alt: OCA/event .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/event-12-0/event-12-0-event_registration_partner_unique + :target: https://translation.odoo-community.org/projects/event-13-0/event-13-0-event_registration_partner_unique :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/199/12.0 + :target: https://runbot.odoo-community.org/runbot/199/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -62,7 +62,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -84,6 +84,7 @@ Contributors * Vicent Cubells * Cristina Martin R. * Victor M.M. Torres + * Víctor Martínez Maintainers ~~~~~~~~~~~ @@ -98,6 +99,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/event `_ project on GitHub. +This module is part of the `OCA/event `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/event_registration_partner_unique/__manifest__.py b/event_registration_partner_unique/__manifest__.py index 0e1430603..77e217ad1 100644 --- a/event_registration_partner_unique/__manifest__.py +++ b/event_registration_partner_unique/__manifest__.py @@ -1,11 +1,12 @@ # Copyright 2016 Tecnativa - Jairo Llopis # Copyright 2017 Tecnativa - Vicent Cubells # Copyright 2018 Tecnativa - Cristina Martin R. +# Copyright 2020 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Unique Partner per Event", "summary": "Enforces 1 registration per partner and event", - "version": "12.0.1.0.0", + "version": "13.0.1.0.0", "category": "Marketing", "website": "https://github.com/oca/event", "author": "Tecnativa, " "Odoo Community Association (OCA)", diff --git a/event_registration_partner_unique/i18n/es.po b/event_registration_partner_unique/i18n/es.po index c0c60eadc..4e79737d9 100644 --- a/event_registration_partner_unique/i18n/es.po +++ b/event_registration_partner_unique/i18n/es.po @@ -27,7 +27,7 @@ msgstr "" "evento" #. module: event_registration_partner_unique -#: code:addons/event_registration_partner_unique/exceptions.py:20 +#: code:addons/event_registration_partner_unique/exceptions.py:0 #, python-format msgid "Duplicated partners found in event {0}: {1}." msgstr "Empresas duplicadas encontradas en el evento {0}: {1}." diff --git a/event_registration_partner_unique/i18n/event_registration_partner_unique.pot b/event_registration_partner_unique/i18n/event_registration_partner_unique.pot index 94c54f597..aa5dd8574 100644 --- a/event_registration_partner_unique/i18n/event_registration_partner_unique.pot +++ b/event_registration_partner_unique/i18n/event_registration_partner_unique.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * event_registration_partner_unique +# * event_registration_partner_unique # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -15,11 +15,12 @@ msgstr "" #. module: event_registration_partner_unique #: model:ir.model.fields,help:event_registration_partner_unique.field_event_event__forbid_duplicates -msgid "Check this to disallow duplicate attendees in this event's registrations" +msgid "" +"Check this to disallow duplicate attendees in this event's registrations" msgstr "" #. module: event_registration_partner_unique -#: code:addons/event_registration_partner_unique/exceptions.py:20 +#: code:addons/event_registration_partner_unique/exceptions.py:0 #, python-format msgid "Duplicated partners found in event {0}: {1}." msgstr "" @@ -38,4 +39,3 @@ msgstr "" #: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__forbid_duplicates msgid "Forbid Duplicates" msgstr "" - diff --git a/event_registration_partner_unique/models/event.py b/event_registration_partner_unique/models/event.py index 7be4a2317..4bf3b673d 100644 --- a/event_registration_partner_unique/models/event.py +++ b/event_registration_partner_unique/models/event.py @@ -1,4 +1,5 @@ # Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis +# Copyright 2020 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import api, fields, models @@ -14,7 +15,6 @@ class EventEvent(models.Model): "registrations", ) - @api.multi @api.constrains("forbid_duplicates", "registration_ids") def _check_forbid_duplicates(self): """Ensure no duplicated attendee are found in the event.""" @@ -26,22 +26,21 @@ def _check_forbid_duplicates(self): class EventRegistration(models.Model): _inherit = "event.registration" - @api.multi @api.constrains("event_id", "attendee_partner_id") def _check_forbid_duplicates(self): """Ensure no duplicated attendees are found in the event.""" - for s in self.filtered("event_id.forbid_duplicates"): - dupes = self.search(s._duplicate_search_domain()) + for event_reg in self.filtered("event_id.forbid_duplicates"): + dupes = self.search(event_reg._duplicate_search_domain()) if dupes: raise exceptions.DuplicatedPartnerError( - s.event_id.display_name, + event_reg.event_id.display_name, ", ".join( - d.display_name for d in dupes.mapped("attendee_partner_id") + partner_id.display_name + for partner_id in dupes.mapped("attendee_partner_id") ), registrations=dupes, ) - @api.multi def _duplicate_search_domain(self): """What to look for when searching duplicates.""" return [ diff --git a/event_registration_partner_unique/readme/CONTRIBUTORS.rst b/event_registration_partner_unique/readme/CONTRIBUTORS.rst index 6759f4fad..c531207ce 100644 --- a/event_registration_partner_unique/readme/CONTRIBUTORS.rst +++ b/event_registration_partner_unique/readme/CONTRIBUTORS.rst @@ -5,3 +5,4 @@ * Vicent Cubells * Cristina Martin R. * Victor M.M. Torres + * Víctor Martínez diff --git a/event_registration_partner_unique/static/description/index.html b/event_registration_partner_unique/static/description/index.html index 33213e730..8889e8ed8 100644 --- a/event_registration_partner_unique/static/description/index.html +++ b/event_registration_partner_unique/static/description/index.html @@ -367,7 +367,7 @@

Unique Partner per Event

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runbot

This module intended used only with backend and extends the functionality of events to support forbidding to duplicate the same Attendee in an event.

Table of contents

@@ -414,7 +414,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -436,6 +436,7 @@

Contributors

  • Vicent Cubells
  • Cristina Martin R.
  • Victor M.M. Torres
  • +
  • Víctor Martínez
  • @@ -448,7 +449,7 @@

    Maintainers

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/event project on GitHub.

    +

    This module is part of the OCA/event project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/event_registration_partner_unique/tests/test_event.py b/event_registration_partner_unique/tests/test_event.py index d678a3c99..3eb756276 100644 --- a/event_registration_partner_unique/tests/test_event.py +++ b/event_registration_partner_unique/tests/test_event.py @@ -1,4 +1,5 @@ # Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis +# Copyright 2020 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo.tests.common import TransactionCase @@ -8,8 +9,9 @@ class DuplicatedPartnerCase(TransactionCase): def setUp(self): - super(DuplicatedPartnerCase, self).setUp() + super().setUp() self.event = self.env.ref("event.event_0") + self.event.forbid_duplicates = False self.partner = self.env.ref("base.res_partner_1") self.registration = self.env["event.registration"].create( { From 2bd05112d736db443b6986d3e47bd6df09f10a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Su=C3=A1rez?= Date: Wed, 17 Mar 2021 12:44:38 +0000 Subject: [PATCH 11/27] Translated using Weblate (Spanish) Currently translated at 100.0% (5 of 5 strings) Translation: event-13.0/event-13.0-event_registration_partner_unique Translate-URL: https://translation.odoo-community.org/projects/event-13-0/event-13-0-event_registration_partner_unique/es/ --- event_registration_partner_unique/i18n/es.po | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/event_registration_partner_unique/i18n/es.po b/event_registration_partner_unique/i18n/es.po index 4e79737d9..44ac33ded 100644 --- a/event_registration_partner_unique/i18n/es.po +++ b/event_registration_partner_unique/i18n/es.po @@ -7,24 +7,23 @@ msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-03-07 18:44+0100\n" -"PO-Revision-Date: 2016-03-07 18:46+0100\n" -"Last-Translator: <>\n" +"PO-Revision-Date: 2021-03-17 14:45+0000\n" +"Last-Translator: Ana Suárez \n" "Language-Team: \n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: \n" -"X-Generator: Poedit 1.8.6\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" #. module: event_registration_partner_unique #: model:ir.model.fields,help:event_registration_partner_unique.field_event_event__forbid_duplicates -#, fuzzy msgid "" "Check this to disallow duplicate attendees in this event's registrations" msgstr "" -"Active esto para impedir que haya registros de empresas duplicadas en el " -"evento" +"Marque esto para impedir que haya asistentes duplicados en los registrados a " +"este evento" #. module: event_registration_partner_unique #: code:addons/event_registration_partner_unique/exceptions.py:0 @@ -44,6 +43,5 @@ msgstr "Registro del evento" #. module: event_registration_partner_unique #: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__forbid_duplicates -#, fuzzy msgid "Forbid Duplicates" msgstr "Prohibir duplicados" From 14c502f04fa3ee3b307aef1fc7fafcd5413c86ff Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 16 Nov 2021 08:51:13 +0100 Subject: [PATCH 12/27] [FIX] event_registration_partner_unique: Avoid false positives Steps to reproduce the problem: - Register anonymously a first attendee for an event from website. - The registration is saved with no attendee_partner_id. - Repeat the registration again anonymously. - You get the error "Duplicated partners found in event...". That's because current duplicated domain is searching for other registrations regardless of if there's a linked partner or not. We now restrict the search to those with a linked partner. TT32961 --- event_registration_partner_unique/__manifest__.py | 2 +- event_registration_partner_unique/models/event.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/event_registration_partner_unique/__manifest__.py b/event_registration_partner_unique/__manifest__.py index 77e217ad1..6d752b34e 100644 --- a/event_registration_partner_unique/__manifest__.py +++ b/event_registration_partner_unique/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Unique Partner per Event", "summary": "Enforces 1 registration per partner and event", - "version": "13.0.1.0.0", + "version": "13.0.1.0.1", "category": "Marketing", "website": "https://github.com/oca/event", "author": "Tecnativa, " "Odoo Community Association (OCA)", diff --git a/event_registration_partner_unique/models/event.py b/event_registration_partner_unique/models/event.py index 4bf3b673d..3e463975a 100644 --- a/event_registration_partner_unique/models/event.py +++ b/event_registration_partner_unique/models/event.py @@ -47,4 +47,5 @@ def _duplicate_search_domain(self): ("id", "!=", self.id), ("event_id", "=", self.event_id.id), ("attendee_partner_id", "=", self.attendee_partner_id.id), + ("attendee_partner_id", "!=", False), ] From 762d89a8988b9f3d9253d0ae7311e1a52ff50ff4 Mon Sep 17 00:00:00 2001 From: "Luis D. Lafaurie" Date: Tue, 26 Apr 2022 10:07:33 +0200 Subject: [PATCH 13/27] [IMP] event_registration_partner_unique: black, isort, prettier --- event_registration_partner_unique/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event_registration_partner_unique/__manifest__.py b/event_registration_partner_unique/__manifest__.py index 6d752b34e..e0c0c7b61 100644 --- a/event_registration_partner_unique/__manifest__.py +++ b/event_registration_partner_unique/__manifest__.py @@ -8,7 +8,7 @@ "summary": "Enforces 1 registration per partner and event", "version": "13.0.1.0.1", "category": "Marketing", - "website": "https://github.com/oca/event", + "website": "https://github.com/OCA/event", "author": "Tecnativa, " "Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, From 73d94fb63499cc578a38f68ac16fff90a0e15b97 Mon Sep 17 00:00:00 2001 From: "Luis D. Lafaurie" Date: Tue, 26 Apr 2022 11:11:35 +0200 Subject: [PATCH 14/27] [MIG] event_registration_partner_unique: Migration to 14.0 --- event_registration_partner_unique/README.rst | 48 ++++++++++--------- .../__manifest__.py | 4 +- .../exceptions.py | 21 -------- .../event_registration_partner_unique.pot | 22 ++++++++- .../models/event.py | 21 ++++---- .../readme/DESCRIPTION.rst | 4 +- .../readme/ROADMAP.rst | 22 ++++----- .../readme/USAGE.rst | 12 +++-- .../static/description/index.html | 44 +++++++++-------- .../tests/test_event.py | 13 +++-- .../views/event_event_view.xml | 2 +- 11 files changed, 111 insertions(+), 102 deletions(-) delete mode 100644 event_registration_partner_unique/exceptions.py diff --git a/event_registration_partner_unique/README.rst b/event_registration_partner_unique/README.rst index 7a6459760..fd0dabc0f 100644 --- a/event_registration_partner_unique/README.rst +++ b/event_registration_partner_unique/README.rst @@ -14,19 +14,19 @@ Unique Partner per Event :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github - :target: https://github.com/OCA/event/tree/13.0/event_registration_partner_unique + :target: https://github.com/OCA/event/tree/14.0/event_registration_partner_unique :alt: OCA/event .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/event-13-0/event-13-0-event_registration_partner_unique + :target: https://translation.odoo-community.org/projects/event-14-0/event-14-0-event_registration_partner_unique :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/199/13.0 + :target: https://runbot.odoo-community.org/runbot/199/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| -This module intended used only with backend and extends the functionality of events -to support forbidding to duplicate the same Attendee in an event. +This module is intended for backend use only, and extends the functionality +of events to avoid duplicating attendees. **Table of contents** @@ -36,25 +36,29 @@ to support forbidding to duplicate the same Attendee in an event. Usage ===== -#. Go to **Events > Events > Create**. -#. Enable **Forbid duplicates**. -#. Try to create 2 registrations for the same Attendee in this event. -#. You can't. +#. Go to **Events** and choose an event or create a new one. +#. Enable **Forbid Duplicates**. +#. Go to **Attendees**. +#. Create a new attendee, starting with **Booked by**. +#. Several attendees can have the same *Booked by* person or company, but if + you try to register an attendee by **Attendee Name** or by + **Attendee Partner** more than once for the same event, the system won't + allow it and will show a *Validation Error*. Known issues / Roadmap ====================== -* This modules intended used with backend, so the validation error - are enough to show user what is wrong, when *website_event* is installed - public user would try register attendees. - As soon try more than one attendee this will trigger validation error as - the attendee partner is duplicated the error shown is 500 internal server error - which is no appropriated. -* It would be necessary have a new module with depends on website_event and this - one to prevent this issue. -* Another kind of problem is with *event_sale* module that would try use Sale Order - contact as attendee that will lead to the issue of attendee duplicates if try to - buy two times same event. +* This module is intended for backend use, so the validation error is enough + to show the user what is wrong, +* When *website_event* is installed, and public users try to register more + than one attendee, this will trigger a validation error as the attendee + partner is duplicated. The error shown is 500 internal server error. +* It would be necessary to have a new module which depends on *website_event* + plus this one to prevent said issue. +* Another problem would arise when used with *event_sale* module, because it + would try to use "Sale Order" contact as attendee and that will lead to the + issue of duplicated attendees if trying to buy access to the same event + more than once. Bug Tracker =========== @@ -62,7 +66,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -99,6 +103,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/event `_ project on GitHub. +This module is part of the `OCA/event `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/event_registration_partner_unique/__manifest__.py b/event_registration_partner_unique/__manifest__.py index e0c0c7b61..5f08aea52 100644 --- a/event_registration_partner_unique/__manifest__.py +++ b/event_registration_partner_unique/__manifest__.py @@ -6,10 +6,10 @@ { "name": "Unique Partner per Event", "summary": "Enforces 1 registration per partner and event", - "version": "13.0.1.0.1", + "version": "14.0.1.0.0", "category": "Marketing", "website": "https://github.com/OCA/event", - "author": "Tecnativa, " "Odoo Community Association (OCA)", + "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, diff --git a/event_registration_partner_unique/exceptions.py b/event_registration_partner_unique/exceptions.py deleted file mode 100644 index 48ece2e2c..000000000 --- a/event_registration_partner_unique/exceptions.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import _, exceptions - - -class UniqueRegistrationPartnerValidationError(exceptions.ValidationError): - """Base class for this module's validation errors.""" - - def __init__(self, *args, **kwargs): - self._args, self._kwargs = args, kwargs - value = self._message() - super(UniqueRegistrationPartnerValidationError, self).__init__(value) - - def _message(self): - """Format the message.""" - return self.__doc__.format(*self._args, **self._kwargs) - - -class DuplicatedPartnerError(UniqueRegistrationPartnerValidationError): - __doc__ = _("Duplicated partners found in event {0}: {1}.") diff --git a/event_registration_partner_unique/i18n/event_registration_partner_unique.pot b/event_registration_partner_unique/i18n/event_registration_partner_unique.pot index aa5dd8574..9e1905e96 100644 --- a/event_registration_partner_unique/i18n/event_registration_partner_unique.pot +++ b/event_registration_partner_unique/i18n/event_registration_partner_unique.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -20,7 +20,13 @@ msgid "" msgstr "" #. module: event_registration_partner_unique -#: code:addons/event_registration_partner_unique/exceptions.py:0 +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__display_name +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_registration__display_name +msgid "Display Name" +msgstr "" + +#. module: event_registration_partner_unique +#: code:addons/event_registration_partner_unique/models/event.py:0 #, python-format msgid "Duplicated partners found in event {0}: {1}." msgstr "" @@ -39,3 +45,15 @@ msgstr "" #: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__forbid_duplicates msgid "Forbid Duplicates" msgstr "" + +#. module: event_registration_partner_unique +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__id +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_registration__id +msgid "ID" +msgstr "" + +#. module: event_registration_partner_unique +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event____last_update +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_registration____last_update +msgid "Last Modified on" +msgstr "" diff --git a/event_registration_partner_unique/models/event.py b/event_registration_partner_unique/models/event.py index 3e463975a..6ecaeee16 100644 --- a/event_registration_partner_unique/models/event.py +++ b/event_registration_partner_unique/models/event.py @@ -1,10 +1,10 @@ # Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis # Copyright 2020 Tecnativa - Víctor Martínez +# Copyright 2022 Tecnativa - Luis D. Lafaurie # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, fields, models - -from .. import exceptions +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError class EventEvent(models.Model): @@ -32,13 +32,14 @@ def _check_forbid_duplicates(self): for event_reg in self.filtered("event_id.forbid_duplicates"): dupes = self.search(event_reg._duplicate_search_domain()) if dupes: - raise exceptions.DuplicatedPartnerError( - event_reg.event_id.display_name, - ", ".join( - partner_id.display_name - for partner_id in dupes.mapped("attendee_partner_id") - ), - registrations=dupes, + raise ValidationError( + _("Duplicated partners found in event {0}: {1}.").format( + event_reg.event_id.display_name, + ", ".join( + partner_id.display_name + for partner_id in dupes.mapped("attendee_partner_id") + ), + ) ) def _duplicate_search_domain(self): diff --git a/event_registration_partner_unique/readme/DESCRIPTION.rst b/event_registration_partner_unique/readme/DESCRIPTION.rst index 96e21c4dd..595020454 100644 --- a/event_registration_partner_unique/readme/DESCRIPTION.rst +++ b/event_registration_partner_unique/readme/DESCRIPTION.rst @@ -1,2 +1,2 @@ -This module intended used only with backend and extends the functionality of events -to support forbidding to duplicate the same Attendee in an event. +This module is intended for backend use only, and extends the functionality +of events to avoid duplicating attendees. diff --git a/event_registration_partner_unique/readme/ROADMAP.rst b/event_registration_partner_unique/readme/ROADMAP.rst index dc42bfd49..f1efd7568 100644 --- a/event_registration_partner_unique/readme/ROADMAP.rst +++ b/event_registration_partner_unique/readme/ROADMAP.rst @@ -1,11 +1,11 @@ -* This modules intended used with backend, so the validation error - are enough to show user what is wrong, when *website_event* is installed - public user would try register attendees. - As soon try more than one attendee this will trigger validation error as - the attendee partner is duplicated the error shown is 500 internal server error - which is no appropriated. -* It would be necessary have a new module with depends on website_event and this - one to prevent this issue. -* Another kind of problem is with *event_sale* module that would try use Sale Order - contact as attendee that will lead to the issue of attendee duplicates if try to - buy two times same event. +* This module is intended for backend use, so the validation error is enough + to show the user what is wrong, +* When *website_event* is installed, and public users try to register more + than one attendee, this will trigger a validation error as the attendee + partner is duplicated. The error shown is 500 internal server error. +* It would be necessary to have a new module which depends on *website_event* + plus this one to prevent said issue. +* Another problem would arise when used with *event_sale* module, because it + would try to use "Sale Order" contact as attendee and that will lead to the + issue of duplicated attendees if trying to buy access to the same event + more than once. diff --git a/event_registration_partner_unique/readme/USAGE.rst b/event_registration_partner_unique/readme/USAGE.rst index dbb71ec8a..a221db882 100644 --- a/event_registration_partner_unique/readme/USAGE.rst +++ b/event_registration_partner_unique/readme/USAGE.rst @@ -1,4 +1,8 @@ -#. Go to **Events > Events > Create**. -#. Enable **Forbid duplicates**. -#. Try to create 2 registrations for the same Attendee in this event. -#. You can't. +#. Go to **Events** and choose an event or create a new one. +#. Enable **Forbid Duplicates**. +#. Go to **Attendees**. +#. Create a new attendee, starting with **Booked by**. +#. Several attendees can have the same *Booked by* person or company, but if + you try to register an attendee by **Attendee Name** or by + **Attendee Partner** more than once for the same event, the system won't + allow it and will show a *Validation Error*. diff --git a/event_registration_partner_unique/static/description/index.html b/event_registration_partner_unique/static/description/index.html index 8889e8ed8..6476ba584 100644 --- a/event_registration_partner_unique/static/description/index.html +++ b/event_registration_partner_unique/static/description/index.html @@ -367,9 +367,9 @@

    Unique Partner per Event

    !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

    Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runbot

    -

    This module intended used only with backend and extends the functionality of events -to support forbidding to duplicate the same Attendee in an event.

    +

    Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runbot

    +

    This module is intended for backend use only, and extends the functionality +of events to avoid duplicating attendees.

    Table of contents

      @@ -387,26 +387,30 @@

      Unique Partner per Event

      Usage

        -
      1. Go to Events > Events > Create.
      2. -
      3. Enable Forbid duplicates.
      4. -
      5. Try to create 2 registrations for the same Attendee in this event.
      6. -
      7. You can’t.
      8. +
      9. Go to Events and choose an event or create a new one.
      10. +
      11. Enable Forbid Duplicates.
      12. +
      13. Go to Attendees.
      14. +
      15. Create a new attendee, starting with Booked by.
      16. +
      17. Several attendees can have the same Booked by person or company, but if +you try to register an attendee by Attendee Name or by +Attendee Partner more than once for the same event, the system won’t +allow it and will show a Validation Error.

      Known issues / Roadmap

        -
      • This modules intended used with backend, so the validation error -are enough to show user what is wrong, when website_event is installed -public user would try register attendees. -As soon try more than one attendee this will trigger validation error as -the attendee partner is duplicated the error shown is 500 internal server error -which is no appropriated.
      • -
      • It would be necessary have a new module with depends on website_event and this -one to prevent this issue.
      • -
      • Another kind of problem is with event_sale module that would try use Sale Order -contact as attendee that will lead to the issue of attendee duplicates if try to -buy two times same event.
      • +
      • This module is intended for backend use, so the validation error is enough +to show the user what is wrong,
      • +
      • When website_event is installed, and public users try to register more +than one attendee, this will trigger a validation error as the attendee +partner is duplicated. The error shown is 500 internal server error.
      • +
      • It would be necessary to have a new module which depends on website_event +plus this one to prevent said issue.
      • +
      • Another problem would arise when used with event_sale module, because it +would try to use “Sale Order” contact as attendee and that will lead to the +issue of duplicated attendees if trying to buy access to the same event +more than once.
      @@ -414,7 +418,7 @@

      Bug Tracker

      Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

      +feedback.

      Do not contact contributors directly about support or help with technical issues.

      @@ -449,7 +453,7 @@

      Maintainers

      OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

      -

      This module is part of the OCA/event project on GitHub.

      +

      This module is part of the OCA/event project on GitHub.

      You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/event_registration_partner_unique/tests/test_event.py b/event_registration_partner_unique/tests/test_event.py index 3eb756276..49cc43702 100644 --- a/event_registration_partner_unique/tests/test_event.py +++ b/event_registration_partner_unique/tests/test_event.py @@ -2,10 +2,9 @@ # Copyright 2020 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.exceptions import ValidationError from odoo.tests.common import TransactionCase -from .. import exceptions - class DuplicatedPartnerCase(TransactionCase): def setUp(self): @@ -28,7 +27,7 @@ def test_allowed(self): def test_forbidden(self): """Cannot when it is forbidden.""" self.event.forbid_duplicates = True - with self.assertRaises(exceptions.DuplicatedPartnerError): + with self.assertRaises(ValidationError): self.registration.copy( {"attendee_partner_id": self.registration.attendee_partner_id.id} ) @@ -36,17 +35,17 @@ def test_forbidden(self): def test_saved_in_exception(self): """The failing partners are saved in the exception.""" self.event.forbid_duplicates = True - try: + with self.assertRaisesRegex( + ValidationError, "Duplicated partners found in event" + ): self.registration.copy( {"attendee_partner_id": self.registration.attendee_partner_id.id} ) - except exceptions.DuplicatedPartnerError as error: - self.assertEqual(error._kwargs["registrations"], self.registration) def test_duplicates_already_exist(self): """Cannot forbid what already happened.""" self.registration.copy( {"attendee_partner_id": self.registration.attendee_partner_id.id} ) - with self.assertRaises(exceptions.DuplicatedPartnerError): + with self.assertRaises(ValidationError): self.event.forbid_duplicates = True diff --git a/event_registration_partner_unique/views/event_event_view.xml b/event_registration_partner_unique/views/event_event_view.xml index 9ccebf68e..47bbc2a4c 100644 --- a/event_registration_partner_unique/views/event_event_view.xml +++ b/event_registration_partner_unique/views/event_event_view.xml @@ -10,7 +10,7 @@ - + From cb9238b893787504fbd59eec2559c5f55f74f141 Mon Sep 17 00:00:00 2001 From: "Luis D. Lafaurie" Date: Tue, 9 Aug 2022 16:27:50 +0200 Subject: [PATCH 15/27] [FIX] event_registration_partner_unique: improve README --- event_registration_partner_unique/README.rst | 15 +++-- .../__manifest__.py | 2 +- event_registration_partner_unique/i18n/it.po | 62 +++++++++++++++++++ .../readme/DESCRIPTION.rst | 6 ++ .../readme/USAGE.rst | 9 ++- .../static/description/index.html | 14 +++-- 6 files changed, 92 insertions(+), 16 deletions(-) create mode 100644 event_registration_partner_unique/i18n/it.po diff --git a/event_registration_partner_unique/README.rst b/event_registration_partner_unique/README.rst index fd0dabc0f..540e17ff8 100644 --- a/event_registration_partner_unique/README.rst +++ b/event_registration_partner_unique/README.rst @@ -28,6 +28,12 @@ Unique Partner per Event This module is intended for backend use only, and extends the functionality of events to avoid duplicating attendees. +It is designed to work alongside *partner_event* (which is a dependency), and +it is advisable to enable it by clicking on **Create Partners in +registration**; this way it will create new partners or will match existing +ones, but at the same time will avoid creating duplicates from partners +already existing. + **Table of contents** .. contents:: @@ -39,11 +45,10 @@ Usage #. Go to **Events** and choose an event or create a new one. #. Enable **Forbid Duplicates**. #. Go to **Attendees**. -#. Create a new attendee, starting with **Booked by**. -#. Several attendees can have the same *Booked by* person or company, but if - you try to register an attendee by **Attendee Name** or by - **Attendee Partner** more than once for the same event, the system won't - allow it and will show a *Validation Error*. +#. Create a new attendee. +#. If you try to fill successive attendees with the same contact filled out in + the "Attendee Partner" field, the system won't allow it. That can + happen for example if the same email is used several times. Known issues / Roadmap ====================== diff --git a/event_registration_partner_unique/__manifest__.py b/event_registration_partner_unique/__manifest__.py index 5f08aea52..52393d25b 100644 --- a/event_registration_partner_unique/__manifest__.py +++ b/event_registration_partner_unique/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Unique Partner per Event", "summary": "Enforces 1 registration per partner and event", - "version": "14.0.1.0.0", + "version": "14.0.1.0.1", "category": "Marketing", "website": "https://github.com/OCA/event", "author": "Tecnativa, Odoo Community Association (OCA)", diff --git a/event_registration_partner_unique/i18n/it.po b/event_registration_partner_unique/i18n/it.po new file mode 100644 index 000000000..4390ee8b5 --- /dev/null +++ b/event_registration_partner_unique/i18n/it.po @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * event_registration_partner_unique +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-10-08 23:35+0000\n" +"Last-Translator: Sergio Zanchetta \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: event_registration_partner_unique +#: model:ir.model.fields,help:event_registration_partner_unique.field_event_event__forbid_duplicates +msgid "" +"Check this to disallow duplicate attendees in this event's registrations" +msgstr "" + +#. module: event_registration_partner_unique +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__display_name +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_registration__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: event_registration_partner_unique +#: code:addons/event_registration_partner_unique/models/event.py:0 +#, python-format +msgid "Duplicated partners found in event {0}: {1}." +msgstr "Trovati partner duplicati nell'evento {0}: {1}." + +#. module: event_registration_partner_unique +#: model:ir.model,name:event_registration_partner_unique.model_event_event +msgid "Event" +msgstr "Evento" + +#. module: event_registration_partner_unique +#: model:ir.model,name:event_registration_partner_unique.model_event_registration +msgid "Event Registration" +msgstr "Registrazione evento" + +#. module: event_registration_partner_unique +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__forbid_duplicates +msgid "Forbid Duplicates" +msgstr "" + +#. module: event_registration_partner_unique +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__id +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_registration__id +msgid "ID" +msgstr "ID" + +#. module: event_registration_partner_unique +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event____last_update +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_registration____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" diff --git a/event_registration_partner_unique/readme/DESCRIPTION.rst b/event_registration_partner_unique/readme/DESCRIPTION.rst index 595020454..cc71bc7e0 100644 --- a/event_registration_partner_unique/readme/DESCRIPTION.rst +++ b/event_registration_partner_unique/readme/DESCRIPTION.rst @@ -1,2 +1,8 @@ This module is intended for backend use only, and extends the functionality of events to avoid duplicating attendees. + +It is designed to work alongside *partner_event* (which is a dependency), and +it is advisable to enable it by clicking on **Create Partners in +registration**; this way it will create new partners or will match existing +ones, but at the same time will avoid creating duplicates from partners +already existing. diff --git a/event_registration_partner_unique/readme/USAGE.rst b/event_registration_partner_unique/readme/USAGE.rst index a221db882..88853b3cc 100644 --- a/event_registration_partner_unique/readme/USAGE.rst +++ b/event_registration_partner_unique/readme/USAGE.rst @@ -1,8 +1,7 @@ #. Go to **Events** and choose an event or create a new one. #. Enable **Forbid Duplicates**. #. Go to **Attendees**. -#. Create a new attendee, starting with **Booked by**. -#. Several attendees can have the same *Booked by* person or company, but if - you try to register an attendee by **Attendee Name** or by - **Attendee Partner** more than once for the same event, the system won't - allow it and will show a *Validation Error*. +#. Create a new attendee. +#. If you try to fill successive attendees with the same contact filled out in + the "Attendee Partner" field, the system won't allow it. That can + happen for example if the same email is used several times. diff --git a/event_registration_partner_unique/static/description/index.html b/event_registration_partner_unique/static/description/index.html index 6476ba584..7def3b787 100644 --- a/event_registration_partner_unique/static/description/index.html +++ b/event_registration_partner_unique/static/description/index.html @@ -370,6 +370,11 @@

    Unique Partner per Event

    Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runbot

    This module is intended for backend use only, and extends the functionality of events to avoid duplicating attendees.

    +

    It is designed to work alongside partner_event (which is a dependency), and +it is advisable to enable it by clicking on Create Partners in +registration; this way it will create new partners or will match existing +ones, but at the same time will avoid creating duplicates from partners +already existing.

    Table of contents

      @@ -390,11 +395,10 @@

      Usage

    • Go to Events and choose an event or create a new one.
    • Enable Forbid Duplicates.
    • Go to Attendees.
    • -
    • Create a new attendee, starting with Booked by.
    • -
    • Several attendees can have the same Booked by person or company, but if -you try to register an attendee by Attendee Name or by -Attendee Partner more than once for the same event, the system won’t -allow it and will show a Validation Error.
    • +
    • Create a new attendee.
    • +
    • If you try to fill successive attendees with the same contact filled out in +the “Attendee Partner” field, the system won’t allow it. That can +happen for example if the same email is used several times.
    From 2ad375effbef607c9127c677f8afff88d68dde57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Ernesto=20Garc=C3=ADa=20Medina?= Date: Tue, 7 Mar 2023 13:48:51 -0600 Subject: [PATCH 16/27] [MIG] event_registration_partner_unique: Migration to 15.0 --- event_registration_partner_unique/README.rst | 23 ++++++---- .../__manifest__.py | 2 +- event_registration_partner_unique/i18n/es.po | 4 +- .../event_registration_partner_unique.pot | 22 ++------- event_registration_partner_unique/i18n/it.po | 10 ++-- .../static/description/index.html | 46 ++++++++++--------- 6 files changed, 50 insertions(+), 57 deletions(-) diff --git a/event_registration_partner_unique/README.rst b/event_registration_partner_unique/README.rst index 540e17ff8..8a9272d05 100644 --- a/event_registration_partner_unique/README.rst +++ b/event_registration_partner_unique/README.rst @@ -2,10 +2,13 @@ Unique Partner per Event ======================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:fa39a5416b9a53ff743d770b11ab214277fe38d04077dfa770174e259f481c29 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -14,16 +17,16 @@ Unique Partner per Event :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github - :target: https://github.com/OCA/event/tree/14.0/event_registration_partner_unique + :target: https://github.com/OCA/event/tree/15.0/event_registration_partner_unique :alt: OCA/event .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/event-14-0/event-14-0-event_registration_partner_unique + :target: https://translation.odoo-community.org/projects/event-15-0/event-15-0-event_registration_partner_unique :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/199/14.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/event&target_branch=15.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module is intended for backend use only, and extends the functionality of events to avoid duplicating attendees. @@ -70,8 +73,8 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -108,6 +111,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/event `_ project on GitHub. +This module is part of the `OCA/event `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/event_registration_partner_unique/__manifest__.py b/event_registration_partner_unique/__manifest__.py index 52393d25b..d589c8108 100644 --- a/event_registration_partner_unique/__manifest__.py +++ b/event_registration_partner_unique/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Unique Partner per Event", "summary": "Enforces 1 registration per partner and event", - "version": "14.0.1.0.1", + "version": "15.0.1.0.0", "category": "Marketing", "website": "https://github.com/OCA/event", "author": "Tecnativa, Odoo Community Association (OCA)", diff --git a/event_registration_partner_unique/i18n/es.po b/event_registration_partner_unique/i18n/es.po index 44ac33ded..6129ccf52 100644 --- a/event_registration_partner_unique/i18n/es.po +++ b/event_registration_partner_unique/i18n/es.po @@ -19,6 +19,7 @@ msgstr "" #. module: event_registration_partner_unique #: model:ir.model.fields,help:event_registration_partner_unique.field_event_event__forbid_duplicates +#: model:ir.model.fields,help:event_registration_partner_unique.field_event_session__forbid_duplicates msgid "" "Check this to disallow duplicate attendees in this event's registrations" msgstr "" @@ -26,7 +27,7 @@ msgstr "" "este evento" #. module: event_registration_partner_unique -#: code:addons/event_registration_partner_unique/exceptions.py:0 +#: code:addons/event_registration_partner_unique/models/event.py:0 #, python-format msgid "Duplicated partners found in event {0}: {1}." msgstr "Empresas duplicadas encontradas en el evento {0}: {1}." @@ -43,5 +44,6 @@ msgstr "Registro del evento" #. module: event_registration_partner_unique #: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__forbid_duplicates +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_session__forbid_duplicates msgid "Forbid Duplicates" msgstr "Prohibir duplicados" diff --git a/event_registration_partner_unique/i18n/event_registration_partner_unique.pot b/event_registration_partner_unique/i18n/event_registration_partner_unique.pot index 9e1905e96..566ff1077 100644 --- a/event_registration_partner_unique/i18n/event_registration_partner_unique.pot +++ b/event_registration_partner_unique/i18n/event_registration_partner_unique.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -15,16 +15,11 @@ msgstr "" #. module: event_registration_partner_unique #: model:ir.model.fields,help:event_registration_partner_unique.field_event_event__forbid_duplicates +#: model:ir.model.fields,help:event_registration_partner_unique.field_event_session__forbid_duplicates msgid "" "Check this to disallow duplicate attendees in this event's registrations" msgstr "" -#. module: event_registration_partner_unique -#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__display_name -#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_registration__display_name -msgid "Display Name" -msgstr "" - #. module: event_registration_partner_unique #: code:addons/event_registration_partner_unique/models/event.py:0 #, python-format @@ -43,17 +38,6 @@ msgstr "" #. module: event_registration_partner_unique #: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__forbid_duplicates +#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_session__forbid_duplicates msgid "Forbid Duplicates" msgstr "" - -#. module: event_registration_partner_unique -#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__id -#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_registration__id -msgid "ID" -msgstr "" - -#. module: event_registration_partner_unique -#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event____last_update -#: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_registration____last_update -msgid "Last Modified on" -msgstr "" diff --git a/event_registration_partner_unique/i18n/it.po b/event_registration_partner_unique/i18n/it.po index 4390ee8b5..4a351d667 100644 --- a/event_registration_partner_unique/i18n/it.po +++ b/event_registration_partner_unique/i18n/it.po @@ -6,21 +6,23 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2022-10-08 23:35+0000\n" -"Last-Translator: Sergio Zanchetta \n" +"PO-Revision-Date: 2023-07-18 14:11+0000\n" +"Last-Translator: mymage \n" "Language-Team: none\n" "Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.3.2\n" +"X-Generator: Weblate 4.17\n" #. module: event_registration_partner_unique #: model:ir.model.fields,help:event_registration_partner_unique.field_event_event__forbid_duplicates msgid "" "Check this to disallow duplicate attendees in this event's registrations" msgstr "" +"Selezionare per impedire la duplicazione dei partecipanti nella " +"registrazioni di questo evento" #. module: event_registration_partner_unique #: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__display_name @@ -47,7 +49,7 @@ msgstr "Registrazione evento" #. module: event_registration_partner_unique #: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__forbid_duplicates msgid "Forbid Duplicates" -msgstr "" +msgstr "Impedisci duplicati" #. module: event_registration_partner_unique #: model:ir.model.fields,field_description:event_registration_partner_unique.field_event_event__id diff --git a/event_registration_partner_unique/static/description/index.html b/event_registration_partner_unique/static/description/index.html index 7def3b787..e4cd2f28a 100644 --- a/event_registration_partner_unique/static/description/index.html +++ b/event_registration_partner_unique/static/description/index.html @@ -1,20 +1,20 @@ - + - + Unique Partner per Event