如何使用odoo-xmlrpc库更新Odoo-erp中的数量?

时间:2018-11-09 12:48:38

标签: javascript node.js odoo

im试图使用nodejs创建一个javascript函数,该函数使用odoo-xmlrpc库在odoo在线数据库中执行付款。为此,我必须以某种方式减少产品数量或创建库存移动。

我找到了这段代码,但没有正常工作:

var data = [{"__metadata":{"id":"bba6f593-167d-4f14-85cf-3b69288f5434","etag":"\"1\"","type":"SP.Data.PollLogListItem"},"PollId":1,"Answer":"Option3"},{"__metadata":{"id":"925dceaf-250f-43c1-be73-9972b0a34750","etag":"\"2\"","type":"SP.Data.PollLogListItem"},"PollId":1,"Answer":"Option4"},{"__metadata":{"id":"85c73abb-a565-4e2c-b74c-1883c15e2eb6","etag":"\"1\"","type":"SP.Data.PollLogListItem"},"PollId":1,"Answer":"Option3"}];

function getCount(pollLog){
  const answersCount = pollLog.reduce(function (r, o) {
    var answer = o["Answer"];
    
    if (!r[answer]) {
      r[answer] = 1
    } else {
      r[answer] += 1;
    }
    
    return r;
  }, {});
  
  return Object.keys(answersCount).map(function(key) {
    return {"Answer":key, "Count": answersCount[key]+""}
  });
}

alert(JSON.stringify(getCount(data)));

也许有人可以帮助我:)

0 个答案:

没有答案