summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-05-17 14:21:27 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-05-17 14:21:27 +0700
commit3e7913ef03dc46a902f14d29e00c92eaed6bdf9d (patch)
tree19f67744179b5bc46ccd3887661914dc0bea4b7e
parent5e9f405cf05b3ae56564c8febff1d43decf63c62 (diff)
Fix error edit address, delete delivery line sale order api
-rw-r--r--indoteknik_api/controllers/api_v1/partner.py4
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py12
-rw-r--r--indoteknik_api/controllers/controller.py4
3 files changed, 6 insertions, 14 deletions
diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py
index fc05ae90..e61c98c1 100644
--- a/indoteknik_api/controllers/api_v1/partner.py
+++ b/indoteknik_api/controllers/api_v1/partner.py
@@ -33,7 +33,7 @@ class Partner(controller.Controller):
'street': ['required'],
'city_id': ['required', 'number', 'alias:kota_id'],
'district_id': ['number', 'alias:kecamatan_id'],
- 'sub_district_id': ['number', 'alias:kelurahan_id'],
+ 'sub_district_id': ['number', 'alias:kelurahan_id', 'exclude_if_null'],
'zip': ['required'],
})
@@ -62,7 +62,7 @@ class Partner(controller.Controller):
'street': ['required'],
'city_id': ['required', 'number', 'alias:kota_id'],
'district_id': ['number', 'alias:kecamatan_id'],
- 'sub_district_id': ['number', 'alias:kelurahan_id'],
+ 'sub_district_id': ['number', 'alias:kelurahan_id', 'exclude_if_null'],
'zip': ['required'],
})
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index 8fe1bb52..2ac92bf9 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -302,18 +302,6 @@ class SaleOrder(controller.Controller):
'price_unit': product._get_website_price_exclude_tax(),
'discount': discount
})
-
- # Static order line for delivery
- if params['value']['type'] == 'sale_order' and params['value']['delivery_amount'] > 0:
- parameters.append({
- 'company_id': 1,
- 'order_id': sale_order.id,
- 'product_id': 81384,
- 'product_uom_qty': 1,
- 'price_unit': params['value']['delivery_amount'],
- 'discount': 0,
- 'tax_id': False
- })
request.env['sale.order.line'].create(parameters)
return self.response({
diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py
index b850bdde..90bc50ed 100644
--- a/indoteknik_api/controllers/controller.py
+++ b/indoteknik_api/controllers/controller.py
@@ -73,6 +73,7 @@ class Controller(http.Controller):
for key, rules in queries.items():
is_number = 'number' in rules
+ is_exclude_if_null = 'exclude_if_null' in rules
alias = next((r.replace('alias:', '') for r in rules if r.startswith('alias:')), key)
default = next((r.replace('default:', '') for r in rules if r.startswith('default:')), None)
@@ -91,6 +92,9 @@ class Controller(http.Controller):
if is_number and value.isdigit():
value = int(value)
+ if not value and is_exclude_if_null:
+ continue
+
result['value'][alias] = value
result['valid'] = not result['reason']