[IMP] event_track_calendar_event_event_speaker:

change position of event_speaker in data model
This commit is contained in:
clementthomas
2024-07-26 10:44:59 +02:00
parent a72126d0a8
commit bc014155fa
5 changed files with 46 additions and 3 deletions

View File

@@ -9,9 +9,10 @@
"author": "Elabore",
"website": "https://www.elabore.coop",
"category": "",
'summary': 'Event track calendar event adaptation when event_speaker module installed',
"depends": ["event_track_calendar_event","event_speaker"],
"data": [
'summary': 'Speaker management in calendar events of event tracks',
"depends": ["event_track_calendar_event"],
"data": [
"views/event_track_views.xml"
],
"installable": True,
"auto_install":True

View File

@@ -1 +1,2 @@
from . import event_track
from . import calendar_event

View File

@@ -0,0 +1,10 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models, api, Command
class CalendarEvent(models.Model):
_inherit = 'calendar.event'
speaker_ids = fields.Many2many(
'res.partner', "calendar_event_speaker_rel", "calendar_event_id", "speaker_id", string="Speakers", domain="[('is_company','=',False)]"
)

View File

@@ -5,6 +5,19 @@ from odoo import fields, models, api, Command
class EventTrack(models.Model):
_inherit = "event.track"
speaker_ids = fields.Many2many(
'res.partner', string="Speakers", compute="compute_speaker_ids"
)
def compute_speaker_ids(self):
"""set speaker_ids as concat of all speakers of all events"""
for track in self:
speaker_ids = set()
for event in track.calendar_event_ids:
speaker_ids.update(event.speaker_ids.ids)
track.speaker_ids = list(speaker_ids)
def get_calendar_event_partner_value(self):
"""Add speaker ids to calendar event partners
"""

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="ir.ui.view" id="view_event_track_form_event_track_calendar_event_event_speaker">
<field name="name">event.track.form.event.track.calendar.event.event.speaker</field>
<field name="inherit_id" ref="event_track_calendar_event.view_event_track_form_event_track_calendar_event" />
<field name="model">event.track</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='calendar_event_ids']/tree/field[@name='description']" position="after">
<field name="speaker_ids" />
</xpath>
<xpath expr="//field[@name='calendar_event_ids']/form//field[@name='description']" position="after">
<field name="speaker_ids" />
</xpath>
</field>
</record>
</odoo>