客户端Web - 如何获取当前记录的ID在任何时间 [英] client web - how to get current record id at any time

查看:143
本文介绍了客户端Web - 如何获取当前记录的ID在任何时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在\"different基于工作流状态的权限问题,但我与它似乎不可能得到'随时'这是必要的,以获取该对象的权限当前对象的id的事实挣扎。什么我的意思是,我设法从客户端状态<一个得到它href=\"http://benalman.com/$c$c/projects/jquery-bbq/docs/files/jquery-ba-bbq-js.html#jQuery.bbq.getState\"相对=nofollow>以下jQuery的烧烤文档喜欢的:

I'm trying to work on the "different permissions based on workflow state" issue but I'm struggling with the fact that it seems impossible to get the id of the current object 'at any time' that is necessary in order to get the permission of that object. What I mean is that I manage to get it from the client state following jquery bbq docs like:

$.bbq.getState().id

但看起来这是可行的只有在一个完整的页面加载。

BUT it looks like this is doable only AFTER a complete page load. I investigated this by placing some alert in the main view events, like:

openerp.web.PageView = openerp.web.PageView.extend({
    on_loaded: function(data) {
        this._super(data);
        alert('page load ' + $.bbq.getState().id);
    },
    do_show: function() {
        this._super();
        alert('page show ' + $.bbq.getState().id);
    },
    reload: function() {
        this._super();
        alert('page reload ' + $.bbq.getState().id);
    },
    on_record_loaded: function(record) {
        this._super(record);
        alert('record loaded ' + $.bbq.getState().id);
    }
});

和我发现,当你打开网页视图(通过点击搜索视图中的项目,例如)你的总是的不确定。

and I found that when you open the page view (by clicking on an item in a search view, for instance) you get always "undefined".

然后,你把它分为重载和on_record_loaded从一个物体传递到另一个使用分页导航时。然后,你再错过它,当你点击编辑按钮。

Then, you get it into "reload" and "on_record_loaded" when passing from an object to another using paged navigation. And then, you miss it again when you click on the "edit" button.

在表单视图我顺利地拿到了它的仅一号负载的,因为它似乎有些缓存原地。所以,如果我把一个PDB到Web客户端的fields_view_get,我这样做成表格init_view

In the form view I successfully got it only on the 1st load because it seems that some caching is in-place. So that, if I place a pdb into web client's fields_view_get and I do this into the form "init_view":

var ids = [];
if ($.bbq.getState().id){
    ids = [parseInt($.bbq.getState().id)];
}
console.log(ids);
return this.rpc("/web/view/load", {
    "model": this.model,
    "view_id": this.view_id,
    "view_type": "form",
    toolbar: this.options.sidebar,
    context: context,
    ids: ids,
    }, this.on_loaded);

我明白了只有在页面被加载的第1次。同样的,如果我从IDS发生

I get it only the 1st time that the page gets loaded. The same happen if I take ids from

this.dataset.ids

我看的任何地方为核心的网络模块和I不能找到这个合适的API,它看起来怪异的(首先对数据集),我们没有获取有道/对当前记录的工作/秒。即使是背景和会议没有有关的任何信息。

I looked anywhere at the core web module and I can't find a proper API for this and it looks weird (above all on dataset) that we don't have a proper way for getting/working on the current record/s. Even the context and the session do not have any information about that.

也许我本应该存储到1日负荷的观点本身...

Probably I should store this into the view itself on 1st load...

先谢谢您的任何指针。

推荐答案

尝试:

this.view.datarecord.id

this.view.datarecord.id

7的OpenERP形式的看法:
使用谷歌浏览调试

OpenERP 7 in form view: debugged using google chrome

这篇关于客户端Web - 如何获取当前记录的ID在任何时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆