新页面,简单的tree视图写法

时间:2023-12-15 14:53:14

.xml文件

<?xml version="1.0"?>
<openerp>
<data>
<!--Tree view-->
<record id="view_history_order_tree" model="ir.ui.view">
<field name="name">history.order.tree</field>
<field name="model">history_order</field>
<field name="arch" type="xml">
<tree string="History order">
<field name="product_id"/>
<field name="material"/>
<field name="spec"/>
<field name="product_uom"/>
<field name="price"/>
<field name="product_qty"/>
<field name="total"/>
<field name="cust_order_no"/>
<field name="date_planned"/>
<field name="memo"/>
<field name="requirement_text"/>
<field name="packing_type1"/>
<field name="state"/>
</tree>
</field>
</record>
<!--action-->
<record id="action_view_history_order_tree" model="ir.actions.act_window" >
<field name="name">历史订单</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">history_order</field>
<field name="view_mode">tree</field>
</record>
<!--menu-->
<menuitem action="action_view_history_order_tree" id="menu_action_view_history_order_tree" sequence="120" parent="base.menu_sales"/>
</data>
</openerp> .py文件
# -*- coding: utf-8 -*- #
##############################################################################
#
# author: hsx
# Copyright (C) 2017 odooinfo.com
#
#
##############################################################################
from openerp.osv import fields,osv
from openerp import tools
import openerp.addons.decimal_precision as dp class history_order(osv.osv):
_name="history_order"
_description="history order line "
_columns={
'product_id':fields.many2one('product_product',u'产品'),
'material': fields.related('product_id', 'material',relation='product.product', type="char", string=u'品名/材质',readonly=True,),
'spec': fields.related('product_id', 'cust_spec',relation='product.product', type="char", string=u'规格',readonly=True,),
'product_uom': fields.many2one('product.uom',u'单位'),
'price':fields.float(u'单价',digits=(6,3)),
'product_qty':fields.float(u'数量', digits_compute= dp.get_precision('Product UoS')),
'total':fields.float(u'金额'),
'date_planned':fields.date(u'交期'),
'cust_order_no':fields.char(u'客户单号'),
'memo':fields.char(u'备注'), 'requirement_text':fields.text(string=u"要求"),
'packing_type1':fields.selection([(1,u'隔板'),(2,u'泡沫')],string=u'包装方式',),
'state':fields.selection([
('draft',u'草稿'),
('confirm',u'确认订单'),
('cancel',u'取消订单'),]
,u'状态', readonly=True, copy=False, select=True), } 在init和openerp里分别加
'history_order.xml',
和import history_order