company.js 700 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. const state = {
  2. company: null
  3. }
  4. const getters = {
  5. getCompany(state) {
  6. return state.company
  7. },
  8. getDefaultCurrency(state) {
  9. return state.company ? state.company.currency : ''
  10. }
  11. }
  12. const mutations = {
  13. setCompany(state, payload) {
  14. state.company = payload.company
  15. }
  16. }
  17. const actions = {
  18. fetchCompany({ commit }) {
  19. let pos = new openerp.web.Model('eiru.pos')
  20. pos.call('get_company').then(response => {
  21. commit('setCompany', {
  22. company: response
  23. })
  24. }).fail(error => {
  25. console.log(error)
  26. })
  27. }
  28. }
  29. export default {
  30. state,
  31. getters,
  32. mutations,
  33. actions
  34. }