Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • Hotel
    Real Estate
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    Consulting
    • Accounting Firm
    • Odoo पार्टनर
    • Marketing Agency
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • 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 change settings on module installation?

Subscribe

Get notified when there's activity on this post

This question has been flagged
settingsmodulexml
2 Replies
12489 Views
Avatar
Christoph

I want to change a value in the settings of sale.config.settings. For this I created a XML file which I added to the __openerp__.py:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="sale.config.settings" id="activate_dropshipping_sale">
      <field name="group_route_so_lines">True</field>
    </record>
  </data>
</openerp>

The problem is that this value is not changed in the settings. Maybe it's the problem that there is no entry in that table because the settings were not changed at this time.

How can I change a settings value like this?

2
Avatar
Discard
Avatar
Temur
Best Answer

 

xml ===================

<?xml version="1.0"?>
<openerp>
<data>

<function model="my.model.init" name="_init_settings" />

</data>
</openerp>

 

python ======================

class my_model_init(osv.osv_memory):

    _name = ''my.model.init"
    _columns = {}
    _defaults = {}

    def _init_settings(self, cr, uid, ids=None, context=None):
        sale_settings_pool = self.pool.get('sale.config.settings')
        sale_settings_id = sale_settings_pool.create(cr, uid, {'group_route_so_lines':True}, context=context)
        sale_settings_obj = sale_settings_pool.browse(cr, uid, sale_settings_id, context=context)
        sale_settings_obj.execute()  # this call is actually changes the setting, you're missing this step @Yenthe ...
        return True

 

2
Avatar
Discard
Temur

You can add "_init_settings" function to an existing class in your module, rather than make separate class for it. But then you must adjust "function" entry in XML, by changing the "model" property accordingly.

Yenthe Van Ginneken (Mainframe Monkey)

@Temur what exactly do you mean with return True? Where exactly should this come then? :o

Temur

Just convention for successful termination, You can omit that, if the rest of code works for you ))

Audrius

The same principle works also in odoo 10

Avatar
Bole
Best Answer

The reason nothing happens is : sale.config.settings is a transient model,
so no values stored there are permanenet. It works a bit different with application settings

If you want something like setting some choices ... you should check yml files.. 
It can be done that way.. 

In your case you shold look at sale_stock module, res_config.py 
In your xml you can achieve desired solution with adding a new property to your company default_picking_policy 
( take a look at method set_sale_defaults )

hope this will help a bit...
Here is some resurce links for yaml usage:
odoo / openerp documentation
zbeanztech-blog: how-effective-yaml-testing-openerp
slideshare presentation from camp to caml

0
Avatar
Discard
Yenthe Van Ginneken (Mainframe Monkey)

Hey Bole could you add an example? I'm trying to do the same as Cristoph at the moment but without succes. I was thinking like this: !python {model: account.config.settings}: | value_obj = self.pool.get('account.config.settings') if value_obj: vals = { 'module_account_followup': 'True', } value_obj.write(cr, uid, vals, context) But that does not seem to work.

Yenthe Van Ginneken (Mainframe Monkey)

Note: I'm doing it for a checkmark on the account module, Christoph is trying it for the sale module, but the concept is identical.

Bole

Your idea (from linkedin) is good example... The rest is in correct usage and understanding how res.config works... here is mentioned sales module... so why not check res_config.py in sales module.... you will find out that there is few types of settings: boolean values are sometimes related to res_company properites, and some of them trigger module instalation... so for every value in congif you want to automate first check how it is defined in rec_config of module... from there... yml method can provide an easy tool to do the job... hope this helps... will post some examples as soon as i get the time to write and test them on v8...

OdooBot
Hi Bole

i've tried this in two ways and both did not work sadly.. I tried id 0 and id 1 too. I've been looking at the .py file too but I'm not quite sure exactly what I should trigger to get everything going though!

    !python {model: account.config.settings}: |
     value_obj = self.pool.get('account.config.settings')
     if value_obj:
       vals = {
        'module_account_followup': 'True',
       }
       value_obj.write(cr, uid, vals, context)
-
    test
-
    !python {model: account.config.settings}: |
     user_ids = self.pool.get('account.config.settings').search(cr, uid, [('id', '=', '1')], limit=1, context=context)
     if user_ids:
       self.write(cr, uid, user_ids, {
       'module_account_followup': 'True',
       }, context)

Any more ideas / guidance please? I'm still learning a lot in this!
Yenthe

2015-01-09 14:35 GMT+01:00 Bole <bole-dajmi5-com@mail.odoo.com>:

Your idea (from linkedin) is good example... The rest is in correct usage and understanding how res.config works... here is mentioned sales module... so why not check res_config.py in sales module.... you will find out that there is few types of settings: boolean values are sometimes related to res_company properites, and some of them trigger module instalation... so for every value in congif you want to automate first check how it is defined in rec_config of module... from there... yml method can provide an easy tool to do the job... hope this helps... will post some examples as soon as i get the time to write and test them on v8...

--
Bole
Sent by Odoo S.A. using Odoo about Forum Post False

Bole

well some hints... 1. there is no id=0 in any table.. all tables are indexed from 1. 2. res_config is transiend model and writing to it means nothing... 3. writing to res_config usualy triggers some other actions like: instaling module ( fileds named module_xxx ) , or setting some properties or defaults ( usualy on res_company object) ... try debugging save action on some config files and see what happens... and how odoo handes "saved" data... in fact.. what odoo DOES when you push SVAE on config view...

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
how to manage this 2 modules
module xml
Avatar
0
मार्च 15
4279
error while parsing inherit view
module xml custom
Avatar
Avatar
1
जून 23
4316
How to change the Your Company record with XML Solved
module xml initialization
Avatar
Avatar
2
अप्रैल 23
18456
"'30' is not an integer or a virtual id" when updating a custom module setting Solved
settings module res.config
Avatar
Avatar
Avatar
Avatar
4
अप्रैल 23
7768
[12.0] enable features in the res.config.settings Solved
settings xml res.config
Avatar
Avatar
Avatar
Avatar
6
मार्च 24
24720
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • 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