[IMP] survey_event_generation: add event selection in surveys depending on event stage boolean

This commit is contained in:
clementthomas
2023-10-03 12:13:03 +02:00
parent 96d2055903
commit cb474958d5
8 changed files with 102 additions and 13 deletions

View File

@@ -1,4 +1,7 @@
from . import survey_question
from . import survey_user_input
from . import survey_user_input_line
from . import survey_survey
from . import survey_survey
from . import event_stage
from . import event_event
from . import product_product

View File

@@ -0,0 +1,12 @@
from odoo import models, fields, api
class EventEvent(models.Model):
_inherit = 'event.event'
def get_events_visible_in_survey(self, product_id=False):
if product_id:
event_tickets = self.env['event.event.ticket'].search([('product_id','=',product_id)])
return self.env['event.event'].search([('stage_id.visible_in_survey','=',True),('event_ticket_ids','in',event_tickets.id)])
return self.env['event.event'].search([('stage_id.visible_in_survey','=',True)])

View File

@@ -0,0 +1,7 @@
from odoo import models, fields, api
class EventStage(models.Model):
_inherit = 'event.stage'
visible_in_survey = fields.Boolean('Visible in surveys')

View File

@@ -0,0 +1,13 @@
from odoo import models, fields, api
class ProductProduct(models.Model):
_inherit = 'product.product'
def get_event_products_visible_in_survey(self):
events = self.env['event.event'].get_events_visible_in_survey()
products = set()
for event in events:
for ticket in event.event_ticket_ids:
products.add(ticket.product_id)
return list(products)