Odoo我想在向导中添加树形视图

时间:2019-02-20 07:09:36

标签: xml odoo odoo-11

我想在向导中添加树形视图。我尝试过这样:

<record id="view_immediate_transfer" model="ir.ui.view">
        <field name="name">xn_quotation_creation_wiz2</field>
        <field name="model">xn_quotation_creation_wiz</field>
        <field name="arch" type="xml">
            <form string="Warning">
                <group>
                 <field name = "xn_customer_id" />
                </group>
                <group>
                <tree editable = "top">
                    <group>
                        <field name="product"/>
                        <field name="qty"/>
                    </group>
                </tree>
                </group>

                <footer>
                    <button name="save_button" string="Save" type="object" class="btn-primary"/>                
                 </footer>
            </form>
        </field>

但是在树状视图中给出的字段就像表单视图一样显示。该怎么办..? (我想从产品主数据中填充此字段。) enter image description here

  

Python

class QuotationCreation2(models.TransientModel):
    _name = "xn_quotation_creation_wiz"

     xn_customer_id = fields.Many2one('res.partner',string = "Customer")
     product=fields.Many2one('product.product',string='Product')
     qty=fields.Integer(string='Quantity')

1 个答案:

答案 0 :(得分:1)

您的视图定义缺少要在向导中显示为树的相关字段,例如One2manyMany2many字段。

<field name="product_master">
  <tree editable = "top">
    <group>
      <field name="product"/>
      <field name="qty"/>
    </group>
  </tree>
</field>

瞬时模型与常规模型基本相同,不同之处在于瞬时模型在数据库中不是持久性的,因此可用于创建向导。对于tree中的任何form视图,您需要一个One2manyMany2many类型的关系。

class QuotationCreation2(models.TransientModel):
  _name = "xn_quotation_creation_wiz"

  xn_customer_id = fields.Many2one('res.partner',string = "Customer")
  product_master = fields.One2many('xn_quotation_creation_wiz.line','wiz_id')

class QuotationCreationLine(models.TransientModel):
  _name = "xn_quotation_creation_wiz.line"

  wiz_id = fields.Many2one('xn_quotation_creation_wiz.line')
  product=fields.Many2one('product.product',string='Product')
  qty=fields.Integer(string='Quantity')
相关问题