Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Problems on saving data to "res.config.settings" in Odoo 12

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
settingssaveodoo12.0
2 Odpowiedzi
33339 Widoki
Awatar
Paulo Matos

Dear all,

I am having a problem on Odoo v12 on saving data on "res.config.settings" model.

I have inherited the model and defined my custom fields:

       class ResConfigSettings(models.TransientModel):
           _inherit = ['res.config.settings']
           #My custom fields
           my_custom_field1_id = fields.Many2one('res.partner', string='For Customer')
           my_custom_field2_id = fields.Many2one('res.partner', string='For Supplier')

The above code is the only code I have on the module .py.

For the UI I have inherited the "res_config_settings_view_form" on the corresponding XML file.

      <record id="res_config_settings_mymodule_form" model="ir.ui.view">
      <field name="name">Config Settings for My Module</field>
      <field name="model">res.config.settings</field>
      <field name="priority" eval="90"/>
      <field name="inherit_id" ref="base.res_config_settings_view_form"/>
      <field name="arch" type="xml">
           <xpath expr="//div[hasclass('settings')]" position="inside">
           <div class="app_settings_block" data-string="MyModule" string="MyModule" data-key="mymodule" groups="account.group_account_manager">
           <t groups="account.group_account_user">
                <h2>My Module Defaults</h2>
                <div class="row mt16 o_settings_container">
                <div class="col-12 col-lg-6 o_setting_box" title="These values are default values the module">
                <div class="o_setting_left_pane">
                </div>
                     <div class="o_setting_right_pane">
                     <span class="o_form_label">Default Data</span>
                     <span class="fa fa-lg fa-building-o" title="Values set here are company-specific." aria-label="Values set here are company-specific." groups="base.group_multi_company" role="img"/>
                     <div class="text-muted">
                     Default values for module
                     </div>
                     <div class="content-group">
                     <div class="row mt16">
                          <label string="Customer" for="my_custom_field1_id" class="col-lg-3 o_light_label"/>
                          <field name="my_custom_field1_id" domain="[('customer', '=', 'True'), ('company_id', '=', company_id)]"/>
                     </div>
                     <div class="row mt16">
                          <label string="Supplier" for="my_custom_field2_id" class="col-lg-3 o_light_label"/>
                          <field name="my_custom_field2_id" domain="[('supplier', '=', 'True'), ('company_id', '=', company_id)]"/>
                     </div>
                     </div>
                     </div>
                     </div>
                     </div>
           </t>
           </div>
           </xpath>
      </field>
      </record>

Everything seems to be working fine and I get no errors and I can see the new "app_settings_block" created for My Module with both new fields and they work for the domain I set for each field.

The problem I have is that when I set a value to any of the fields and click on the "Save" button, the data is simple not saved into the database.

I am sure I am working with correct user/group and have full access to the system.

What could be the problem?

Any idea?

Thank you all in advance

Best regards

Paulo


5
Awatar
Odrzuć
Niyas Raphy (Walnut Software Solutions)

https://www.youtube.com/watch?v=MsVoYPQ4-J4

Awatar
Haresh Kansara
Najlepsza odpowiedź

Hello Paulo,

The General Settings (res.config.settings) data is not directly save on Save button click, you need to set setter-getter method to manage this field's data. These data are store in config parameter and fetch from this config parameter.

You are doing all perfect, but add bellow code in your python file:

from odoo import api, fields, models, modules

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

    #My custom fields
    my_custom_field1_id = fields.Many2one('res.partner', string='For Customer')
    my_custom_field2_id = fields.Many2one('res.partner', string='For Supplier')

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

    @api.multi
    def set_values(self):
        super(ResConfigSettings, self).set_values()
        param = self.env['ir.config_parameter'].sudo()

        field1 = self.my_custom_field1_id and self.my_custom_field1_id.id or False
        field2 = self.my_custom_field2_id and self.my_custom_field2_id.id or False

        param.set_param('your_custom_module_name.my_custom_field1_id', field1)
        param.set_param('your_custom_module_name.my_custom_field2_id', field2)


Hope it will helpful for you.

Thanks and regards

Haresh Kansara

9
Awatar
Odrzuć
Paulo Matos
Autor

Dear @Haresh,

Thank you very much for your asnwer.

It helps me to better understand how "res.config.settings" works.

Anyway, I'm having a problem with the "set_values()" function you provided on your sample code and need your help on fixing it.

I am testing your code with only "my_custom_field1" from the code on my question.

After testing it, only with the "get_values()" function, I can see on the postgresql database table "res_config_setting" that the ID for the selected partner is correctly set.

In my case, the id is "7".

When I "activate" the "set_values()" function, I am getting the below error:

"Database fetch misses ids (('7',)) and has extra ids ((7,)), may be caused by a type incoherence in a previous request"

In fact this ids "7" from the error is the same id for the selected partner and I believe it's something related with data type.

Tested with other partners and the error id is always equal to the id of the selected partner.

Can you please help fixe this?

Thank you in advance

Best regards

Paulo

Paulo Matos
Autor

Dear @Haresh,,

I have found the issue.

I had to convert the result into an integer since it receives a char result.

I have changed the code for "get_values()" function to:

my_custom_field1_id = int(self.env['ir.config_parameter'].sudo().get_param('your_custom_module_name.my_custom_field1_id')),

By convert the result to an integer (int()) value it's working as expected.

Thank you once again

Best regards

Paulo

CARLOS ALBERTO GARCIA BRIZUELA

Excellent solution, works great for me!

Thanks a lot

Awatar
rabeb246
Najlepsza odpowiedź

editor doesn't save the content when I press "Save" odoo14???????


0
Awatar
Odrzuć
Zahid Mehmood

field_name = fields.Integer('Field String',config_parameter="field_name")

Add config_parameter this parameter in the field definition

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Value in own settings is not stored
settings value save
Awatar
0
mar 15
4252
Can't fix Error On Save in Settings: Invalid Fields Rozwiązane
settings error invalid save
Awatar
Awatar
2
lip 24
9785
Expected singleton: hr.emp.travel.location(62, 63)
odoo12.0
Awatar
Awatar
Awatar
2
paź 25
1945
USUARIO DE LECTURA - ODOO
settings
Awatar
Awatar
Awatar
2
wrz 25
724
Fiscal localizations
settings
Awatar
Awatar
2
kwi 25
10950
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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