currencies.js 940 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const state = {
  2. currencies: []
  3. }
  4. const getters = {
  5. getCurrencies(state) {
  6. return state.currencies
  7. }
  8. }
  9. const mutations = {
  10. pushCurrencies(state, payload) {
  11. state.currencies = payload.currencies
  12. }
  13. }
  14. const actions = {
  15. fetchCurrencies({ commit, dispatch }) {
  16. return new Promise((resolve, reject) => {
  17. let ResCurrency = new openerp.web.Model('res.currency')
  18. ResCurrency.call('get_currencies', {
  19. context: new openerp.web.CompoundContext()
  20. }).then(response => {
  21. commit('pushCurrencies', {
  22. currencies: response
  23. })
  24. dispatch('loaded', 'currencies')
  25. resolve()
  26. }).fail(error => {
  27. console.log(error);
  28. reject(error)
  29. })
  30. })
  31. }
  32. }
  33. export default {
  34. state,
  35. getters,
  36. mutations,
  37. actions
  38. }