Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

How to programmatically configure general settings (base.config.settings) in Odoo 10

Subscribe

Get notified when there's activity on this post

This question has been flagged
settingspythonmoduleodoo10odoo10.0
4 Replies
25435 Views
Avatar
Creative Emergy Inc.

My goal is to have a module do the setup at install: loading dependencies, and settings configuration parameters. The idea is to keep everything in the code (if possible), to have all the information in the same place. In my dream, I'd love to have all the parameters in a key-value based file in my module.

I managed to successfully set parameters in res.company and website (e.g. changing the default favicon), but I have a hard time accessing the parameters in base.config.settings, as it apparently deals with transient models (or is there another way?). My readings lead me to try things like this:

  1. create an object from the transient model with the required values set

  2. call execute() on it

I tried the code below in a module (with the companion view).

class ResBaseConfigSettings(models.TransientModel):
    _inherit = "base.config.settings"
    @api.model 
    def set_signup_parameters(self):
        _logger.info("> Settings sign-up parameters")
        _logger.info(self)
        settings = self.env['base.config.settings'].create({
            'auth_signup_uninvited': True,
            'auth_signup_reset_password': True,
        })
        settings.execute()
        _logger.info("> ... done.")

Here is the view (set_config_parameters.xml):

<odoo>
  <data noupdate="1">
            <function model="base.config.settings" name="set_signup_parameters"/>
  </data>
</odoo>

Unfortunately, when I execute the code (by installing the module) an infinite loop is created, and I can't figure out why. 

2017-08-08 06:04:14,308 4649 INFO TFBN01A odoo.modules.loading: loading tfbn_enhancements/views/set_config_parameters.xml
2017-08-08 06:04:14,452 4649 INFO TFBN01A odoo.addons.tfbn_enhancements.models.models: > Settings sign-up parameters
2017-08-08 06:04:14,452 4649 INFO TFBN01A odoo.addons.tfbn_enhancements.models.models: base.config.settings()
2017-08-08 06:04:15,744 4649 INFO TFBN01A odoo.addons.tfbn_enhancements.models.models: > Settings sign-up parameters
2017-08-08 06:04:15,744 4649 INFO TFBN01A odoo.addons.tfbn_enhancements.models.models: base.config.settings(1,)
2017-08-08 06:04:16,929 4649 INFO TFBN01A odoo.addons.tfbn_enhancements.models.models: > Settings sign-up parameters
2017-08-08 06:04:16,929 4649 INFO TFBN01A odoo.addons.tfbn_enhancements.models.models: base.config.settings(2,)
2017-08-08 06:04:18,162 4649 INFO TFBN01A odoo.addons.tfbn_enhancements.models.models: > Settings sign-up parameters
2017-08-08 06:04:18,162 4649 INFO TFBN01A odoo.addons.tfbn_enhancements.models.models: base.config.settings(3,)
(...)

Also, when I'm trying to execute this in the console, it seems to work ok. At least, there is no sign of infinite loop. 

>>> c = self.env['base.config.settings'].create({'auth_signup_uninvited': True,'auth_signup_reset_password': True,})
>>> c
base.config.settings(1,)
>>> c.execute()
2017-08-08 06:45:38,182 9929 INFO TFBN01A odoo.addons.base.res.res_config: getting next operation 2017-08-08 06:45:38,183 9929 INFO TFBN01A odoo.addons.base.res.res_config: getting next ir.actions.todo()
2017-08-08 06:45:38,188 9929 INFO TFBN01A odoo.addons.base.res.res_config: next action is None
{'url': '/web', 'type': 'ir.actions.act_url', 'target': 'self'}

I'm also wondering where those settings are stored in the database (in ir_config_parameter?), and the proper way to store these permanently.

What am I missing? Thanks for the help.




3
Avatar
Discard
Avatar
Creative Emergy Inc.
Author Best Answer

Update: there are two possible ways to achieve the same result (i.e. getting two boolean fields checked).

OPTION 1) Using Python code

About the issues described above, and for the record:

  • the infinite loop comes for the fact the above code did not implement the right type of inheritance (it did implement class inheritance instead of the desired prototype inheritance). The fix is to add a _name attribute (different from _inherit). See https://www.odoo.com/documentation/10.0/howtos/backend.html#inheritance

  • the view needs to be fixed accordingly

See the revised code:


class ResBaseConfigSettings(models.TransientModel):
    _name = "my.config.settings" # that's prototype inheritance (vs. class inheritance if omitted)
                                   # see https://www.odoo.com/documentation/10.0/howtos/backend.html#inheritance
    _inherit = "res.config.settings"
    @api.model 
    def set_signup_parameters(self):
        _logger.info("> Settings sign-up parameters")
        settings = self.env['res.config.settings'].create({
            'auth_signup_uninvited': True,
            'auth_signup_reset_password': True,
        })
        settings.execute()
        _logger.info("> ... done.")

and the view reflecting the new model _name:

<odoo>
  <data noupdate="1">
            <function model="my.config.settings" name="set_signup_parameters"/>
  </data>
</odoo>


OPTION 2) Entirely in a view with a record and a function node

Just make sure your module is called "my_app" or remove the "my_app." part from the id and ref below.

<!-- Another way to set up the signup parameters vs. the record, then the function (in that order) below
           See https://www.odoo.com/forum/help-1/question/how-to-update-a-module-s-config-settings-from-another-module-28230
-->
      <record model="base.config.settings" id="my_app.signup_settings">
        <field name="auth_signup_uninvited" eval="1"/>  
        <field name="auth_signup_reset_password" eval="1"/> 
      </record>
      <function model="base.config.settings" name="execute">
        <!-- ids = --> <value eval="[ref('my_app.signup_settings')]"/>
        <!-- context = --> <value eval="{}"/>
      </function>



4
Avatar
Discard
Avatar
Maxime Chambreuil
Best Answer

Hello Marc,

The configuration panels are views to trigger different actions in the background when you click on "Apply". It installs modules, adds users to groups or set a default values. You can reproduce those same actions using the dependencies of your module to install other modules or from an XML file in your module to update groups or set the value of the defaults.

1
Avatar
Discard
Avatar
Jacob Neubaum
Best Answer

Updated for v16

I was trying to figure out how to do this completely from the odoo shell and was able to solve with the following code:

newSettings = env['res.config.settings'].create({})
newSettings.update({'auth_signup_uninvited' : True})
newSettings.execute()
env.cr.commit()

0
Avatar
Discard
Avatar
Ray Carnes (ray)
Best Answer

Updated for v15:


# get access to the configuration model
ResConfig = env["res.config.settings"].create({}).execute()

# get a copy of the default values
default_values = ResConfig.default_get(list(ResConfig.fields_get()))

# update the default values = "Operations --> Warnings"
default_values.update({"group_warning_stock": True})

# save

ResConfig.create(default_values).execute()

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Make tabular under <page>. Notebook doesnt work
python odoo10 odoo10.0
Avatar
Avatar
2
जन॰ 18
4175
Set Default Country Solved
python python2.7 odoo10 odoo10.0
Avatar
Avatar
2
जून 20
14619
Can't import a model in odoo view Solved
python module models odoo10.0
Avatar
Avatar
Avatar
Avatar
Avatar
7
जुल॰ 19
43159
odoo 10: How to search and get the partner details in a field by using the phone number? Solved
python module models odoo odoo10.0
Avatar
Avatar
Avatar
2
अग॰ 18
12591
Error when creat new patient of Medical Odoo 10
python xml erp odoo10 odoo10.0
Avatar
Avatar
Avatar
6
मार्च 18
5288
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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