Odoo Я хочу добавить вид дерева внутри мастера - PullRequest
0 голосов
/ 20 февраля 2019

Я хочу добавить древовидное представление внутри моего мастера. Я пытался так:

<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 голосов
/ 20 февраля 2019

В вашем определении представления отсутствует соответствующее поле, которое вы хотите отобразить в виде дерева внутри мастера, например, поле One2many или Many2many.

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

Переходная модель в основном такая же, как и в обычномВ отличие от модели, временные модели не сохраняются в базе данных, поэтому используются для создания мастеров.Для любого tree представления в пределах form вам необходимо отношение типа One2many или Many2many.

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