mapan_loyalty_push/models/app_cms_config.py

28 lines
887 B
Python

# -*- coding: utf-8 -*-
from odoo import models, fields, api
class AppCmsConfig(models.Model):
"""Singleton model for Mobile App global configuration."""
_name = 'mapan.app.config'
_description = 'Mobile App Configuration'
name = fields.Char(default='App Configuration', readonly=True)
about_us_url = fields.Char(
string='About Us URL',
help='URL to open when user taps "About Us" in the app account menu.'
)
contact_us_url = fields.Char(
string='Contact Us URL',
help='URL to open when user taps "Contact Us" in the app account menu.'
)
@api.model
def get_config(self):
"""Always return the single config record, creating it if it does not exist."""
config = self.search([], limit=1)
if not config:
config = self.create({'name': 'App Configuration'})
return config