summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-07-01 07:50:42 +0000
committertrisusilo <tri.susilo@altama.co.id>2024-07-01 07:50:42 +0000
commit2ad59ce416a79bdd12f74f4fd491d30443e9ebdf (patch)
tree88b7a32216b4a9a2967dc580d6c841d73b7f0354
parent424e8a227f73ae528812c9baaa6ee6e09a181bb7 (diff)
parentf134865c1e61aa7b808dbe46c2d7d33eb34c5183 (diff)
Merged in feature/iman_flash_sale (pull request #150)
<iman> add flash sale to sales order Approved-by: trisusilo
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py2
-rw-r--r--indoteknik_api/controllers/controller.py11
-rwxr-xr-xindoteknik_custom/models/sale_order.py3
-rwxr-xr-xindoteknik_custom/views/sale_order.xml1
4 files changed, 13 insertions, 4 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index f17e736f..ea2d381c 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -331,6 +331,7 @@ class SaleOrder(controller.Controller):
'delivery_amount': ['number', 'default:0'],
'carrier_id': [],
'delivery_service_type': [],
+ 'flash_sale': ['boolean'],
'voucher': [],
'source': [],
'estimated_arrival_days': ['number', 'default:0']
@@ -364,6 +365,7 @@ class SaleOrder(controller.Controller):
'shipping_paid_by': 'customer',
'carrier_id': params['value']['carrier_id'],
'delivery_service_type': params['value']['delivery_service_type'],
+ 'flash_sale': params['value']['flash_sale'],
'customer_type': 'nonpkp',
'npwp': '0',
'user_id': 1180 # User ID: Ima Nurhikmah
diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py
index 017e5c12..a34a2688 100644
--- a/indoteknik_api/controllers/controller.py
+++ b/indoteknik_api/controllers/controller.py
@@ -80,9 +80,10 @@ class Controller(http.Controller):
'value': {},
'query': {}
}
-
+
for key, rules in queries.items():
is_number = 'number' in rules
+ is_boolean = 'boolean' 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)
@@ -92,8 +93,10 @@ class Controller(http.Controller):
value = ''
if 'required' in rules and not value:
result['reason'].append(f"{key} is required")
- if 'number' in rules and value and not value.isdigit():
+ if is_number and value and not value.isdigit():
result['reason'].append(f"{key} must be a number")
+ if is_boolean and value and value.lower() not in ['true', 'false', '1', '0']:
+ result['reason'].append(f"{key} must be a boolean")
result['query'][key] = value
@@ -101,6 +104,8 @@ class Controller(http.Controller):
value = default
if is_number and value.isdigit():
value = int(value)
+ if is_boolean:
+ value = value.lower() in ['true', '1']
if not value and is_exclude_if_null:
continue
@@ -108,7 +113,7 @@ class Controller(http.Controller):
result['value'][alias] = value
result['valid'] = not result['reason']
-
+
return result
def time_to_str(self, object, format):
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 826315f2..6886f5a8 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -72,6 +72,7 @@ class SaleOrder(models.Model):
gross_amount = fields.Float(string='Gross Amount', help='Jumlah pembayaran yang dilakukan dengan Midtrans')
notification = fields.Char(string='Notification', help='Dapat membantu error dari approval')
delivery_service_type = fields.Char(string='Delivery Service Type', help='data dari rajaongkir')
+ flash_sale = fields.Boolean(string='Flash Sale', help='Data dari web')
grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total')
payment_link_midtrans = fields.Char(string='Payment Link', help='Url payment yg digenerate oleh midtrans, harap diserahkan ke customer agar dapat dilakukan pembayaran secara mandiri')
due_id = fields.Many2one('due.extension', string="Due Extension", readonly=True, tracking=True)
@@ -99,7 +100,7 @@ class SaleOrder(models.Model):
], string='Web Approval', copy=False)
compute_fullfillment = fields.Boolean(string='Compute Fullfillment', compute="_compute_fullfillment")
note_ekspedisi = fields.Char(string="Note Ekspedisi")
-
+
def open_form_multi_create_uang_muka(self):
action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_sale_order_multi_uangmuka')
action['context'] = {
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index d50331be..7f0eedb3 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -73,6 +73,7 @@
<field name="sales_tax_id" domain="[('type_tax_use','=','sale'), ('active', '=', True)]" required="1"/>
<field name="carrier_id" required="1"/>
<field name="delivery_service_type" readonly="1"/>
+ <field name="flash_sale"/>
</field>
<field name="medium_id" position="after">
<field name="date_doc_kirim" readonly="1"/>