关于复制原有view xml 添加字段问题
-
写成addons的组件,维护起来方便
问题:如何复制一个对象中的view xml(openerp中原有对象)并添加一个字段
例如.
我想在warehouse中的warehouse managenment中增加一个menu item 点击后进入像delivery orders一样的界面,字段一致,search tool bar也一样,但是在这个tree当中添加一个test的字段,只在这个tree中显示
界面开发步骤:
1.在stock.picking中增加一个test字段
2.在stock.picking中新建一个view,编辑复制stock.picking.out.tree中内容 取名叫customer_test_view, 并把新加的test字段写在后面
3.创建Window Actions ,需要search tool bar 所以Search View Ref:选择 stock.picking.out.search 然后在view ordering中new一个新的,选择我们前面新建的customer_test_view
4.创建menu item ,parent menu 关联Warehouse,Actions选择前面我们建的。
基本就能完成这一需求
组建形式开发:
stock.py
from osv import fields, osv
class stock_picking(osv.osv):
_name = "stock.picking"
_inherit = "stock.picking"
_columns = {
'dispatching' : fields.many2one('hr.employee','Dispatching')
}
stock_picking()
stock_vew.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="stock_view_picking_out_tree_inherited">
<field name="name">stock.view.picking.out.tree.inherited</field>
<field name="model">stock.picking</field>
<field name="type">tree</field>
<field name="inherit_id" ref="stock.view_picking_out_tree"/>
<field name="arch" type="xml">
<field name="state" position="after">
<field name="dispatching"/>
</field>
</field>
</record>
<act_window id="action_dispatching_picking" name="Dispatching"
src_model="stock.picking" res_model="stock.picking"
view_type="tree" view_mode="tree" view_id="stock.view_picking_out_tree" />
<menuitem action="action_dispatching_picking" id="menu_stock_picking_dispatching"
parent="stock.menu_stock_warehouse_mgmt" sequence="100" />
</data>
</openerp>
代码结束
现在是改了这个,默认的stock.view_picking_out_tree也变了。
:-[