What is necessary to make this peace of code working? I always get the error "Function TypeError: EventBooth.check_app_installed() missing 1 required positional argument: 'self'". Meanwhile I tried a lot of different approaches, but nothing worked.
from odoo import models, fields, api
class EventBooth(models.Model):
_name = 'event.booth'
@api.model
def check_app_installed(self):
# Check if the 'event' app is installed
event_app_installed = self.env['ir.module.module'].search([('name', '=', 'event'), ('state', '=', 'installed')])
return event_app_installed
@api.model
def create(self, vals):
app_installed = self.check_app_installed()
if not app_installed:
# Install the 'event' app if it is not installed
event_app = self.env['ir.module.module'].search([('name', '=', 'event')])
event_app.button_immediate_install()
# Continue with the creation of the record
return super(EventBooth, self).create(vals)
if check_app_installed():
_inherit = 'event.booth'
price = fields.Float(string='Price')