[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>
Odoo 开发与实施交流
No decsciption available
2.3k
Topics
10.4k
Posts
-
有类似K3的财务报表吗
Watching Ignoring Scheduled Pinned Locked Moved0 Votes2 Posts2k Views -
在listview的web视图上增加一个按钮的问题
Watching Ignoring Scheduled Pinned Locked Moved0 Votes14 Posts16k Views -
Odoo 8 新建用户和其它操作都显示loading still loading
Watching Ignoring Scheduled Pinned Locked Moved0 Votes2 Posts1k Views -
Odoo8.0_form视图验证控件
Watching Ignoring Scheduled Pinned Locked Moved0 Votes2 Posts2k Views -
One2many字段可以使用树形么?
Watching Ignoring Scheduled Pinned Locked Moved0 Votes4 Posts3k Views -
卓忆原创视频:Odoo培训现场录制01:Odoo界面介绍
Watching Ignoring Scheduled Pinned Locked Moved0 Votes2 Posts2k Views -
产品搜索,如何搜索产品的属性值,比如:iphone 5s 颜色:红色
Watching Ignoring Scheduled Pinned Locked Moved0 Votes3 Posts4k Views -
请教如何qweb报表打印如何分页?
Watching Ignoring Scheduled Pinned Locked Moved0 Votes2 Posts2k Views -
网友:Odoo9.0里面新建销售订单的时候什么情况会是弹窗?
Watching Ignoring Scheduled Pinned Locked Moved0 Votes2 Posts2k Views -
[9.0]怎么从代码中弹出一个对话框
Watching Ignoring Scheduled Pinned Locked Moved0 Votes3 Posts2k Views -
Web开发中怎么处理多参数
Watching Ignoring Scheduled Pinned Locked Moved0 Votes7 Posts5k Views -
新人贴:有哪位大侠成功安装OpenLabs的magento integration模块呀(已解决)
Watching Ignoring Scheduled Pinned Locked Moved0 Votes6 Posts9k Views -
WebService能发到odoo里面吗?怎么放?
Watching Ignoring Scheduled Pinned Locked Moved0 Votes2 Posts2k Views -
请问怎么启动webService
Watching Ignoring Scheduled Pinned Locked Moved0 Votes4 Posts3k Views -
关于客户订单通知问题
Watching Ignoring Scheduled Pinned Locked Moved0 Votes3 Posts3k Views -
商品导入时,字段“内部货号”无法导入,其他的都正常,请教各位高手。
Watching Ignoring Scheduled Pinned Locked Moved0 Votes3 Posts2k Views -
【已解决】关于多仓库,每次采购入库都是在默认的仓库,如何设置不同类型的产品按对应的仓库收货
Watching Ignoring Scheduled Pinned Locked Moved0 Votes4 Posts3k Views -
关于Purchase Supplied Goods模块
Watching Ignoring Scheduled Pinned Locked Moved0 Votes2 Posts2k Views -
关于采购模块的二级审核
Watching Ignoring Scheduled Pinned Locked Moved0 Votes5 Posts4k Views -
卓忆翻译(英中对照):Odoo9工作流中的改变:销售和采购取消工作流的原因
Watching Ignoring Scheduled Pinned Locked Moved0 Votes2 Posts2k Views