Hello I'm trying to pass my active_id from my res.partner to the JS. But no luck. I tried with dataset active_id but it's always undefined. and i can't find any solution in the docs. Here's my JS File:
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):
@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'
}
yeah, you can get the current id by using:
var dataset = this.dataset;
var active_id = dataset.ids[dataset.index];
Python
@api.model
def _get_active_id(self):
return self._context.get('active_id')
deploy_config_id = fields.Many2one('res.partner', string='Customer', required=True, default=_get_active_id)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.