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

Qweb templating (Python side) : Access survey_user_input model on survey template using t-field ?

購読

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

この質問にフラグが付けられました
pythonqwebcontrollerst-field
1 返信
11445 ビュー
アバター
TEIMI Yassine

Dears,

As you know t-field gives fields access via browsable record.

For the survey module, it's used on survey qweb template. For example, for the survey_init template (the first page of every started survey, describing survey title, and description) here is the code using t-field :

 <template id="survey_init" name="Survey"> 

<t t-call="website.layout">
<div class="wrap">
<div class="oe_structure" />
<div class="container">
<div groups="base.group_website_publisher" t-ignore="true" class="text-right">
<a href="/web#action=survey.action_survey_form" class="btn btn-default">Go back to su rveys</a>
</div>
<div class='jumbotron mt32'>
<h1 t-field='survey.title' />
<div t-field='survey.description' class="oe_no_empty"/>
<a class="btn btn-primary btn-lg" t-att-href="'/survey/fill/%s/%s' % (slug(survey ), token)">
Start Survey
</a>
</div>
</div>
<div class="oe_structure" />
</div>
</t>
</template>

So how this is can be done ?

Humble answer : After inspecting the controllers code, it's the start_survey() method that is responsible of launching the survey, it takes the variable survey as a parameter, and send it via data dictionnary trough : website.request.render, wich allows access survey fields value using t-field.

Here is the code part (For one page rendering case "test survey" among others) explainig that :

 @http.route(['/survey/start/<model("survey.survey"):survey>', 
'/survey/start/<model("survey.survey"):survey>/<string:token>'],

type='http', auth='public', website=True)
def start_survey(self, survey, token=None, **post):
cr, uid, context = request.cr, request.uid, request.context
    survey_obj = request.registry['survey.survey']
    user_input_obj = request.registry['survey.user_input']
    # Test mode
    if token and token == "phantom":
        _logger.info("[survey] Phantom mode")
        user_input_id = user_input_obj.create(cr, uid, {'survey_id': survey.id, 'test_entry': True}, context=context)
        user_input = user_input_obj.browse(cr, uid, [user_input_id], context=context)[0]
        data = {'survey': survey, 'page': None, 'token': user_input.token}
    return request.website.render('survey.survey_init', data)

My question here is how survey is passed as a parameter ? is it by using @route ?

If I know how to pass more parameters to start_survey(), then maybe I can pass a parameter named like "survey_user_input" trough data dictionnary, allowing me to use it on t-field.

NB:

I'm calling my survey from hr_evaluation_interview model from the hr_evaluation module.

Here is the method calling survey from hr_evaluation module (maybe I can use it to pass a parameter to start survey via context) :

 def action_start_survey(self, cr, uid, ids, context=None): 
''' Open the website page with the survey form '''
    trail = ""
    context = dict(context or {}, relative_url=True)
    if 'survey_token' in context:
        trail = "/" + context['survey_token']
    return {
        'type': 'ir.actions.act_url',
        'name': "Start Survey",
        'target': 'self',
        'url': self.read(cr, uid, ids, ['public_url'], context=context)[0]['public_url'] + trail
        }

I hope my question is clear, if not, I'm here for further explainations.

Many thanks for your help.

0
アバター
破棄
アバター
Axel Mendoza
最善の回答

The argument survey is converted and passed by the @route decorator, converting the positional param of the url to a model object using a model argument pattern converter declared in the url param of the @route decorator and passed to the handle method of the url. 

See more here about that:

https://www.odoo.com/documentation/8.0/howtos/website.html#urls-and-routing

Specifically:

Odoo provides an additional converter called model which provides records directly when given their id. Let's use this to create a generic page for teacher biographies:

So you need to redefine the method and the @route url pattern and the method arguments to match the url pattern.

The url returned on the method action_start_survey need to match the @route url pattern so add the id value of the survey_user_input param to the url obtained from the field public_url or to the trail var, the thing is that the result url need to match the url for the @route overrided

1
アバター
破棄
TEIMI Yassine
著作者

Thanks a lot Axel for your explainations, I'm now trying to override : action_start_survey method called from hr_interview (I did'nt included it on my post), it's the first called method, that calls action_start_survey of the survey model. (So functionnaly speaking, it's like using action_start_survey for a human ressources evaluation purpose). Then I'll override action_start_survey of the survey module, and then override @route decorator and start_survey() method. I'll post my code, and further details soon. Thanks for your valuable help.

TEIMI Yassine
著作者

Hi Axel, it worked : On the first action_start_survey (on hr_interview object) I had to pass a browsable record of it, using context, and then on action_start_survey(survey object), modify trail, and add slug(context['interview']) to the url, and finally on the start_survey() method override @route decorator and pass the parameter, then send it via data dictionnary to the qweb view, and it's ready to use. I have to do the same for print_survey() and fill_survey(). Thanks a lot Axel for your help.

Axel Mendoza

Happy to help

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

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

登録
関連投稿 返信 ビュー 活動
What's the difference between t-esc and t-field in a report ? 解決済
qweb t-field
アバター
アバター
アバター
3
7月 23
32681
Issue with a new Product Label Template (102x102) in Odoo V17
development python qweb
アバター
0
12月 24
1847
passing values to the react using Controller
qweb controllers ReactJs
アバター
アバター
アバター
2
12月 23
2418
Email template - list of followers
python qweb email
アバター
アバター
アバター
2
6月 23
3233
My custom report is changing when user Configured the Document Layout 解決済
python qweb v14
アバター
アバター
1
1月 23
3395
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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