Browse Source

[ADD] more keys to search customers

Gogs 7 years ago
parent
commit
1a0e83dce5
3 changed files with 38 additions and 5 deletions
  1. 30 0
      models/eiru_pos.py
  2. 4 1
      src/components/CustomerSearcher.vue
  3. 4 4
      src/store/modules/customers.js

+ 30 - 0
models/eiru_pos.py

@@ -156,6 +156,36 @@ class EiruPOS(models.Model):
 
         return currencies
 
+    @api.model
+    def get_customers(self):
+        domain = [('customer', '=', True), ('is_company', '=', False), ('active', '=', True)]
+        customers = []
+
+        for customer in self.env['res.partner'].search(domain):
+            categories = []
+
+            for category in customer.category_id:
+                categories.append({
+                    'id': category.id,
+                    'name': category.name,
+                    'display_name': category.display_name
+                })
+
+            customers.append({
+                'id': customer.id,
+                'name': customer.name,
+                'display_name': customer.display_name,
+                'image_medium': customer.image_medium,
+                'phone': customer.phone,
+                'mobile': customer.mobile,
+                'email': customer.email,
+                'categories': categories
+            })
+        
+
+        return customers
+        
+
 class eiru_pos_session(models.Model):
     _name = 'eiru.pos.session'
 

+ 4 - 1
src/components/CustomerSearcher.vue

@@ -27,7 +27,10 @@
                     minMatchCharLength: 1,
                     keys: [
                         'name',
-                        'display_name'
+                        'phone',
+                        'mobile',
+                        'emainl',
+                        'categories.name'
                     ]
                 })
             },

+ 4 - 4
src/store/modules/customers.js

@@ -28,12 +28,12 @@ const mutations = {
 const actions = {
     fetchCustomers({ commit, dispatch }) {
         return new Promise((resolve, reject) => {
-            let customer = new openerp.web.Model('res.partner')
-            customer.query(['name', 'display_name', 'image_medium']).filter([['customer', '=', true], ['is_company', '=', false], ['active', '=', true]]).all().then(response => {
+            let pos = new openerp.web.Model('eiru.pos')
+            pos.call('get_customers').then(response => {
                 commit('pushCustomers', {
                     customers: response
                 })
-                
+
                 dispatch('loaded', {
                     module: 'customers'
                 })
@@ -58,4 +58,4 @@ export default {
     getters,
     mutations,
     actions
-}
+}