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

Odoo 10 Wizard: How to populate with active fields from parent view

購読

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

この質問にフラグが付けられました
wizardcontextactive_idpopulateodoo10
4 返信
18912 ビュー
アバター
Bérengère Bouillon

Hello,


I'm stuck to populate a wizard and I'm completely lost on the way to do that.

Until know, I've created a custom button on the stock module, view_picking_form record with an inherited model (see views.xml). I also know how to create a custom wizard (wizard.py wizard.xml).

But what I do not know is how to populate it with the list of products fields (product_id, product_qty, qty_done) that are linked to the active view. I'm working with the new API on Odoo 10 and couln't find the method to do that. Odoo always tells me it doesn't know the fields I want to pass and they don't display on the wizard.

Can anyone help me on that please ?


views.xml

<?xml version="1.0" encoding="utf-8"?>
    <odoo>
        <data>
            <record id="view_picking_form_inherit" model="ir.ui.view">
                <field name="name">stock.picking.form.inherit</field>
                <field name="model">stock.picking</field>
                <field name="inherit_id" ref="stock.view_picking_form"/>
                <field name="arch" type="xml">

                    <xpath expr="//form/sheet/h1[@class='hidden-xs']" position="inside">
                        <div class="oe_right oe_button_box">

                            <button string="Open Wizard" name="%(action_wizard)d"
                                    type="action" class="oe_button oe_form_button oe_highlight"
                                    context="{'default_active_id': active_id}"/> </div> </xpath> </field> </record> </data> </odoo>


wizard.py

# -*- coding: utf-8 -*-
from odoo import _, api, fields, models

class MyClass(models.TransientModel):
    _name = 'stock.picking.wizard'
    _inherit = ['stock.picking', 'stock.pack.operation'] 

    @api.multi
def _default_products(self):
self.ensure_one()
active_id = self.env.context.get('active_ids', []) or []
record = self.env['stock.picking'].browse(active_id)
return record.product_id product_id
= fields.Many2one('product.product', string='Product', default=_default_products)


wizard.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="view_wizard" model="ir.ui.view">
            <field name="name">stock_picking_wizard</field>
            <field name="model">stock.picking.wizard</field>
            <field name="arch" type="xml">
                <form string="Stock Products">
                    <tree string="Product list">
                        <field name="product_id"/>
                    </tree>
                </form>
            </field>
        </record>

        <record id="action_wizard" model="ir.actions.act_window">
            <field name="name">Wizard</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">stock.picking.wizard</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_wizard"/>
            <field name="target">new</field>
        </record>
    </data>
</odoo>


0
アバター
破棄
Niyas Raphy (Walnut Software Solutions)

Hi Bérengère Bouillon,

I didn't understand what exactly you are looking for, as far as i undestood do you want to add all the product into the new field you have created in the wizard from the active stock picking lines ?

Bérengère Bouillon
著作者

Hi Niyas Raphy,

Yes it's that. When I'm on an available transfert, I need to retrieve all the products of the active record in my wizard.

Niyas Raphy (Walnut Software Solutions)

Hi , you can make it a many to many field, ie the product field in the wizard. Then you can write the products from the stock picking lines into it.

link : https://stackoverflow.com/questions/31853402/filling-many2many-field-odoo-8

Bérengère Bouillon
著作者

Thanks Niyas, but I don't understand how a many2many relation could be useful in this situation. Maybe I didn't explained well. The goal is to get the active view informations (included the product_id, product_qty,...) and pass them into the wizard to get the same products I had in the previous view (but only these ones). The lead I found to do that was to get the context through the active_id, but I didn't manage to do it for know.

アバター
Bérengère Bouillon
著作者 最善の回答

I managed to do something by creating the wizard in the models.py :

models.py

@api.multi
    def open_wizard2(self):
        view = self.env.ref('my_module.view_custom_wizard')
        wiz = self.env['stock.picking.wizard'].create({'picky_id': self.id})
        return {
            'name': _('Create wizard'),
            'type': 'ir.actions.act_window',
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'stock.picking.wizard',
            'views': [(view.id, 'form')],
            'view_id': view.id,
            'target': 'new',
            'res_id': wiz.id,
            'context': self.env.context,
        }

wizard.py

class MyWizard(models.TransientModel):
    _name = 'stock.picking.wizard'
    _inherit = ['stock.picking', 'stock.pack.operation']

    picky_id = fields.Many2one('stock.picking')

    @api.model
    def default_get(self, fields):
        res = super(MyWizard, self).default_get(fields)
        if 'picky_id' in fields and self._context.get('active_id') and not res.get('picky_id'):
            res = {'picky_id': self._context['active_id']}
        return res


With this method I saw that I get most of the context, but there is still some fields missing like the location_id which gives me a validation Error. Can you tell me if I'm using the wright solution and why I'm getting this error ?

The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it
- creation/update: a mandatory field is not correctly set
[object with reference: location_id - location.id]
db_1    | ERROR:  null value in column "location_id" violates not-null constraint
db_1    | DETAIL:  Failing row contains (5, null, null, null, null, f, f, 0.000, null, null, null, null, direct, null, 1, null, null, 0.000, , null, 1, 1, 0.000, t, null, null, null, f, 2017-06-08 08:26:59.126366, 2017-06-08 08:26:59, /, null, null, 2017-06-08 08:26:59.126366, null, null, null, null, 25).
db_1    | STATEMENT:  INSERT INTO "stock_picking_wizard" ("id", "body", "product_qty", "name", "move_type", "fresh_record", "company_id", "picky_id", "location_dest_id", "ordered_qty", "launch_pack_operations", "qty_done", "date", "printed", "location_id", "recompute_pack_op", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval('stock_picking_wizard_id_seq'), '', '0.000', '/', 'direct', true, 1, 25, NULL, '0.000', false, '0.000', '2017-06-08 08:26:59', false, NULL, false, 1, 1, (now() at time zone 'UTC'), (now() at time zone 'UTC')) RETURNING id
web_1   | 2017-06-08 08:26:59,133 1 INFO odoo10db odoo.sql_db: bad query: INSERT INTO "stock_picking_wizard" ("id", "body", "product_qty", "name", "move_type", "fresh_record", "company_id", "picky_id", "location_dest_id", "ordered_qty", "launch_pack_operations", "qty_done", "date", "printed", "location_id", "recompute_pack_op", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval('stock_picking_wizard_id_seq'), '', '0.000', '/', 'direct', true, 1, 25, NULL, '0.000', false, '0.000', '2017-06-08 08:26:59', false, NULL, false, 1, 1, (now() at time zone 'UTC'), (now() at time zone 'UTC')) RETURNING id



0
アバター
破棄
アバター
Shameem Babu
最善の回答

It is related question :

https://www.odoo.com/forum/help-1/question/110946 


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

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

登録
関連投稿 返信 ビュー 活動
Call a wizard, in context pass an id. Not recognized 解決済
wizard context odoo10
アバター
1
8月 19
5223
Update Wizard without closing it after button click
wizard odoo10
アバター
0
10月 23
2575
How to save the values of fields ?
wizard odoo10
アバター
アバター
アバター
4
10月 18
9437
Is it possible to create a new record with wizard? 解決済
wizard odoo10
アバター
アバター
アバター
3
6月 18
7768
active_domain not found in context when using wizard
wizard context
アバター
0
8月 17
4176
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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