[FW][MERGE][FIX] (website_)event(_question/_track): provide fixes related to 13.2 event upgrades
Purpose ======= Fix kanban state default value and display in community. Fix question answers not correctly parsed from frontend. Fix sale availability ACLs issue when having tickets. Do not group the event tracks by location. See sub commits for more details. Task 2188857 PR #44545 closes odoo/odoo#45655 Forward-port-of: odoo/odoo#44545 Related: odoo/enterprise#8533 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -116,7 +116,7 @@ class EventEvent(models.Model):
|
||||
color = fields.Integer('Kanban Color Index')
|
||||
event_mail_ids = fields.One2many('event.mail', 'event_id', string='Mail Schedule', copy=True)
|
||||
# Kanban fields
|
||||
kanban_state = fields.Selection([('normal', 'In Progress'), ('done', 'Done'), ('blocked', 'Blocked')])
|
||||
kanban_state = fields.Selection([('normal', 'In Progress'), ('done', 'Done'), ('blocked', 'Blocked')], default='normal')
|
||||
kanban_state_label = fields.Char(compute='_compute_kanban_state_label', string='Kanban State Label', tracking=True, store=True)
|
||||
stage_id = fields.Many2one(
|
||||
'event.stage', ondelete='restrict', default=_get_default_stage_id,
|
||||
|
||||
@@ -65,7 +65,7 @@ class EventTicket(models.Model):
|
||||
start_sale_date = fields.Date(string="Registration Start")
|
||||
end_sale_date = fields.Date(string="Registration End")
|
||||
is_expired = fields.Boolean(string='Is Expired', compute='_compute_is_expired')
|
||||
sale_available = fields.Boolean(string='Is Available', compute='_compute_sale_available')
|
||||
sale_available = fields.Boolean(string='Is Available', compute='_compute_sale_available', compute_sudo=True)
|
||||
registration_ids = fields.One2many('event.registration', 'event_ticket_id', string='Registrations')
|
||||
# seats
|
||||
seats_reserved = fields.Integer(string='Reserved Seats', compute='_compute_seats', store=True)
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
<field name="legend_normal" invisible="1"/>
|
||||
<field name="legend_done" invisible="1"/>
|
||||
<widget name="web_ribbon" text="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
|
||||
<field name="kanban_state" widget="state_selection" class="ml-auto"/>
|
||||
<field name="kanban_state" widget="state_selection" class="ml-auto float-right"/>
|
||||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only" string="Event Name"/>
|
||||
<h1><field name="name" placeholder="e.g. Conference for Architects"/></h1>
|
||||
|
||||
@@ -296,7 +296,6 @@ class WebsiteEventController(http.Controller):
|
||||
{'1-name': 'r', '1-email': 'r@r.com', '1-phone': '', '1-event_ticket_id': '1'}
|
||||
"""
|
||||
registration_fields = request.env['event.registration']._fields
|
||||
|
||||
registrations = {}
|
||||
global_values = {}
|
||||
for key, value in form_details.items():
|
||||
|
||||
@@ -9,10 +9,20 @@ class WebsiteEvent(WebsiteEventController):
|
||||
def _process_attendees_form(self, event, form_details):
|
||||
''' Process data posted from the attendee details form. '''
|
||||
registrations = super(WebsiteEvent, self)._process_attendees_form(event, form_details)
|
||||
|
||||
for registration in registrations:
|
||||
answer_ids = []
|
||||
for key, value in registration.items():
|
||||
if key.startswith('answer_ids-'):
|
||||
answer_ids.append([4, int(value)])
|
||||
registration['answer_ids'] = answer_ids
|
||||
registration['answer_ids'] = []
|
||||
|
||||
general_answer_ids = []
|
||||
for key, value in form_details.items():
|
||||
if 'answer_ids' in key:
|
||||
index = int(key.split('-')[0])
|
||||
if not index:
|
||||
general_answer_ids.append([4, int(value)])
|
||||
else:
|
||||
registrations[index-1]['answer_ids'].append([4, int(value)])
|
||||
|
||||
for registration in registrations:
|
||||
registration['answer_ids'].extend(general_answer_ids)
|
||||
|
||||
return registrations
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from odoo.addons.website_event_questions.tests.common import TestEventQuestionCommon
|
||||
from odoo.fields import Datetime as FieldsDatetime
|
||||
from odoo.tests.common import users
|
||||
from odoo.addons.website.tools import MockRequest
|
||||
from odoo.addons.website_event_questions.controllers.main import WebsiteEvent
|
||||
from odoo.addons.website_event_questions.tests.common import TestEventQuestionCommon
|
||||
|
||||
|
||||
class TestEventData(TestEventQuestionCommon):
|
||||
@@ -29,3 +31,34 @@ class TestEventData(TestEventQuestionCommon):
|
||||
self.assertEqual(
|
||||
set(event.general_question_ids.mapped('answer_ids.name')),
|
||||
set(['Q2-Answer1', 'Q2-Answer2']))
|
||||
|
||||
def test_process_attendees_form(self):
|
||||
event = self.env['event.event'].create({
|
||||
'name': 'Event Update Type',
|
||||
'event_type_id': self.event_type_complex.with_user(self.env.user).id,
|
||||
'date_begin': FieldsDatetime.to_string(datetime.today() + timedelta(days=1)),
|
||||
'date_end': FieldsDatetime.to_string(datetime.today() + timedelta(days=15)),
|
||||
})
|
||||
|
||||
form_details = {
|
||||
'1-name': 'Pixis',
|
||||
'1-email': 'pixis@gmail.com',
|
||||
'1-phone': '+32444444444',
|
||||
'1-event_ticket_id': '2',
|
||||
'1-answer_ids-8': '5',
|
||||
'2-name': 'Geluchat',
|
||||
'2-email': 'geluchat@gmail.com',
|
||||
'2-phone': '+32777777777',
|
||||
'2-event_ticket_id': '3',
|
||||
'2-answer_ids-8': '9',
|
||||
'0-answer_ids-3': '7',
|
||||
'0-answer_ids-4': '1',
|
||||
}
|
||||
|
||||
with MockRequest(self.env):
|
||||
registrations = WebsiteEvent()._process_attendees_form(event, form_details)
|
||||
|
||||
self.assertEqual(registrations, [
|
||||
{'name': 'Pixis', 'email': 'pixis@gmail.com', 'phone': '+32444444444', 'event_ticket_id': 2, 'answer_ids': [[4, 5], [4, 7], [4, 1]]},
|
||||
{'name': 'Geluchat', 'email': 'geluchat@gmail.com', 'phone': '+32777777777', 'event_ticket_id': 3, 'answer_ids': [[4, 9], [4, 7], [4, 1]]}
|
||||
])
|
||||
|
||||
@@ -55,6 +55,7 @@ class WebsiteEventSaleController(WebsiteEventController):
|
||||
# free tickets -> order with amount = 0: auto-confirm, no checkout
|
||||
elif order:
|
||||
order.action_confirm() # tde notsure: email sending ?
|
||||
request.website.sale_reset()
|
||||
|
||||
return res
|
||||
|
||||
|
||||
@@ -197,7 +197,6 @@
|
||||
<field name="name">Event Tracks</field>
|
||||
<field name="res_model">event.track</field>
|
||||
<field name="view_mode">kanban,tree,form,calendar,graph,activity</field>
|
||||
<field name="context">{'search_default_location': 1}</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
Add a new track
|
||||
@@ -211,7 +210,7 @@
|
||||
<field name="res_model">event.track</field>
|
||||
<field name="name">Event Tracks</field>
|
||||
<field name="view_mode">kanban,tree,form,calendar,graph,activity</field>
|
||||
<field name="context">{'search_default_event_id': active_id, 'default_event_id': active_id, 'search_default_location': 1}</field>
|
||||
<field name="context">{'search_default_event_id': active_id, 'default_event_id': active_id}</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
Add a new track
|
||||
|
||||
Reference in New Issue
Block a user