项目作者: BMKeros

项目描述 :
Tools for development in web for odoo
高级语言: JavaScript
项目地址: git://github.com/BMKeros/odoo-webkit.git
创建时间: 2018-04-13T14:07:55Z
项目社区:https://github.com/BMKeros/odoo-webkit

开源协议:

下载


odoo-webkit Build Status

Tools for development in web for odoo

Installing

Using npm:

  1. $ npm install odoo-webkit

Using yarn:

  1. $ yarn add odoo-webkit

Example

  1. import { Model } from 'odoo-webkit';
  2. const ResUsers = new Model('res.users');
  3. //Create new user
  4. ResUsers.create({ name: 'testing' }).then(console.log);
  5. //Search users
  6. ResUsers.filter(['email', 'ilike', '@odoo.com']).get().then(console.log);
  7. //Update user
  8. ResUsers.write([1], { email: 'testing@odoo.com' }).then(console.log);
  9. //Delete user
  10. ResUsers.unlink([1]).then(console.log);

odoo-webkit API

Usage class Model

  1. import { Model } from 'odoo-webkit';
  2. const task = new Model('todo.task');
  3. // Method create ERP
  4. task.create({ name: "test", is_done: false }).then(console.log);
  5. // Method write ERP
  6. task.write(1, { is_done: true }).then(console.log);
  7. // Method unlink ERP
  8. task.unlink(1).then(console.log);
  9. //Search
  10. task.filter(['is_done', '=', true]).get().then(console.log);
  11. //Search and get especifict fields
  12. task
  13. .fields(['name'])
  14. .filter(['is_done','=', false])
  15. .get()
  16. .then(console.log);
  17. //Search all
  18. task.all().then(console.log);
  19. //Search and order
  20. task
  21. .filter(['name','ilike','test'])
  22. .order_by('-id')
  23. .get()
  24. .then(console.log);
  25. //count task
  26. task.count();
  27. //Search and limit
  28. task
  29. .filter(['name','ilike','test2'])
  30. .order_by('name')
  31. .limit(100)
  32. .get()
  33. .then(console.log);
  34. //How call function in ERP
  35. task
  36. .call_button('_toggle_tasks', [data, context])
  37. .then(console.log)

Usage class Auth

  1. import { Auth } from 'odoo-webkit';
  2. const auth = new Auth();
  3. // Method login
  4. // parameters username, password, database
  5. auth.login('admin', 'admin', 'test').then(console.log);
  6. // Method logout
  7. auth.logout().then(console.log);