main.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # -*- coding: utf-8 -*-
  2. from openerp import http
  3. from helpers import get_data, process_data
  4. import logging
  5. LOGGER = logging.getLogger(__name__)
  6. def make_info_log(log):
  7. LOGGER.info('\033[1;34m[INFO] --> \033[m{}'.format(log))
  8. class Purchases(http.Controller):
  9. @http.route('/eiru_purchases/init', auth='user', methods=['GET'])
  10. def init_purchase(self, **kw):
  11. mode = kw.get('mode')
  12. make_info_log('Preparing data to {}'.format(mode))
  13. return get_data(mode)
  14. # '''
  15. # Create supplier and return data
  16. # '''
  17. # @http.route('/eiru_purchases/create_supplier', type='json', auth='user', methods=['POST'], cors='*')
  18. # def create_supplier(self, **kw):
  19. # self.make_info_log('Creating supplier')
  20. # '''
  21. # Create product and return data
  22. # '''
  23. # @http.route('/eiru_purchases/create_product', type='json', auth='user', methods=['POST'], cors='*')
  24. # def create_product(self, **kw):
  25. # self.make_info_log('Creating product')
  26. '''
  27. Purchase processing resource route
  28. '''
  29. @http.route('/eiru_purchases/process', type='json', auth='user', methods=['POST'])
  30. def process_purchase(self, **kw):
  31. make_info_log('Processing {}'.format(kw.get('mode')))
  32. return process_data(kw)