|
@@ -0,0 +1,45 @@
|
|
|
+const state = {
|
|
|
+ customers: [],
|
|
|
+ selectedCustomer: null
|
|
|
+}
|
|
|
+
|
|
|
+const getters = {
|
|
|
+ getCustomers(state) {
|
|
|
+ return state.customers
|
|
|
+ },
|
|
|
+ hasSelectedCustomer(state) {
|
|
|
+ return !!state.selectedCustomer
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const mutations = {
|
|
|
+ pushCustomers(state, payload) {
|
|
|
+ state.customers = [...payload.customers]
|
|
|
+ },
|
|
|
+ selectCustomer(state, payload) {
|
|
|
+ state.selectedCustomer = payload.customer
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const actions = {
|
|
|
+ fetchCustomers({ commit }){
|
|
|
+ let customer = new openerp.web.Model('res.partner')
|
|
|
+ customer.query(['name', 'display_name']).filter([['customer', '=', true], ['active', '=', true]]).all().then(response => {
|
|
|
+ commit('pushCustomers', {
|
|
|
+ customers: response
|
|
|
+ })
|
|
|
+ }).fail(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ selectCustomer({ commit }, payload) {
|
|
|
+ commit('selectCustomer', payload)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export default {
|
|
|
+ state,
|
|
|
+ getters,
|
|
|
+ mutations,
|
|
|
+ actions
|
|
|
+}
|