diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-10-25 08:47:36 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-10-25 08:47:36 +0700 |
| commit | 9fa80c62cdffec5b91aaf2a2899d70d0f507c2e4 (patch) | |
| tree | 93ae8d82f774345f650bc8d072dea759c6e33363 /indoteknik_api/controllers/api_v1/state.py | |
| parent | a21c5fe37529b2d2259d3b86d8e98730b2bc8513 (diff) | |
| parent | a7be93f4825967807f12e6bfbebcf090af8500fa (diff) | |
Merge branch 'production' into iman/switch-account
# Conflicts:
# indoteknik_api/controllers/api_v1/user.py
# indoteknik_custom/models/user_company_request.py
Diffstat (limited to 'indoteknik_api/controllers/api_v1/state.py')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/state.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/indoteknik_api/controllers/api_v1/state.py b/indoteknik_api/controllers/api_v1/state.py new file mode 100644 index 00000000..598ef70b --- /dev/null +++ b/indoteknik_api/controllers/api_v1/state.py @@ -0,0 +1,24 @@ +from .. import controller +from odoo import http +from odoo.http import request + +class District(controller.Controller): + prefix = '/api/v1/' + + @http.route(prefix + 'state', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() + def get_state(self, **kw): + parameters = [] + + name = kw.get('name') + if name: + name = '%' + name.replace(' ', '%') + '%' + parameters.append(('name', 'ilike', name)) + + states = request.env['res.country.state'].search(parameters) + data = [] + for state in states: + data.append({ 'id': state.id, 'name': state.name }) + + return self.response(data) + |
