[英]Odoo v12 javascript double rpc call problem
I have created the class crm.dashboard.py have 2 methods, I want to call them in JS, the first controller works but when I call the second I get this error:我已经创建了 class crm.dashboard.py 有 2 个方法,我想在 JS 中调用它们,第一个 controller 有效,但是当我调用第二个时,我得到了这个错误:
AttributeError: type object 'crm.dashboard' has no attribute 'get_test_info'
Any solution please?请问有什么解决办法吗?
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;
});
}
}
Code of the method:方法代码:
@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
The message says "I don't find the method get_test_info in model crm.dashboard".消息显示“我在 model crm.dashboard 中找不到方法 get_test_info”。
The problem isn't your JS but "your" python file.问题不在于您的 JS,而在于“您的” python 文件。
Possible error:可能的错误:
__init__.py
__init__.py
中导入__init__.py
of your module.__init__.py
中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.