コンテンツへスキップ
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
このフォーラムについて
ヘルプ

Working with fields.selection values

購読

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

この質問にフラグが付けられました
selection
1 返信
28352 ビュー
アバター
Leopoldo Cantillo M.

Hi,

How I can read or return the value chosen from a selection field? I need the user to select values from a list, and use the selected value to complete the information in other fields in the form.

Thanks.

Some code used to test, with error:

....
 'seq_choosed': fields.selection([(11,'Product End'),(12,'Product Base')],'Sequence to use '),
...
 lot_sequence = self.pool.get('ir.sequence').get_id(cr, uid, seq_choosed.value, context={} )
1
アバター
破棄
Sehrish

Hope this will helps: https://learnopenerp.blogspot.com/2021/08/get-selection-field-value-instead-of-key-odoo.html

アバター
Olivier Dony (odo)
最善の回答

Your question does not clearly explain what you want to do nor what you tried. You say you have an error but you do not say what is the error message (and trace). Your code example is not complete enough to understand properly.

Still, here are a few pointers:

  • How to obtain the value chosen by the user depends on where you do it: in an on_change method, in a fields.function, when overriding one of the base ORM methods, etc.
  • Have a look at the OpenERP Technical memento, it contains examples for these various use cases.
  • The selection field in your example has 2 possible hardcoded integer values: 11 or 12. This is rather unusual but supported. Most selection fields use string values though. In this case when you read() or browse() a record from the model in which this field is defined, you will get the value as an int (11 or 12) or False if the field was left empty (if it's not required).

Here's a random example based on the little information you provided:

Imagine you put an on_change on your field in the XML view:

  <field name="seq_choosed" on_change="on_change_seq_choosed(seq_choosed)"/>
  <field name="seq_num"/>

Then you could do something like the following:

  def on_change_seq_choosed(self, cr, uid, ids, seq_choosed, context=None):
       # on_change returns a dict
       result = {
           'value': {}
       }
       # selected value is explicitly passed in seq_choosed parameter in XML def 
       if seq_choosed:
           seq_num = self.pool.get('ir.sequence').get_id(cr, uid, seq_choosed, context=context)
           result['value']['seq_num'] = seq_num
       return result

That's not a very useful example, but if you want better answers you'll have to be a lot more specific in your question ;-)

2
アバター
破棄
Leopoldo Cantillo M.
著作者

Thanks a lot for your answer, and all the corrections, my English is no very good. I going to try this, and looking more about the on_change method.

Atchuthan - Technical Consultant, Sodexis Inc

@Oliver Dony, for instance I want to print the value (Product Base) with key (12), how to do?

If I print seq_choosed, it prints me the key of selection field. I need to print value of key chosen

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

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

登録
関連投稿 返信 ビュー 活動
how to add values dynamically in selection fields? 解決済
selection
アバター
アバター
アバター
アバター
アバター
4
12月 23
23255
Dynamically change choices in selection fields 解決済
selection
アバター
アバター
アバター
アバター
アバター
5
7月 24
16634
How to change the values for a selection field? 解決済
selection
アバター
アバター
アバター
アバター
アバター
9
5月 22
54642
How to get values from a radio button in a Selection
selection
アバター
0
7月 20
3746
Changing field selection data on change event
selection
アバター
0
3月 20
4462
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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