-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] website_event_attendee_fields_custom: временный модуль для мигр…
…ации данных
- Loading branch information
Showing
7 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://github.com/em230418>`__ | ||
|
||
Sponsors | ||
-------- | ||
|
||
* `Tribal Gathering <https://www.tribalgathering.com/>`__ | ||
|
||
Maintainers | ||
----------- | ||
|
||
* `IT-Projects LLC <https://it-projects.info>`__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": """Event guest info (deprecated)""", | ||
"version": "17.0.1.0.0", | ||
"author": "IT-Projects LLC, Eugene Molotov", | ||
"support": "[email protected]", | ||
"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", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="partner_firstname.field_res_partner__firstname" model="ir.model.fields"> | ||
<field name="attendee_field" eval="True" /> | ||
</record> | ||
|
||
<record id="partner_firstname.field_res_partner__lastname" model="ir.model.fields"> | ||
<field name="attendee_field" eval="True" /> | ||
</record> | ||
|
||
<record | ||
id="partner_contact_nationality.field_res_partner__nationality_id" | ||
model="ir.model.fields" | ||
> | ||
<field name="attendee_field" eval="True" /> | ||
</record> | ||
|
||
<record id="field_res_partner__passport" model="ir.model.fields"> | ||
<field name="attendee_field" eval="True" /> | ||
</record> | ||
|
||
<record | ||
id="partner_contact_birthdate.field_res_partner__birthdate_date" | ||
model="ir.model.fields" | ||
> | ||
<field name="attendee_field" eval="True" /> | ||
</record> | ||
</odoo> |
59 changes: 59 additions & 0 deletions
59
website_event_attendee_fields_custom/migrations/17.0.1.0.0/post-migrate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |