main.py 1.3 KB

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