From ffd36dd39a712a31bc2e2c61db9961e5e0eefecb Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Wed, 20 Nov 2024 10:56:22 +0500 Subject: [PATCH] =?UTF-8?q?[ADD]=20website=5Fevent=5Fattendee=5Ffields=5Fc?= =?UTF-8?q?ustom:=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9?= =?UTF-8?q?=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B4=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../README.rst | 24 ++++++++ .../__init__.py | 1 + .../__manifest__.py | 18 ++++++ website_event_attendee_fields_custom/data.xml | 28 +++++++++ .../migrations/17.0.1.0.0/post-migrate.py | 59 +++++++++++++++++++ .../models.py | 18 ++++++ .../pyproject.toml | 3 + 7 files changed, 151 insertions(+) create mode 100644 website_event_attendee_fields_custom/README.rst create mode 100644 website_event_attendee_fields_custom/__init__.py create mode 100644 website_event_attendee_fields_custom/__manifest__.py create mode 100644 website_event_attendee_fields_custom/data.xml create mode 100644 website_event_attendee_fields_custom/migrations/17.0.1.0.0/post-migrate.py create mode 100644 website_event_attendee_fields_custom/models.py create mode 100644 website_event_attendee_fields_custom/pyproject.toml diff --git a/website_event_attendee_fields_custom/README.rst b/website_event_attendee_fields_custom/README.rst new file mode 100644 index 0000000..1178a19 --- /dev/null +++ b/website_event_attendee_fields_custom/README.rst @@ -0,0 +1,24 @@ +=============================== + Event guest info (deprecated) +=============================== + +This module is required only for migrating to Odoo 17.0 +After moving all fields declaration to other modules, this module can be safely removed. + +Credits +======= + +Contributors +------------ + +* `Eugene Molotov `__ + +Sponsors +-------- + +* `Tribal Gathering `__ + +Maintainers +----------- + +* `IT-Projects LLC `__ diff --git a/website_event_attendee_fields_custom/__init__.py b/website_event_attendee_fields_custom/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/website_event_attendee_fields_custom/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/website_event_attendee_fields_custom/__manifest__.py b/website_event_attendee_fields_custom/__manifest__.py new file mode 100644 index 0000000..ff44ba7 --- /dev/null +++ b/website_event_attendee_fields_custom/__manifest__.py @@ -0,0 +1,18 @@ +{ + "name": """Event guest info (deprecated)""", + "version": "17.0.1.0.0", + "author": "IT-Projects LLC, Eugene Molotov", + "support": "it@it-projects.info", + "website": "https://github.com/it-projects-llc/website-addons", + "license": "AGPL-3", + "depends": [ + "website_event_attendee_fields", + "partner_contact_birthdate", + "partner_firstname", + "partner_identification", + "partner_contact_nationality", + ], + "data": [ + "data.xml", + ], +} diff --git a/website_event_attendee_fields_custom/data.xml b/website_event_attendee_fields_custom/data.xml new file mode 100644 index 0000000..5911f87 --- /dev/null +++ b/website_event_attendee_fields_custom/data.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/website_event_attendee_fields_custom/migrations/17.0.1.0.0/post-migrate.py b/website_event_attendee_fields_custom/migrations/17.0.1.0.0/post-migrate.py new file mode 100644 index 0000000..3042efe --- /dev/null +++ b/website_event_attendee_fields_custom/migrations/17.0.1.0.0/post-migrate.py @@ -0,0 +1,59 @@ +def migrate(cr, installed_version): + from odoo import SUPERUSER_ID, api + + env = api.Environment(cr, SUPERUSER_ID, {}) + q_ref = {} + + cr.execute( + """ +select eaf.id, f.id, f.name, f.field_description, f.domain +from event_event_attendee_field eaf +left join ir_model_fields f on eaf.field_id = f.id + """ + ) + for row in cr.fetchall(): + af_id = row[0] + field_id = row[1] + field_name = row[2] + q_title = row[3] + + cr.execute( + "UPDATE ir_model_fields SET attendee_field = TRUE WHERE id = %s", [field_id] + ) + if field_name in ("company_name", "phone", "email", "name"): + q_ref[af_id] = { + "question_type": field_name, + "title": q_title, + } + else: + if field_name in ("firstname", "lastname"): + q_title += " as on ID" + + q_ref[af_id] = { + "question_type": "partner_field", + "partner_field": field_id, + "partner_field_domain": row[4] or "[]", + "title": q_title, + } + + cr.execute( + """ +select event_event_id, array_agg(event_event_attendee_field_id) +from event_event_event_event_attendee_field_rel +group by event_event_id; + """ + ) + for row in cr.fetchall(): + event_id = row[0] + + cr.execute("DELETE FROM event_question WHERE id = %s", [event_id]) + + for af_id in sorted(row[1]): + vals = { + "event_id": event_id, + "sequence": 10 * af_id, + } + q_vals = q_ref.get(af_id) or {} + + vals.update(q_vals) + env["event.question"].create(vals) diff --git a/website_event_attendee_fields_custom/models.py b/website_event_attendee_fields_custom/models.py new file mode 100644 index 0000000..4c7c522 --- /dev/null +++ b/website_event_attendee_fields_custom/models.py @@ -0,0 +1,18 @@ +from odoo import fields, models + + +class Partner(models.Model): + _inherit = "res.partner" + + passport = fields.Char( + string="Passport Number", + compute=lambda s: s._compute_identification( + "passport", + "passport", + ), + inverse=lambda s: s._inverse_identification( + "passport", + "passport", + ), + search=lambda s, *a: s._search_identification("passport", *a), + ) diff --git a/website_event_attendee_fields_custom/pyproject.toml b/website_event_attendee_fields_custom/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/website_event_attendee_fields_custom/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi"