Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

How can I save/load my own configuration/settings

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
configurationsettingsres_config
6 Respuestas
40294 Vistas
Avatar
Stefan Reisich

Hello,

how can I save and load my own configuration/settings. And create my own section in Settings -> Configuration? How can I load this saved settings?

I want save a URL, a user name and a password needed for my module...

image description

Thank you very much.

6
Avatar
Descartar
Avatar
Simplify it!
Mejor respuesta

To add a configuration page you have to do this:

from openerp.osv import fields, osv 

class custom_config_settings(osv.osv_memory):

    _name = 'custom.config.settings'
    _inherit = 'res.config.settings'
    _columns = {
        'username': fields.char('Username', size=48),
    }
    _defaults = {
        'username': ""
    }

    def get_default_username(self, cr, uid, fields, context=None):
        #some code... 
        #you can get the field content from some table and return it
        #as a example
        user_name=self.pool.get('res.users').browse(cr, uid, uid, context=context).name
        return {'username': user_name}

    def set_default_username(self, cr, uid, ids, context=None):
        #some code... 
        #you can get the field content from some table and return it
        #as a example
        config = self.browse(cr, uid, ids[0], context)
        new_username=config.username
        self.pool.get('res.users').write(cr, uid, uid, {'name': new_username})

And the view:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
    <record id="view_custom_config_settings" model="ir.ui.view">
        <field name="name">custom settings</field>
        <field name="model">custom.config.settings</field>
        <field name="arch" type="xml">
            <form string="Configure Accounting" version="7.0" class="oe_form_configuration">
                <header>
                    <button string="Apply" type="object" name="execute" class="oe_highlight"/>
                    or
                    <button string="Cancel" type="object" name="cancel" class="oe_link"/>
                </header>
                <field name="username"/>
            </form>
        </field>
    </record>

    <record id="action_custom_config" model="ir.actions.act_window">
        <field name="name">Custom Settings</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">custom.config.settings</field>
        <field name="view_mode">form</field>
        <field name="target">inline</field>
    </record>

    <menuitem id="menu_custom_config" name="Custom Settings" parent="base.menu_config"
        sequence="16" action="action_custom_config"/>

    </data>
</openerp>

This is only an example.

The config page works because when you open the configuration page all the "get_" functions will be called. And when you save it all the "set_" functions are going to run.

I hope this can help you.

EDIT

Taken from OpenERP docs:

Base configuration wizard for application settings. It provides support for setting default values, assigning groups to employee users, and installing modules. To make such a 'settings' wizard, define a model like::

        class my_config_wizard(osv.osv_memory):
            _name = 'my.settings'
            _inherit = 'res.config.settings'
            _columns = {
                'default_foo': fields.type(..., default_model='my.model'),
                'group_bar': fields.boolean(..., group='base.group_user', implied_group='my.group'),
                'module_baz': fields.boolean(...),
                'other_field': fields.type(...),
            }

The method execute provides some support based on a naming convention:

*   For a field like 'default_XXX', ``execute`` sets the (global) default value of
    the field 'XXX' in the model named by ``default_model`` to the field's value.

*   For a boolean field like 'group_XXX', ``execute`` adds/removes 'implied_group'
    to/from the implied groups of 'group', depending on the field's value.
    By default 'group' is the group Employee.  Groups are given by their xml id.

*   For a boolean field like 'module_XXX', ``execute`` triggers the immediate
    installation of the module named 'XXX' if the field has value ``True``.

*   For the other fields, the method ``execute`` invokes all methods with a name
    that starts with 'set_'; such methods can be defined to implement the effect
    of those fields.

The method ``default_get`` retrieves values that reflect the current status of the
fields like 'default_XXX', 'group_XXX' and 'module_XXX'.  It also invokes all methods
with a name that starts with 'get_default_'; such methods can be defined to provide
current values for other fields.
13
Avatar
Descartar
Atchuthan - Technical Consultant, Sodexis Inc

@Grover, in many configuration settings available in OpenERP, most of the field does not have get or set function with it

For instance take sales configuration, `module_sale_analytic_plans,

Simplify it!

Of course, but it depends on what you are trying to do: If field name starts with module_ that means that it's going to install that module. It's not an ordinary boolean. I've edited the answer. Hope it helps

Atchuthan - Technical Consultant, Sodexis Inc

@thanks Grover, your description was helpful

Avatar
Iwan Dermawan
Mejor respuesta

Please help,

why in my configurations, new record added after Apply button clicked not updated last config data (reload record succesfull display in form)

1
Avatar
Descartar
Avatar
Thierry Godin
Mejor respuesta

Hello,

Your configuration will be saved while you're making backup of your database.

Regards

-2
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
res_config.py error Resuelto
configuration settings xml res_config
Avatar
Avatar
1
may 15
6171
disable delete and edit options in conversations Odoo 15
configuration settings
Avatar
Avatar
Avatar
2
abr 24
5285
In res_config.py why odoo cannot find a field that is already defined? Resuelto
settings res_config
Avatar
Avatar
1
may 15
6343
What are the things to watch out for before my OpenERP goes live? Version 7.
configuration settings
Avatar
0
mar 15
8145
Reserve Profit and Loss Account
configuration settings
Avatar
Avatar
1
mar 15
7455
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now