Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

How to store Boolean value in res.config.settings?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
configurationsettingsv14
2 Réponses
10526 Vues
Avatar
Nikita

Hello,

I created several fields for res.config.settings and added them to the view. For Float fields, I was able to configure the ability to enter and save new values, and also figured out how to set default values.

However, I do not know how to make sure that the Boolean field is saved when changing and clicking Save.

class ResConfigSettings(models.TransientModel):
    _inherit = 'res.config.settings'

    field_name = fields.Float(string='Im float field')

    boolean_field = fields.Boolean(string='I want the checkmark set here to be saved')

For enter and save new values in Float fields I use:

def set_values(self):
        res = super(ResConfigSettings, self).set_values()
        self.env['ir.config_parameter'].set_param('module_name.field_name', self.field_name)

        return res
    @api.model
    def get_values(self):
        res = super(ResConfigSettings, self).get_values()
        ICPSudo = self.env['ir.config_parameter'].sudo()
        res.update(
            field_name= ICPSudo.get_param('module_name.field_name'),
        )

        return res

Do you know how you can save the state of a Boolean field?

0
Avatar
Ignorer
Nikita
Auteur

I tried to make a new class with a Boolean field and add it from there, but this field became not clickable

class Settings_holder(models.Model):

_name = 'module_name.settings_holder'

field_name= fields.Boolean('Hello Odoo!')

class ResConfigSettings(models.TransientModel):

_inherit = 'res.config.settings'

test_field = fields.Many2one('module_name.settings_holder', string='hmmmm')

covid_tax = fields.Boolean(related='test_field.field_name')

Nikita
Auteur

I forgot the comma when listing in res.update() inside get_values​​(). Don't forget the commas :D

Jaiswal Shivam

From Odoo 17.0 You can do like this

sale_invoice_id = fields.Many2one('sale.order', string='Sale Invoice', config_parameter='current_module_name.sale_invoice_id')

You can use this for all type field in v17.0 (Note:- Only for setting value in res.config.setting')

Avatar
cabrejua
Meilleure réponse

Why are you using ICPSudo in get_values, and not in set_values ?

You should add sudo() in self.env['ir.config_parameter'].set_param('module_name.field_name', self.field_name):

self.env['ir.config_parameter'].sudo().set_param('module_name.field_name', self.field_name)

or

ICPSudo = self.env['ir.config_parameter'].sudo()
so that you can use ICPSudo

1
Avatar
Ignorer
Avatar
Jaiswal Shivam
Meilleure réponse

In Odoo 17.0 You can do like this

sale_invoice_id = fields.Many2one('sale.order', string='Sale Invoice', config_parameter='current_module_name.sale_invoice_id')

You can use this for all type field in v17.0 (Note:- Only for setting value in res.config.setting')

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
disable delete and edit options in conversations Odoo 15
configuration settings
Avatar
Avatar
Avatar
2
avr. 24
5358
After click Settings I get a Error: field_utils.format[(intermediate value)] is not a function
settings v14
Avatar
0
déc. 22
4102
What are the things to watch out for before my OpenERP goes live? Version 7.
configuration settings
Avatar
0
mars 15
8160
Reserve Profit and Loss Account
configuration settings
Avatar
Avatar
1
mars 15
7490
'method' object is not subscriptable
settings orm v14
Avatar
Avatar
1
avr. 24
6053
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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