Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

External API xmlrpc error: KeyError: 'report_options'

形象
odoo
2 注释
形象
丢弃
形象
odoo
-

Test

形象
odoo
-


const contextParam = {
'context': {
'report_options': {
'date': {
'date_from': 'YYYY-MM-DD',
'date_to': 'YYYY-MM-DD'
},
'account_type_aml_sign': -1
}
}
}

Unfortunately, the library async-odoo-xmlrpc does not support the extra paramater. A PR has been opened to add this in, but at the time of writing it is not yet merged.
I used the library xmlrpc, on which async-odoo-xmlrpc is based, directly to get the request to work in nodeJS, like so:

client.methodCall(
'execute_kw',
[db, uid, password, 'account.aged.receivable', 'search_read', [[]], contextParam],
(err, val) => {
// Handle response here
}

2 答案
0
形象
odoo
最佳答案

That's because account.aged.receivable inherits the account.aged.partner (i.e., account_aged_partner_balance) model which in turn requires context values to query the data for the report.

Inspecting the source code for 'account_aged_partner_balance' shows that this method '_get_sql'  needs at least:

  • options['date']['date_to']
  • options['filter_account_type']

For Odoo RPC you can set the context values (see also https://stackoverflow.com/questions/46586281/alter-odoo-xmlrpc-context-to-use-a-specific-language):

odoo.execute_kw(
'account.aged.receivable',
'search_read',
[[]],
{
'context': {
'report_options': {
'data': {
'date_to': value
},
'filter_account_type': 'receivable',
}
}
}
); 

I haven't tested this, but I hope it helps.

形象
丢弃
0
形象
odoo
最佳答案

@jort, indeed, that does the trick, thanks!

形象
丢弃