[quote author=Smile佳佳 link=topic=14531.msg32198#msg32198 date=1461296520][quote author=开阖-静静 link=topic=14531.msg31382#msg31382 date=1447298909]直接include listview就好了。instance.web.ListView.include({ load_list: function () { var self = this; this._super.apply(this, arguments); var b_length= self.__parentedParent.$el.find('.ok_bn').length; if(b_length ==0 && self.model=="res.partner"){ //通过获取this中的对象信息进行分析最终确定在那个地方加按钮。 console.log(self.$buttons[0].firstChild.className!="oe_button ok_bn"); console.log(+b_length<=0+"ok_bnok_bnok_bnok_bnok_bnok_bnok_bn"); var button = $("服务"); root=self.$el.parents(); button.prependTo(root.find('.oe_list_buttons')); this.$buttons.on('click', '.ok_bn', function() { self.do_action({ type: 'ir.actions.act_window', res_model: "product.product", res_id: 1, views: [[false, 'form']], target: 'current', context:"", }, { on_reverse_breadcrumb: function () { self.reload(); } }); }); } }, });但是不推荐这么做。不符合odoo的思想。有旭哥(http://odoo.nbzx.me) 找到一个一个好方法。(推荐使用) <record id="action_purchase_need" model="ir.actions.act_window"> <field name="name">采购 </field> <field name="res_model">purchase.need</field> <field name="view_type">form</field> <field name='view_mode'>tree_purchase_need</field> <field name="view_id" ref="purchase_need_tree"/> </record> instance.web.views.add('tree_purchase_need', 'instance.web.dftg_ext.NeedListView'); instance.web.dftg_ext.NeedListView = instance.web.ListView.extend({ init: function() { var self = this; this._super.apply(this, arguments); this.on('list_view_loaded', this, function() { if(self.__parentedParent.$el.find('.oe_purchase_need').length == 0){ var button1 = $("<button type='button' class='oe_button oe_purchase_need'>刷新采购需求</button>") .click(this.proxy('do_refresh_action')); self.__parentedParent.$el.find('.oe_list_buttons').append(button1); } }); }, do_refresh_action: function () { var self = this; var action_manager = new instance.web.ActionManager(self); return action_manager.do_action('dftg_ext.action_purchase_need_refresh_wizard', { on_close: function () { self.do_search(self.last_domain, self.last_context, self.last_group_by); } }); }, //重载列表数据 do_search: function(domain, context, group_by) { var self = this; this.last_domain = domain; this.last_context = context; this.last_group_by = group_by; this.old_search = _.bind(this._super, this); return self.old_search(new instance.web.CompoundDomain(self.last_domain), self.last_context, self.last_group_by); }, });[/quote]因为我是对一个对象写多个不同的视图,我在图一中这样指定view_id,没有找到,所以我又在下面按图二的方式又指定了一下,按钮就不显示了,请问这个怎么解决???[/quote]除了上楼静静的方法,还有一个方法,在action中添加<field name="context">{'tree_view_ref': '包名.视图id'}</field>