# -*- 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.' ) brand_logo = fields.Image( string='Brand Logo', help='Logo to be displayed in the app header/dashboard.' ) primary_color = fields.Char( string='Primary Color (Hex)', default='#C62828', help='Hex color code for primary theme color, e.g. #C62828' ) secondary_color = fields.Char( string='Secondary Color (Hex)', default='#FF8F00', help='Hex color code for secondary theme color, e.g. #FF8F00' ) @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', 'primary_color': '#C62828', 'secondary_color': '#FF8F00' }) @api.model def action_open_config(self): """Action to open the singleton configuration record.""" config = self.get_config() return { 'name': 'App Settings', 'type': 'ir.actions.act_window', 'res_model': 'mapan.app.config', 'view_mode': 'form', 'res_id': config.id, 'target': 'current', }