From f01969680c174f21be8fb9fde2032c749a62cf62 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 3 Jun 2024 15:56:00 +0700 Subject: def cargo --- indoteknik_api/controllers/api_v1/courier.py | 20 ++++++++- indoteknik_custom/__manifest__.py | 3 ++ indoteknik_custom/models/__init__.py | 2 + indoteknik_custom/models/def_cargo/__init__.py | 3 ++ .../models/def_cargo/def_cargo_city.py | 11 +++++ .../models/def_cargo/def_cargo_district.py | 15 +++++++ .../models/def_cargo/def_cargo_province.py | 10 +++++ indoteknik_custom/security/ir.model.access.csv | 3 ++ indoteknik_custom/views/def_cargo_city.xml | 41 ++++++++++++++++++ indoteknik_custom/views/def_cargo_district.xml | 49 ++++++++++++++++++++++ indoteknik_custom/views/def_cargo_province.xml | 39 +++++++++++++++++ 11 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/def_cargo/__init__.py create mode 100644 indoteknik_custom/models/def_cargo/def_cargo_city.py create mode 100644 indoteknik_custom/models/def_cargo/def_cargo_district.py create mode 100644 indoteknik_custom/models/def_cargo/def_cargo_province.py create mode 100644 indoteknik_custom/views/def_cargo_city.xml create mode 100644 indoteknik_custom/views/def_cargo_district.xml create mode 100644 indoteknik_custom/views/def_cargo_province.xml diff --git a/indoteknik_api/controllers/api_v1/courier.py b/indoteknik_api/controllers/api_v1/courier.py index 8cf3a674..1a52c1d2 100644 --- a/indoteknik_api/controllers/api_v1/courier.py +++ b/indoteknik_api/controllers/api_v1/courier.py @@ -5,6 +5,7 @@ from odoo.http import request class Courier(controller.Controller): prefix = '/api/v1/' + PREFIX_PARTNER = prefix + 'partner//' @http.route(prefix + 'courier', auth='public', methods=['GET', 'OPTIONS']) @controller.Controller.must_authorized() @@ -23,5 +24,22 @@ class Courier(controller.Controller): 'name': courier.name, 'image': base_url + 'api/image/rajaongkir.kurir/image/'+str(courier.id) }) + return self.response(data) + + @http.route(prefix + 'def_cargo', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() + def get_location_def_cargo(self, **kw): + city_name = str(kw.get('city_name')) + + cargo_city = request.env['def.cargo.city'].search([('name', 'ilike', f'%{city_name}%')]) + cargo_district = request.env['def.cargo.district'].search([('city_id', '=', cargo_city.id)], limit=1) + + data = { + 'kota': cargo_city.name, + 'coverage': cargo_district.coverage, + 'rate': cargo_district.rate, + 'next_kg': cargo_district.next_kg, + 'sla': cargo_district.sla + } + return self.response(data) - \ No newline at end of file diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 5b43781e..3d2b01e5 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -126,6 +126,9 @@ 'views/ged_tracking.xml', 'views/dunning_run_ged.xml', 'views/account_move_multi_update_bills.xml', + 'views/def_cargo_province.xml', + 'views/def_cargo_city.xml', + 'views/def_cargo_district.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index cd1e4d29..510dd659 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -106,6 +106,7 @@ from . import po_multi_cancel from . import logbook_sj from . import report_logbook_sj from . import role_permission + from . import cust_commision from . import report_stock_forecasted from . import web_logging @@ -114,3 +115,4 @@ from . import res_partner_site from . import external_api from . import ged from . import account_move_multi_update_bills +from . import def_cargo diff --git a/indoteknik_custom/models/def_cargo/__init__.py b/indoteknik_custom/models/def_cargo/__init__.py new file mode 100644 index 00000000..d6f2b19e --- /dev/null +++ b/indoteknik_custom/models/def_cargo/__init__.py @@ -0,0 +1,3 @@ +from . import def_cargo_province +from . import def_cargo_city +from . import def_cargo_district \ No newline at end of file diff --git a/indoteknik_custom/models/def_cargo/def_cargo_city.py b/indoteknik_custom/models/def_cargo/def_cargo_city.py new file mode 100644 index 00000000..4e7015be --- /dev/null +++ b/indoteknik_custom/models/def_cargo/def_cargo_city.py @@ -0,0 +1,11 @@ +from odoo import fields, models, api +from datetime import datetime, timedelta +import logging + +_logger = logging.getLogger(__name__) + + +class DefCargoCity(models.Model): + _name = 'def.cargo.city' + name = fields.Char(string="Name") + province_id = fields.Many2one('def.cargo.province', string="Province") diff --git a/indoteknik_custom/models/def_cargo/def_cargo_district.py b/indoteknik_custom/models/def_cargo/def_cargo_district.py new file mode 100644 index 00000000..0650005d --- /dev/null +++ b/indoteknik_custom/models/def_cargo/def_cargo_district.py @@ -0,0 +1,15 @@ +from odoo import fields, models, api +from datetime import datetime, timedelta +import logging + +_logger = logging.getLogger(__name__) + + +class DefCargoDistrict(models.Model): + _name = 'def.cargo.district' + name = fields.Char(string="Name") + city_id = fields.Many2one('def.cargo.city', string="City") + coverage = fields.Char(string="Coverage") + rate = fields.Float(string="Rate (min 10kg)") + next_kg = fields.Float(string="Next Kg") + sla = fields.Char(string="SLA") diff --git a/indoteknik_custom/models/def_cargo/def_cargo_province.py b/indoteknik_custom/models/def_cargo/def_cargo_province.py new file mode 100644 index 00000000..c666da5a --- /dev/null +++ b/indoteknik_custom/models/def_cargo/def_cargo_province.py @@ -0,0 +1,10 @@ +from odoo import fields, models, api +from datetime import datetime, timedelta +import logging + +_logger = logging.getLogger(__name__) + + +class DefCargoProvince(models.Model): + _name = 'def.cargo.province' + name = fields.Char(string="Name") diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 223504e6..744ce1c7 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -117,3 +117,6 @@ access_ged_tracking,access.ged.tracking,model_ged_tracking,,1,1,1,1 access_ged_tracking_line,access.ged.tracking.line,model_ged_tracking_line,,1,1,1,1 access_ged_tracking_log,access.ged.tracking.log,model_ged_tracking_log,,1,1,1,1 access_account_move_multi_update_bills,access.account.move.multi_update_bills,model_account_move_multi_update_bills,,1,1,1,1 +access_def_cargo_province,access.def.cargo.province,model_def_cargo_province,,1,1,1,1 +access_def_cargo_city,access.def.cargo.city,model_def_cargo_city,,1,1,1,1 +access_def_cargo_district,access.def.cargo.district,model_def_cargo_district,,1,1,1,1 diff --git a/indoteknik_custom/views/def_cargo_city.xml b/indoteknik_custom/views/def_cargo_city.xml new file mode 100644 index 00000000..8f8beec5 --- /dev/null +++ b/indoteknik_custom/views/def_cargo_city.xml @@ -0,0 +1,41 @@ + + + + def.cargo.city.tree + def.cargo.city + + + + + + + + + + def.cargo.city.form + def.cargo.city + +
+ + + + + + + + +
+
+
+ + + Def Cargo City + ir.actions.act_window + def.cargo.city + tree,form + + + +
\ No newline at end of file diff --git a/indoteknik_custom/views/def_cargo_district.xml b/indoteknik_custom/views/def_cargo_district.xml new file mode 100644 index 00000000..109fbcba --- /dev/null +++ b/indoteknik_custom/views/def_cargo_district.xml @@ -0,0 +1,49 @@ + + + + def.cargo.district.tree + def.cargo.district + + + + + + + + + + + + + + def.cargo.district.form + def.cargo.district + +
+ + + + + + + + + + + + +
+
+
+ + + Def Cargo District + ir.actions.act_window + def.cargo.district + tree,form + + + +
\ No newline at end of file diff --git a/indoteknik_custom/views/def_cargo_province.xml b/indoteknik_custom/views/def_cargo_province.xml new file mode 100644 index 00000000..37dc9162 --- /dev/null +++ b/indoteknik_custom/views/def_cargo_province.xml @@ -0,0 +1,39 @@ + + + + def.cargo.province.tree + def.cargo.province + + + + + + + + + def.cargo.province.form + def.cargo.province + +
+ + + + + + + +
+
+
+ + + Def Cargo Province + ir.actions.act_window + def.cargo.province + tree,form + + + +
\ No newline at end of file -- cgit v1.2.3