In the odoo event.booth.configurator, which pops up when selecting event booth product in a sale order, you have to select the event and the booth type. However, in my company, I always only have one event at a time, all others are either not created yet or archived. So, when i open the event configurator, I want to check whether there is only one Event within this company that is active (aka not archived) and then automatically select it.
# -*- coding: utf-8 -*-
from odoo import models, fields, api
# from . import prepare_engine as rectanglemaps_engine
class EventBoothConfigurator(models.TransientModel):
_inherit = 'event.booth.configurator'
# plan = fields.Binary(string='Plan', attachment=True)
@api.model
def create(self, values):
# If the company only has one event active, we set it by default
if not values.get('event_id'):
values['event_id'] = self.env['event.event'].search([('active', '=', True)], limit=1).id
return super(EventBoothConfigurator, self).create(values)
I do not get an error message, however, nothing happens
How can I make this possible?
Is the create method the right idea?