diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-05-02 15:16:54 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-05-02 15:16:54 +0700 |
| commit | 02d95b8fbc4faf0045d293514ce63de358fa7645 (patch) | |
| tree | de553456375f89ffac420c037c4bcd436b0b88b5 /indoteknik_api/controllers/api_v1/courier.py | |
| parent | b43a60cca3644d09506673349589c9f213831862 (diff) | |
add kurir rajaongkir
Diffstat (limited to 'indoteknik_api/controllers/api_v1/courier.py')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/courier.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/indoteknik_api/controllers/api_v1/courier.py b/indoteknik_api/controllers/api_v1/courier.py new file mode 100644 index 00000000..cd3e35c0 --- /dev/null +++ b/indoteknik_api/controllers/api_v1/courier.py @@ -0,0 +1,26 @@ +from .. import controller +from odoo import http +from odoo.http import request + + +class Courier(controller.Controller): + prefix = '/api/v1/' + + @http.route(prefix + 'courier', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() + def get_courier(self): + base_url = request.env['ir.config_parameter'].get_param('web.base.url') + query = [ + ('publish', '=', True), + ] + + couriers = request.env['rajaongkir.kurir'].search(query) + data = [] + for courier in couriers: + data.append({ + 'id': courier.delivery_carrier_id.id, + 'name': courier.name, + 'image': base_url + 'api/image/rajaongkir.kurir/image/'+str(courier.id) + }) + return self.response(data) +
\ No newline at end of file |
