コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    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:

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

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

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
settingssaveodoo12.0
2 返信
33313 ビュー
アバター
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
アバター
破棄
Niyas Raphy (Walnut Software Solutions)

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

アバター
Haresh Kansara
最善の回答

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
アバター
破棄
Paulo Matos
著作者

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
著作者

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

アバター
rabeb246
最善の回答

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


0
アバター
破棄
Zahid Mehmood

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

Add config_parameter this parameter in the field definition

ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Value in own settings is not stored
settings value save
アバター
0
3月 15
4233
Can't fix Error On Save in Settings: Invalid Fields 解決済
settings error invalid save
アバター
アバター
2
7月 24
9743
Expected singleton: hr.emp.travel.location(62, 63)
odoo12.0
アバター
アバター
アバター
2
10月 25
1936
USUARIO DE LECTURA - ODOO
settings
アバター
アバター
アバター
2
9月 25
717
Fiscal localizations
settings
アバター
アバター
2
4月 25
10943
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة 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(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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