在odoo 12中,从java脚本self调用python方法为null



如果我从XML调用按钮上的python方法,我有一个方法,如下所示:

<button id="button_update_question" name="testquestion1" type="object" string="Update Question" class="oe_highlight" />

给我的自我是:自我:调查。调查(1,(

如果我试图从javascript中调用相同的python方法:

this._rpc({
model: 'survey.survey',
method: 'testquestion1',
args: [{
id: id,
question: question,
type: type,
}],  
});

它给我的自我是:self:survey.survey((

我的问题是,如果从javascript调用python方法,为什么self没有任何值。如何实现这一点。任何人,请帮帮我

提前谢谢。

更新测试问题1:的签名

@api.multi
def testquestion1(self,vals):
print('self:',self)
id1 = vals['id']        
type_val = vals['type']  
update_data = {}
update_data = {
'question': vals['question'],
}
exiting_data = self.env['survey.question'].search([('id','=',id1)]).write(update_data)

尝试将ids传递给testquestion1方法。

this._rpc({
model: 'survey.survey',
method: 'testquestion1',
args: [event.data.record.res_ids,
{
id: id,
question: question,
type: type,
}],
});

相关内容

最新更新