【问题标题】:Odoo v12 javascript double rpc call problemOdoo v12 javascript双rpc调用问题
【发布时间】:2021-06-02 11:45:12
【问题描述】:

我已经创建了 crm.dashboard.py 类有 2 个方法,我想在 JS 中调用它们,第一个控制器可以工作,但是当我调用第二个时,我得到了这个错误:

AttributeError: type object 'crm.dashboard' has no attribute 'get_test_info'  

请问有什么办法吗?

init: function(parent, context) {
    this._super(parent, context);
    var crm_data = [];
    var test_data = [];

    var self = this;
    if (context.tag == 'crm_dashboard.dashboard') {
        self._rpc({
            model: 'crm.dashboard',
            method: 'get_crm_info',
        }, []).then(function(result){
            self.crm_data = result[0]
        })

        self._rpc({
            model: 'crm.dashboard',
            method: 'get_test_info',
        }, []).then(function(result){
            self.test_data = result[0]
        })


        .done(function(){
            self.render();
            self.href = window.location.href;
        });


    }
}

方法代码:

@api.model
def get_test_info(self):

    expected_revenue = 0
    obj_test = self.env['sale.order'].sudo().search([])
    amount_total = 0
    for sale in obj_test:
        amount_total = round(amount_total + (sale.amount_untaxed + sale.amount_tax))
    test_details = [{}]
    if test_details:
        data = {
            'amount_total': amount_total,

        }

        test_details[0].update(data)

        print("TEST________________", test_details)
    return test_details

【问题讨论】:

  • 安装了包含python代码的模块?

标签: javascript odoo rpc


【解决方案1】:

消息说“我在模型 crm.dashboard 中找不到方法 get_test_info”。

问题不是你的 JS,而是“你的”python 文件。

可能的错误:

  • 具有模型“crm.dashboard”和方法“get_test_info”的 python 文件未导入 __init__.py
  • 文件夹模型未导入您模块的__init__.py
  • 缺少依赖项(暗示未安装)
  • 方法名称不同。

【讨论】:

  • 嗨,谢谢你的回答,但是我检查了python文件,没有问题
  • 你能用包含 get_test_info 方法的 py 文件更新你的第一条消息吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-24
  • 2021-03-02
  • 2020-12-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多