2017-08-24 9 views
1

は、モデルの、カスタムモジュール今ウィザードでレコードの保存ボタンを作成します - 私はステップでウィザードを作成しましたOdoov8

で、私の問題は、第4ステップでは、ワークフローが終了したということですすべてのフィールドを保存する必要がありますが、私はウィザードに保存ボタンがありません

私のウィザードの他のすべてのフィールドを維持する方法はありますか?

マイウィザードビュー:

<record id="view_wizard_prod_order_form" model="ir.ui.view"> 
     <field name="name">bsi.production.order.wizard</field> 
     <field name="model">bsi.production.order</field> 
     <field name="arch" type="xml"> 
      <form string="Production Order"> 
       <field name="state" widget="statusbar" statusbar_visible="step1,step2,step3,step4" statusbar_colors='{"step3":"blue","step4":"blue"}' clickable="True" /> 
        <group> 
        <group> 
         <field name="date_production" attrs="{'invisible': [('state', '!=', 'step1')]}" /> 
         <field name="product_id" attrs="{'invisible': [('state', '!=', 'step1')]}" /> 
         <field name="qty_available" attrs="{'invisible': [('state', '!=', 'step1')]}" /> 
         <field name="isbn1" attrs="{'invisible': [('type_prod', '!=', 'direct')]}" /> 
         <field name="isbn2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/> 
         <field name="isbn3" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/> 
         <field name="isbn4" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/> 
         <field name="isbn5" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/> 
         <field name="isbn6" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/> 
        </group> 
        <group> 
         <field name="type_prod" attrs="{'invisible': [('state', '!=', 'step1')]}"/> 
         <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}" /> 
         <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/> 
         <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/> 
         <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/> 
         <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/> 
         <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/> 
        </group> 
       </group> 
       <group> 
        <group string="Book Block" attrs="{'invisible': [('state', '!=', 'step2')]}"> 
          <field name="name_block" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="category" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="language" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="edition" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="size" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="book_block_textp" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="n_pages_one_color" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="two_color" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="four_color" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="total" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="text_print_code" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="book_block_adpaper" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="adnl_n_pages_one_color" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="adnl_two_color" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="adnl_third_color" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="adnl_four_color" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="adnl_total" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="adnl_text_print_code" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="book_block_txtep" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="n_of_end_pages" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
        </group> 
        <group string="Book Size" attrs="{'invisible': [('state', '!=', 'step2')]}"> 
          <field name="name_size" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="description_size" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="forme_size" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
          <field name="plate_size" attrs="{'invisible': [('state', '!=', 'step2')]}"/> 
        </group> 
       </group> 
       <group> 
        <group string="Book Edition" attrs="{'invisible': [('state', '!=', 'step3')]}"> 
          <field name="name_edition" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
        </group> 
        <group string="Book Binding" attrs="{'invisible': [('state', '!=', 'step3')]}"> 
          <field name="name_binding" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
        </group> 
        <group string="Cut Off" attrs="{'invisible': [('state', '!=', 'step3')]}"> 
          <field name="name_cut" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
          <field name="description_cut" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
          <field name="cutoff_size" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
        </group> 
        <group string="Paper Master" attrs="{'invisible': [('state', '!=', 'step3')]}"> 
          <field name="name_papermaster" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
          <field name="description_papermaster" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
          <field name="paper_type" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
          <field name="uom_papermaster" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
          <field name="gsm_papermaster" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
          <field name="std_cost_rate" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
          <field name="qty_in_kgs" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
          <field name="size_width" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
          <field name="size_height" attrs="{'invisible': [('state', '!=', 'step3')]}"/> 
        </group> 
       </group> 
       <group> 
        <group string="End Paper" attrs="{'invisible': [('state', '!=', 'step4')]}"> 
          <field name="name_end_paper" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
          <field name="category_end_paper" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
          <field name="size_end_paper" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
        </group> 
        <group string="Printing Code" attrs="{'invisible': [('state', '!=', 'step4')]}"> 
          <field name="description_code" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
          <field name="size_code" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
        </group> 
        <group string="Book Edge" attrs="{'invisible': [('state', '!=', 'step4')]}"> 
          <field name="name_book_edge" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
        </group> 
        <group string="Job Rate" attrs="{'invisible': [('state', '!=', 'step4')]}"> 
          <field name="name_jobrate" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
          <field name="binding" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
          <field name="size_binding_job_rate" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
          <field name="bind_variety" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
          <field name="rates" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
          <field name="addl_rate" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
          <field name="uptoforme" attrs="{'invisible': [('state', '!=', 'step4')]}"/> 
        </group> 
       </group> 
     </form> 
     </field> 
    </record> 

私はちょうどそれがクリック可能とテーブルの上にデータを保存する必要があります。 私はこの1つのようないくつかの解決策を見た:

<button string="Save" name="create" type="object"/> 

をしかし、それはない作品なので、任意のアイデアでしょうか?

EDIT

これは私の定義されたメソッドです。

@api.multi 
def save_data(self, vals): 
    # and here you use you wizard fields 
    self.name 
    self.date_production 
    self.type_prod 
    self.product_id 
    self.qty_available 
    self.isbn1 
    self.isbn2 
    self.isbn3 
    self.isbn4 
    self.isbn5 
    self.isbn6 
    self.isbn7 
    self.isbn8 
    #print_order = fields.One2many('bsi.print.order', 'production_orders', string="Print Order", copy=True) 
    self.print_order2 
    self.name_block 
    self.category 
    #self.other_fields 
    return (bsi_production_order, self).create(cr, uid, vals, context=context) 

しかし、それはこの私をスロー:

Traceback (most recent call last): 
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 546, in _handle_exception 
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 583, in dispatch 
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 319, in _call_function 
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\service\model.py", line 118, in wrapper 
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 316, in checked_call 
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 812, in __call__ 
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 412, in response_wrap 
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\web\controllers\main.py", line 944, in call_kw 
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw 
TypeError: create() takes exactly 2 arguments (5 given) 
+1

を保存する機能を定義する、あなたの 'bsi.production.order'モデルのPythonの側で' create'メソッドを定義していますか?それがうまくいかないとはどういう意味ですか?エラーはありますか? – travisw

+0

こんにちは、いいえ、実際には、このアプローチ(ボタンだけ)は機能すると答えていましたが、実際に必要なものを作成する方法がありましたが、スーパーを呼び出す必要があるかどうかはわかりません()もしそれがもっと簡単なのであれば...混乱しているかもしれません。 – NeoVe

+1

あなたはあなたが必要とする 'vals'を渡すことができれば、それをかなり基本的に保つことができると思います。 'create'メソッドは基本的に' super(your_model、self).create(vals) 'を返します。 – travisw

答えて

1

はフッターにボタンを追加し、あなたが最後に打ったとき、それを表示ステップ。

  <button string="Save" name="save_data" type="object"/> 

そして、あなたのウィザードの

 @api.multi 
     def save_data(self): 
       # and here you use you wizard fields 
       self.some_field 
+0

こんにちは、ありがとう、私はフィールドを追加し、最後に私は '戻り値(bsi_production_order、self).create(vals)'を書いていますが、'TypeError:create()は2つの引数(5が与えられます)何か案は? – NeoVe

+0

モデルにcreateメソッドを定義しましたか? – Cherif

+0

はい、確かに、私の質問を編集するつもりです – NeoVe

関連する問題