【发布时间】: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