如何在odoo中像销售订单行一样显示

how to make display like sales order lines in odoo

我是odoo开发的新手,谁能告诉我如何在odoo中制作如图sales order line中的显示,谢谢

这是 Odoo 中的 One2many 字段 要制作这样的你必须添加一些这样的东西:

在python代码中

from openerp import fields,models
class sale_order(models.Model):
     _inherit='sale.order'
     field_One2many=field.One2many('sale.order.line','order_id','Order')
sale_order()
class sale_order_line(models.model):
     _inherit='sale.order.line'
     order_id=fields.Many2one('sale.order','Order')
sale_order_line()

并且您的 Xml 文件中有一些视图代码,例如:

<record model="ir.ui.view" id="view_test">
            <field name="name">sale.order.form</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale_order.form_view_id"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="pass of position" position="the postion">
                        <field name='field_One2many'>
                          <tree>
                             <!-- Your Fields in the view -->
                          </tree>
                      </field>
                    </xpath>
                </data>
            </field>
        </record>

完成