向导与步骤空白页 - Odoo v8

时间:2017-08-23 06:05:09

标签: python openerp odoo-8

我正在创建一个带有Odoov8步骤的向导,这是我原来的表单视图:

   <record id="view_prod_order_form" model="ir.ui.view">
        <field name="name">bsi.production.order.form</field>
        <field name="model">bsi.production.order</field>
        <field name="arch" type="xml">
            <form string="Production Order">
            <div class="oe_title">
            <label for="name" class="oe_edit_only" />
            <h1>
                <field name="name" />
            </h1>
            </div>
            <sheet>
                <h1>
                    <field name="name" class="oe_inline" readonly="1"/>
                </h1>
                <group>
                    <group>
                      <field name="date_production"/>
                      <field name="product_id"/>
                      <field name="qty_available"/>
                      <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"/>
                      <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 string="Book Block">
                            <field name="name_block"/>
                            <field name="category"/>
                            <field name="language"/>
                            <field name="edition"/>
                            <field name="size"/>
                            <field name="book_block_textp"/>
                            <field name="n_pages_one_color"/>
                            <field name="two_color"/>
                            <field name="four_color"/>
                            <field name="total"/>
                            <field name="text_print_code"/>
                            <field name="book_block_adpaper"/>
                            <field name="adnl_n_pages_one_color"/>
                            <field name="adnl_two_color"/>
                            <field name="adnl_third_color"/>
                            <field name="adnl_four_color"/>
                            <field name="adnl_total"/>
                            <field name="adnl_text_print_code"/>
                            <field name="book_block_txtep"/>
                            <field name="n_of_end_pages"/>
                    </group>
                    <group string="Book Size">
                            <field name="name_size"/>
                            <field name="description_size"/>
                            <field name="forme_size"/>
                            <field name="plate_size"/>
                    </group>
                    <group string="Book Edition">
                            <field name="name_edition"/>
                    </group>
                    <group string="Book Binding">
                            <field name="name_binding"/>
                    </group>
                    <group string="Cut Off">
                            <field name="name_cut"/>
                            <field name="description_cut"/>
                            <field name="cutoff_size"/>
                    </group>
                    <group string="Paper Master">
                            <field name="name_papermaster"/>
                            <field name="description_papermaster"/>
                            <field name="paper_type"/>
                            <field name="uom_papermaster"/>
                            <field name="gsm_papermaster"/>
                            <field name="std_cost_rate"/>
                            <field name="qty_in_kgs"/>
                            <field name="size_width"/>
                            <field name="size_height"/>
                    </group>
                    <group string="End Paper">
                            <field name="name_end_paper"/>
                            <field name="category_end_paper"/>
                            <field name="size_end_paper"/>
                    </group>
                    <group string="Printing Code">
                            <field name="description_code"/>
                            <field name="size_code"/>
                    </group>
                    <group string="Book Edge">
                            <field name="name_book_edge"/>
                    </group>
                    <group string="Job Rate">
                            <field name="name_jobrate"/>
                            <field name="binding"/>
                            <field name="size_binding_job_rate"/>
                            <field name="bind_variety"/>
                            <field name="rates"/>
                            <field name="addl_rate"/>
                            <field name="uptoforme"/>
                    </group>
                </group>
            </sheet>
            </form>
        </field>
    </record>

我想要的是从一个向导调用此视图,包含步骤,因此每个步骤都可以填充每个'x'字段数量,这是我的向导代码:

def action_next1(self, cr, uid, ids, context=None):
  #your treatment to click  button next 
  #...
  # update state to  step2
  self.write(cr, uid, ids, {'state': 'step2',}, context=context)
  #return view
  return {
        'type': 'ir.actions.act_window',
        'res_model': 'bsi_production_order',
        'view_mode': 'form',
        'view_type': 'form',
        'res_id': this.id,
        'views': [(False, 'form')],
        'target': 'new',
         }

def action_next2(self, cr, uid, ids, context=None):
  #your treatment to click  button next 
  #...
  # update state to  step2
  self.write(cr, uid, ids, {'state': 'step3',}, context=context)
  #return view
  return {
        'type': 'ir.actions.act_window',
        'res_model': 'bsi_production_order',
        'view_mode': 'form',
        'view_type': 'form',
        'res_id': this.id,
        'views': [(False, 'form')],
        'target': 'new',
         }

def action_next3(self, cr, uid, ids, context=None):
  #your treatment to click  button next 
  #...
  # update state to  step2
  self.write(cr, uid, ids, {'state': 'step4',}, context=context)
  #return view
  return {
        'type': 'ir.actions.act_window',
        'res_model': 'bsi_production_order',
        'view_mode': 'form',
        'view_type': 'form',
        'res_id': this.id,
        'views': [(False, 'form')],
        'target': 'new',
         }

def action_previous1(self, cr, uid, ids, context=None):
  #your treatment to click  button previous 
  #...
  # update state to  step1
  self.write(cr, uid, ids, {'state': 'step1',}, context=context)
  #return view
  return {
        'type': 'ir.actions.act_window',
        'res_model': 'bsi_production_order',
        'view_mode': 'form',
        'view_type': 'form',
        'res_id': this.id,
        'views': [(False, 'form')],
        'target': 'new',
         }

def action_previous2(self, cr, uid, ids, context=None):
  #your treatment to click  button previous 
  #...
  # update state to  step1
  self.write(cr, uid, ids, {'state': 'step2',}, context=context)
  #return view
  return {
        'type': 'ir.actions.act_window',
        'res_model': 'bsi_production_order',
        'view_mode': 'form',
        'view_type': 'form',
        'res_id': this.id,
        'views': [(False, 'form')],
        'target': 'new',
         }

def action_previous3(self, cr, uid, ids, context=None):
  #your treatment to click  button previous 
  #...
  # update state to  step1
  self.write(cr, uid, ids, {'state': 'step3',}, context=context)
  #return view
  return {
        'type': 'ir.actions.act_window',
        'res_model': 'bsi_production_order',
        'view_mode': 'form',
        'view_type': 'form',
        'res_id': this.id,
        'views': [(False, 'form')],
        'target': 'new',
         }

这是各自的观点:

   <record id="view_wizard_prod_order_form" model="ir.ui.view">
        <field name="name">bsi.production.order.form</field>
        <field name="model">bsi.production.order</field>
        <field name="arch" type="xml">
            <form string="Production Order">
              <field invisible="1" name="state" />
                <group states="step1">
                  <group>
                    <group>
                      <field name="date_production"/>
                      <field name="product_id"/>
                      <field name="qty_available"/>
                      <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"/>
                      <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 states="step2">
                    <group string="Book Block">
                            <field name="name_block"/>
                            <!--<field name="description"/>-->
                            <field name="category"/>
                            <field name="language"/>
                            <field name="edition"/>
                            <field name="size"/>
                            <field name="book_block_textp"/>
                            <field name="n_pages_one_color"/>
                            <field name="two_color"/>
                            <field name="four_color"/>
                            <field name="total"/>
                            <field name="text_print_code"/>
                            <field name="book_block_adpaper"/>
                            <field name="adnl_n_pages_one_color"/>
                            <field name="adnl_two_color"/>
                            <field name="adnl_third_color"/>
                            <field name="adnl_four_color"/>
                            <field name="adnl_total"/>
                            <field name="adnl_text_print_code"/>
                            <field name="book_block_txtep"/>
                            <field name="n_of_end_pages"/>
                    </group>
                    <group string="Book Size">
                            <field name="name_size"/>
                            <field name="description_size"/>
                            <field name="forme_size"/>
                            <field name="plate_size"/>
                    </group>               
                </group>

                <group states="step3">
                    <group string="Book Edition">
                            <field name="name_edition"/>
                    </group>
                    <group string="Book Binding">
                            <field name="name_binding"/>
                    </group>
                    <group string="Cut Off">
                            <field name="name_cut"/>
                            <field name="description_cut"/>
                            <field name="cutoff_size"/>
                    </group>
                    <group string="Paper Master">
                            <field name="name_papermaster"/>
                            <field name="description_papermaster"/>
                            <field name="paper_type"/>
                            <field name="uom_papermaster"/>
                            <field name="gsm_papermaster"/>
                            <field name="std_cost_rate"/>
                            <field name="qty_in_kgs"/>
                            <field name="size_width"/>
                            <field name="size_height"/>
                    </group>              
                </group>

                <group states="step4">
                    <group string="End Paper">
                            <field name="name_end_paper"/>
                            <field name="category_end_paper"/>
                            <field name="size_end_paper"/>
                    </group>
                    <group string="Printing Code">
                            <field name="description_code"/>
                            <field name="size_code"/>
                    </group>
                    <group string="Book Edge">
                            <field name="name_book_edge"/>
                    </group>
                    <group string="Job Rate">
                            <field name="name_jobrate"/>
                            <field name="binding"/>
                            <field name="size_binding_job_rate"/>
                            <field name="bind_variety"/>
                            <field name="rates"/>
                            <field name="addl_rate"/>
                            <field name="uptoforme"/>
                    </group>          
                </group>

      <footer states="step1">
        <button name="action_next1" string="Next" type="object" />
        <button string="Cancel" class="oe_link" special="cancel"/>
      </footer>

      <footer states="step2">
        <button name="action_previous1" string="Previous" type="object" />
        <button string="Cancel" class="oe_link" special="cancel"/>
      </footer>   
      <footer states="step2">
        <button name="action_next2" string="Next" type="object" />
        <button string="Cancel" class="oe_link" special="cancel"/>
      </footer>

      <footer states="step3">
        <button name="action_previous2" string="Previous" type="object" />
        <button string="Cancel" class="oe_link" special="cancel"/>
      </footer>   
      <footer states="step3">
        <button name="action_next3" string="Next" type="object" />
        <button string="Cancel" class="oe_link" special="cancel"/>
      </footer>

      <footer states="step4">
        <button name="action_previous3" string="Previous" type="object" />
        <button string="Cancel" class="oe_link" special="cancel"/>
      </footer>   
        </form>
        </field>
    </record>

现在,如果我想打开这个向导视图,它只显示一个空的白色表单,同样,非向导视图也会发生同样的事情,这是菜单项和操作

对于向导:

 <record id="action_prod_order" model="ir.actions.act_window">
        <field name="name">Production Order (Wizard)</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">bsi.production.order</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
       <field name="view_id" ref="view_wizard_prod_order_form"/>
       <field name="target">new</field>
 </record>
 <menuitem action="action_prod_order" id="menu_mrp_production_order_action_1"
        parent="mrp.menu_mrp_manufacturing" />

表单视图:

 <record id="mrp_production_order_action_2" model="ir.actions.act_window">
        <field name="name">Production Orders</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">bsi.production.order</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form,calendar,graph,gantt</field>
        <field name="view_id" eval="False"/>
        <field name="context">{}</field>
        <field name="help" type="html">
          <p class="oe_view_nocontent_create">
            Click to create a production order. 
          </p><p>
            A production order...
          </p><p>
            Production orders are usually proposed automatically based
            on customer requirements or automated rules like the minimum
            stock rule.
          </p>
        </field>
</record>
<menuitem action="mrp_production_order_action_2" id="menu_mrp_production_order_action_2"
        parent="mrp.menu_mrp_manufacturing" />

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我认为问题在于你的行动

         <field name="view_mode">tree,form</field>

您正在弹出窗口中显示您的记录,这在odoo中是不允许的。一般来说,树只是一个简单的裸露,当你点击它时,记录会被加载,这就是odoo 10。

只需使用表单模式

并确保您的状态字段也具有默认值。