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

Odoo I want to add a tree view inside a wizard

我想在我的 wizard.I 中添加一个树视图,试过这样:

<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>

但是树视图中给出的字段显示为一个表单 view.What 要做..? (我想从 product master 填充这个字段。)

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')

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

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

瞬态模型与常规模型基本相同,区别在于瞬态模型不持久存在于数据库中,因此用于创建向导。对于 form 中的任何 tree 视图,您需要 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')