是否有可能从网页中获取数据到Odoo,以及如何实现?
例如,从某个网页获取名称、地址和国家到res.partner模块。
发布于 2017-04-24 12:11:56
从奥多
如果你说的是odoo网站。
您必须创建网站页面的模板视图,使用JSONRPC和odoo (python)创建javascript。
在第一次,您需要用按钮创建一个模板视图来发送数据,该按钮将调用javascript方法。
你的JS档案:
odoo.define('your_module.your_website', function (require) {
"use strict";
// Odoo class to calling an url with JSONRPC
var ajax = require('web.ajax');
$(this).on("click", ".my_button", function () {
/// Call URL /update_partner with jsonRpc with attribute name, address, country
ajax.jsonRpc("/update_patner", 'call', {'name': name,'address': address, 'country':'country'})
.then(function (data) {
// Action after update
});
}
}你的python文件。
from odoo import http
class YourController(http.Controller):
@http.route(['/update_partner'], type='json', auth="public", methods=['POST'], website=True)
def update_partner(self, name, address, country, **kw):
http.request.env['res.partner'].write({'name':name,'address':address, 'country':country})
return {'result':True'}来自其他网站的
如果您想更新合作伙伴从over网站,您可以使用这个文件的odoo。
https://stackoverflow.com/questions/43583515
复制相似问题