currencies.js 905 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 pos = new openerp.web.Model('res.currency')
  18. ResCurrency.call('get_currencies').then(response => {
  19. commit('pushCurrencies', {
  20. currencies: response
  21. })
  22. dispatch('loaded', {
  23. module: 'currencies'
  24. })
  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. }