【问题标题】:How to send parameters from JS function to python mthod in odoo?如何将参数从JS函数发送到odoo中的python方法?
【发布时间】:2018-03-22 09:55:07
【问题描述】:

这是调用 Python 方法的 JS 行

model_obj.call(FunctionToBeCalled,active_id,{context:self.dataset.context}) 

这是我的python方法,

@api.multi
def delete_client_analysis_profile(self):
    print 'self',self
    query = "delete from olims_analysis_profile_olims_client_rel where olims_analysis_profile_id in("+\
        ",".join(str(record.id) for record in self)+")"

    self.env.cr.execute(query)

我无法在我的 python 方法中获得active_id。有人可以帮忙吗?

【问题讨论】:

    标签: javascript python odoo-9


    【解决方案1】:

    要从js 调用您的方法,请使用:

    new instance.web.Model("your.model")
    .call( "delete_client_analysis_profile", [[active_id]])
        .then(function (result) {
            // do something with result
    });
    

    那么你只需要操纵self

    【讨论】:

      猜你喜欢
      • 2016-01-13
      • 2020-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-04
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多