Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

javascript - 在JavaScript Odoo 10中获取active_id(Get active_id in javascript Odoo 10)

Hello I'm trying to pass my active_id from my res.partner to the JS.

(您好,我正在尝试将我的active_id从我的res.partner传递给JS。)

But no luck.

(但是没有运气。)

I tried with dataset active_id but it's always undefined.

(我尝试使用数据集active_id,但始终未定义。)

and i can't find any solution in the docs.

(而且我在文档中找不到任何解决方案。)

Here's my JS File:

(这是我的JS文件:)

odoo.define('melax_category.my_dialog_partner', function(require){"user strict";
  var core = require('web.core');
  var session = require('web.session');
  var qweb = core.qweb;
  var mixins = core.mixins;
//   var Widget = require('web.Widget');
  var Model = require('web.Model');
  var Dialog = require('web.Dialog');
  var model_category = new Model('res.partner');
//   var dataset = this.dataset;
//   var active_id = dataset.ids[dataset.index];

function ActionBuildTreeBuyerPartner(parent, action){
    console.log(this.id)
    var dialog = new Dialog(document.body, {
                    title: "Categories Web Acheteur",
                    subtitle: '<input id="search-tree-buyer" type="text">',
                    size: 'big',
                    $content: '
                               <div id="tree-buyer-container"></div>
                               ',
                });

    TREE = $('#tree-buyer-container')
    dialog.open();
    DESTROY_TREE($('#tree-buyer-container'))
    BUILD_TREE_PARTNER_MODE(model_category, $('#tree-buyer-container'))

}

function ActionBuildTreeSellerPartner(parent, action){
    var dialog = new Dialog(document.body, {
                    title: "Categories Web Vendeur",
                    // subtitle: "Tree Builder Partner Sub Title!",
                    size: 'big',
                    $content: '<div id="tree-seller-container"></div>',
                });

    TREE = $('#tree-seller-container')
    dialog.open();
    // DESTROY_TREE($('#tree-seller-container'))
    // BUILD_TREE_PARTNER_MODE(model_category, $('#tree-buyer-container'))

}
    core.action_registry.add("build_tree_buyer_partner", ActionBuildTreeBuyerPartner);
    core.action_registry.add("build_tree_seller_partner", ActionBuildTreeSellerPartner);
});

and here's my python file where for example i'm trying to pass my active_id(self.id):

(这是我的python文件,例如,我正在尝试传递我的active_id(self.id):)

@api.multi
def build_tree_buyer_partner(self):
    _logger.error(self)
    # My active Id
    _logger.error(self.id)       
    return {
        'type':'ir.actions.client',
        'tag': 'build_tree_buyer_partner'
    }
  ask by Ahmed Hached translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

ayou can get the current id by using:

(您可以使用以下方法获取当前ID:)

var dataset = this.dataset;
var active_id = dataset.ids[dataset.index];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...