From 8cca552e51decb429ebb69703c82fc7b9d157df2 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 14 Feb 2023 14:08:33 +0700 Subject: search by invoice in dunning run --- indoteknik_custom/views/dunning_run.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/views/dunning_run.xml b/indoteknik_custom/views/dunning_run.xml index cae9cc32..ac080fcf 100644 --- a/indoteknik_custom/views/dunning_run.xml +++ b/indoteknik_custom/views/dunning_run.xml @@ -91,6 +91,7 @@ + -- cgit v1.2.3 From 258717cb3c0a326ff85200dd9a724818dd9fca18 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 15 Feb 2023 13:15:51 +0700 Subject: add date surat jalan --- indoteknik_custom/models/stock_picking.py | 1 + indoteknik_custom/views/stock_picking.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 2c75ccbc..a3b5c6ef 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -56,6 +56,7 @@ class StockPicking(models.Model): ('pengajuan1', 'Approval Accounting'), ('approved', 'Approved'), ], string='Approval Return Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Return") + date_doc_kirim = fields.Datetime(string='Tanggal Kirim di SJ', help="Tanggal Kirim di cetakan SJ, tidak berpengaruh ke Accounting") def action_assign(self): res = super(StockPicking, self).action_assign() diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index a189e399..908820c5 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -45,6 +45,7 @@ + -- cgit v1.2.3 From 6e1b1715764630631cf6ee78fd0d6407a3185e9c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 15 Feb 2023 15:02:53 +0700 Subject: add date doc kirim in sj tree --- indoteknik_custom/views/stock_picking.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 908820c5..866c1aac 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -8,6 +8,7 @@ + -- cgit v1.2.3 From 19f823c479d8a8f7c0a5c4486ed124d7f4a9c40c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 16 Feb 2023 09:42:49 +0700 Subject: add last tgl kirim in sale order --- indoteknik_custom/models/sale_order.py | 1 + indoteknik_custom/models/stock_picking.py | 6 ++++++ indoteknik_custom/views/sale_order.xml | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index f21554f7..a8eed411 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -66,6 +66,7 @@ class SaleOrder(models.Model): ('partial_chargeback', 'Partial Chargeback'), ('authorize', 'Authorize'), ], string='Payment Status', help='Payment Gateway Status / Midtrans / Web, https://docs.midtrans.com/en/after-payment/status-cycle') + date_doc_kirim = fields.Datetime(string='Tanggal Kirim di SJ', help="Tanggal Kirim di cetakan SJ yang terakhir, tidak berpengaruh ke Accounting") def calculate_line_no(self): line_no = 0 diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index a3b5c6ef..1dba31a3 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -58,6 +58,12 @@ class StockPicking(models.Model): ], string='Approval Return Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Return") date_doc_kirim = fields.Datetime(string='Tanggal Kirim di SJ', help="Tanggal Kirim di cetakan SJ, tidak berpengaruh ke Accounting") + @api.onchange('date_doc_kirim') + def update_date_doc_kirim_so(self): + if not self.sale_id: + return + self.sale_id.date_doc_kirim = self.date_doc_kirim + def action_assign(self): res = super(StockPicking, self).action_assign() self.real_shipping_id = self.sale_id.real_shipping_id diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 1b6f31aa..ff684451 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -29,6 +29,9 @@ + + + { @@ -101,6 +104,7 @@ + -- cgit v1.2.3 From e3bac53c36e9b5314553340d4e345e9ed0ab2add Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 16 Feb 2023 10:20:28 +0700 Subject: add npwp validation in ask approval so --- indoteknik_custom/models/sale_order.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index a8eed411..8a4d096a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -215,6 +215,9 @@ class SaleOrder(models.Model): raise UserError('Gudang harus Bandengan') if order.state == 'cancel' or order.state == 'done' or order.state == 'sale': raise UserError("Status harus draft atau sent") + if not order.partner_invoice_id.npwp: + raise UserError("NPWP harus diisi di master data konsumen, jika non pkp dapat diisi 00.000.000.0-000.000") + if order.partner_id.parent_id: if not order.partner_id.parent_id.property_payment_term_id: raise UserError("Payment Term pada Master Data Customer harus diisi") -- cgit v1.2.3 From 0f99be075d857fb6bc7985b0fe8b429f53d3a9a0 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 16 Feb 2023 10:25:40 +0700 Subject: bug fix so status --- indoteknik_custom/models/sale_order.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 8a4d096a..519e55ce 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -104,10 +104,9 @@ class SaleOrder(models.Model): def calculate_so_status(self): so_state = ['sale'] - so_status = ['sebagian', 'menunggu'] sales = self.env['sale.order'].search([ ('state', 'in', so_state), - ('so_status', 'in', so_status), + ('so_status', '!=', 'terproses'), ]) for sale in sales: sum_qty_ship = sum_qty_so = 0 -- cgit v1.2.3 From 57b12c36df829ab358a68a5356c3549cf9714900 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 16 Feb 2023 13:49:18 +0700 Subject: add wati notification handle --- indoteknik_api/controllers/api_v1/__init__.py | 1 + indoteknik_api/controllers/api_v1/wati.py | 18 ++++++++++++++++++ indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/wati.py | 11 +++++++++++ indoteknik_custom/security/ir.model.access.csv | 3 ++- 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 indoteknik_api/controllers/api_v1/wati.py create mode 100644 indoteknik_custom/models/wati.py diff --git a/indoteknik_api/controllers/api_v1/__init__.py b/indoteknik_api/controllers/api_v1/__init__.py index 63540928..df89fcaf 100644 --- a/indoteknik_api/controllers/api_v1/__init__.py +++ b/indoteknik_api/controllers/api_v1/__init__.py @@ -20,3 +20,4 @@ from . import brand_homepage from . import customer from . import content from . import midtrans +from . import wati diff --git a/indoteknik_api/controllers/api_v1/wati.py b/indoteknik_api/controllers/api_v1/wati.py new file mode 100644 index 00000000..009ea244 --- /dev/null +++ b/indoteknik_api/controllers/api_v1/wati.py @@ -0,0 +1,18 @@ +from .. import controller +from odoo import http +from odoo.http import request +import json + + +class Wati(controller.Controller): + prefix = '/api/v1/' + + @http.route(prefix + 'wati/notification', auth='none', type='json', csrf=False, cors='*', methods=['POST', 'OPTIONS']) + def notification(self, **kw): + json_raw = json.loads(request.httprequest.data) + + request.env['wati.notification'].create([{ + 'json_raw': json_raw + }]) + + return diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 55eca2e7..62a024e3 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -48,3 +48,4 @@ from . import website_ads from . import leads_monitoring from . import midtrans from . import ip_lookup +from . import wati diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py new file mode 100644 index 00000000..f9ab6df2 --- /dev/null +++ b/indoteknik_custom/models/wati.py @@ -0,0 +1,11 @@ +from odoo import fields, models, api +import logging + +_logger = logging.getLogger(__name__) + + +class WatiNotification(models.Model): + _name = 'wati.notification' + + json_raw = fields.Char(string='JSON Raw Text') + diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 2cfe86a9..977f3a1b 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -32,4 +32,5 @@ access_midtrans_notification,access.midtrans.notification,model_midtrans_notific access_midtrans_recurring,access.midtrans.recurring,model_midtrans_recurring,,1,1,1,1 access_midtrans_account,access.midtrans.account,model_midtrans_account,,1,1,1,1 access_ip_lookup,access.ip.lookup,model_ip_lookup,,1,1,1,1 -access_ip_lookup_line,access.ip.lookup.line,model_ip_lookup_line,,1,1,1,1 \ No newline at end of file +access_ip_lookup_line,access.ip.lookup.line,model_ip_lookup_line,,1,1,1,1 +access_wati_notification,access.wati.notification,model_wati_notification,,1,1,1,1 \ No newline at end of file -- cgit v1.2.3 From 895a2e9ae261a6e11ae5673f0694165919edc6e7 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 16 Feb 2023 13:57:28 +0700 Subject: json dump wati --- indoteknik_api/controllers/api_v1/wati.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/wati.py b/indoteknik_api/controllers/api_v1/wati.py index 009ea244..01b32653 100644 --- a/indoteknik_api/controllers/api_v1/wati.py +++ b/indoteknik_api/controllers/api_v1/wati.py @@ -10,9 +10,10 @@ class Wati(controller.Controller): @http.route(prefix + 'wati/notification', auth='none', type='json', csrf=False, cors='*', methods=['POST', 'OPTIONS']) def notification(self, **kw): json_raw = json.loads(request.httprequest.data) + json_dump = json.dumps(json_raw, indent=4, sort_keys=True) request.env['wati.notification'].create([{ - 'json_raw': json_raw + 'json_raw': json_dump }]) return -- cgit v1.2.3 From 5413d6ae243fc2c9dd37930097928d51ef961aaa Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 16 Feb 2023 14:44:57 +0700 Subject: convert wati to leads --- indoteknik_custom/models/crm_lead.py | 4 ++++ indoteknik_custom/models/wati.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py index 3c8b842b..0534eb2f 100755 --- a/indoteknik_custom/models/crm_lead.py +++ b/indoteknik_custom/models/crm_lead.py @@ -10,6 +10,10 @@ class CrmLead(models.Model): file_tdp = fields.Binary(string="Tanda Daftar Perusahaan") file_siup = fields.Binary(string="Surat Izin Usaha Perdagangan") body_html_lead = fields.Text('Body HTML', compute='compute_body_leads') + # for wati only + ticket_id = fields.Char('Ticket ID', help='Ticket ID yang ada di WATI') + operator_email = fields.Char('Operator Email', help='Operator yang membalas') + operator_name = fields.Char('Operator Name', help='Operator yang membalas') def revert_to_leads(self): opportunities = self.env['crm.lead'].search([ diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index f9ab6df2..57ba9a4a 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -1,5 +1,6 @@ from odoo import fields, models, api import logging +import json _logger = logging.getLogger(__name__) @@ -8,4 +9,39 @@ class WatiNotification(models.Model): _name = 'wati.notification' json_raw = fields.Char(string='JSON Raw Text') + is_lead = fields.Boolean(string='To Leads', help='apakah sudah ter-convert jadi leads') + def _convert_to_leads(self): + query = [ + ('is_lead', '=', False) + ] + watis = self.env['wati.notification'].search(query, order='id') + + for wati in watis: + ticket_id = json.loads(wati.json_raw)['ticketId'] + text = json.loads(wati.json_raw)['text'] + + current_lead = self.env['crm.lead'].search([('ticket_id', '=', ticket_id)], limit=1) + operator_email = json.loads(wati.json_raw)['operatorEmail'] + operator_name = json.loads(wati.json_raw)['operatorName'] + + if current_lead: + # must append internal notes as a reply here + current_lead.description = current_lead.description + "|" +text + wati.is_lead = True + else: + # create new leads + contact_name = json.loads(wati.json_raw)['senderName'] + phone = json.loads(wati.json_raw)['waId'] + name = 'Ada pesan dari WATI '+phone+' '+contact_name + + self.env['crm.lead'].create([{ + 'name': name, + 'ticket_id': ticket_id, + 'operator_email': operator_email, + 'operator_name': operator_name, + 'contact_name': contact_name, + 'phone': phone, + 'description': text + }]) + wati.is_lead = True -- cgit v1.2.3 From aeb50c4ede78b7f101c5ccf7a63a2fb81ec3aae0 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 16 Feb 2023 14:52:01 +0700 Subject: bug fix wati to leads --- indoteknik_custom/models/wati.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index 57ba9a4a..0a4da9e1 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -18,6 +18,7 @@ class WatiNotification(models.Model): watis = self.env['wati.notification'].search(query, order='id') for wati in watis: + _logger.info('Convert Lead ID %s' % wati.id) ticket_id = json.loads(wati.json_raw)['ticketId'] text = json.loads(wati.json_raw)['text'] @@ -27,13 +28,13 @@ class WatiNotification(models.Model): if current_lead: # must append internal notes as a reply here - current_lead.description = current_lead.description + "|" +text + current_lead.description = current_lead.description + "|" +str(text) wati.is_lead = True else: # create new leads contact_name = json.loads(wati.json_raw)['senderName'] phone = json.loads(wati.json_raw)['waId'] - name = 'Ada pesan dari WATI '+phone+' '+contact_name + name = 'Ada pesan dari WATI '+str(phone)+' '+str(contact_name) self.env['crm.lead'].create([{ 'name': name, -- cgit v1.2.3 From dc44e019784e18f34bb84a86640793efd3daca17 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 16 Feb 2023 15:13:53 +0700 Subject: bug fix wati --- indoteknik_api/controllers/api_v1/wati.py | 3 ++- indoteknik_custom/models/wati.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/wati.py b/indoteknik_api/controllers/api_v1/wati.py index 01b32653..68ff1640 100644 --- a/indoteknik_api/controllers/api_v1/wati.py +++ b/indoteknik_api/controllers/api_v1/wati.py @@ -13,7 +13,8 @@ class Wati(controller.Controller): json_dump = json.dumps(json_raw, indent=4, sort_keys=True) request.env['wati.notification'].create([{ - 'json_raw': json_dump + 'json_raw': json_dump, + 'is_lead': False }]) return diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index 0a4da9e1..37c97f59 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -28,7 +28,7 @@ class WatiNotification(models.Model): if current_lead: # must append internal notes as a reply here - current_lead.description = current_lead.description + "|" +str(text) + current_lead.description = str(current_lead.description) + "|" +str(text) wati.is_lead = True else: # create new leads -- cgit v1.2.3 From a400a6b71bdd0ec77c9a053088c0024a2aadfaff Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 16 Feb 2023 16:51:43 +0700 Subject: add operator and name in wait leads --- indoteknik_custom/models/wati.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index 37c97f59..fbe350a5 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -29,6 +29,8 @@ class WatiNotification(models.Model): if current_lead: # must append internal notes as a reply here current_lead.description = str(current_lead.description) + "|" +str(text) + current_lead.operator_email = operator_email + current_lead.operator_name = operator_name wati.is_lead = True else: # create new leads -- cgit v1.2.3 From 37e33dfc0f0f79f67aa600c13e2e134037005f45 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 17 Feb 2023 09:26:35 +0700 Subject: add message sent in wati leads --- indoteknik_custom/models/wati.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index fbe350a5..170b4245 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -18,17 +18,23 @@ class WatiNotification(models.Model): watis = self.env['wati.notification'].search(query, order='id') for wati in watis: - _logger.info('Convert Lead ID %s' % wati.id) + _logger.info('Convert to Lead WATI Notification ID %s' % wati.id) ticket_id = json.loads(wati.json_raw)['ticketId'] text = json.loads(wati.json_raw)['text'] current_lead = self.env['crm.lead'].search([('ticket_id', '=', ticket_id)], limit=1) operator_email = json.loads(wati.json_raw)['operatorEmail'] operator_name = json.loads(wati.json_raw)['operatorName'] + event_type = json.loads(wati.json_raw)['eventType'] - if current_lead: + if event_type == 'sessionMessageSent': + current_lead.description = str(current_lead.description)+ "| i:" + str(text) + current_lead.operator_email = operator_email + current_lead.operator_name = operator_name + wati.is_lead = True + elif current_lead: # must append internal notes as a reply here - current_lead.description = str(current_lead.description) + "|" +str(text) + current_lead.description = str(current_lead.description) + " | c:" +str(text) current_lead.operator_email = operator_email current_lead.operator_name = operator_name wati.is_lead = True -- cgit v1.2.3 From 08d34e27298f6c2808f1f11986a8e2aaed4f432e Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 17 Feb 2023 10:35:15 +0700 Subject: mapping sales person in wati leads --- indoteknik_custom/models/wati.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index 170b4245..158a16d7 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -28,9 +28,30 @@ class WatiNotification(models.Model): event_type = json.loads(wati.json_raw)['eventType'] if event_type == 'sessionMessageSent': + if 'Saya *Eko*' in str(text): + sales = 11 + elif 'Saya *Nabila*' in str(text): + sales = 20 + elif 'Saya *Novita*' in str(text): + sales = 377 + elif 'Saya *Putri*' in str(text): + sales = 10 + elif 'Saya *Heriyanto*' in str(text): + sales = 375 + elif 'Saya *Ade*' in str(text): + sales = 9 + elif 'Saya *Adela*' in str(text): + sales = 8 + elif 'Saya *Jananto*' in str(text): + sales = 376 + elif 'Saya *Dwi*' in str(text): + sales = 24 + else: + sales = 20 #Nabila current_lead.description = str(current_lead.description)+ "| i:" + str(text) current_lead.operator_email = operator_email current_lead.operator_name = operator_name + current_lead.user_id = sales wati.is_lead = True elif current_lead: # must append internal notes as a reply here -- cgit v1.2.3 From 3503d77e6e5a2b5bb2d230bd5098cf03731d88c0 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 17 Feb 2023 10:48:18 +0700 Subject: add customer sign in wati leads --- indoteknik_custom/models/wati.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index 158a16d7..0fe3b02d 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -72,6 +72,6 @@ class WatiNotification(models.Model): 'operator_name': operator_name, 'contact_name': contact_name, 'phone': phone, - 'description': text + 'description': "c:" +str(text) }]) wati.is_lead = True -- cgit v1.2.3 From 1ac814df6fb11614d58df36662c7d8f72951f4c3 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 17 Feb 2023 17:01:49 +0700 Subject: change else to system instead nabila in lead wati --- indoteknik_custom/models/wati.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index 0fe3b02d..e2e723ef 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -47,7 +47,7 @@ class WatiNotification(models.Model): elif 'Saya *Dwi*' in str(text): sales = 24 else: - sales = 20 #Nabila + sales = 25 #System current_lead.description = str(current_lead.description)+ "| i:" + str(text) current_lead.operator_email = operator_email current_lead.operator_name = operator_name -- cgit v1.2.3 From 4a7d62d40a47ae894e2e22171105332ada9516ee Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 20 Feb 2023 09:52:14 +0700 Subject: add date order in midtrans --- indoteknik_api/controllers/api_v1/sale_order.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 1c67d6c5..e140605c 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -37,6 +37,7 @@ class SaleOrder(controller.Controller): 'id': sale.id, 'name': sale.name, 'amount_total': sale.amount_total, + 'date_order': sale.date_order, 'state': sale.state, 'product_name': product_name, 'product_not_in_id': product_not_in_id, -- cgit v1.2.3 From 28a205be163323cfad8596bbbcf0d1f7b3e4b993 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 20 Feb 2023 10:48:33 +0700 Subject: fix error date conversion to str --- indoteknik_api/controllers/api_v1/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 84c34a7d..f6c6faa5 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -37,7 +37,7 @@ class SaleOrder(controller.Controller): 'id': sale.id, 'name': sale.name, 'amount_total': sale.amount_total, - 'date_order': sale.date_order, + 'date_order': self.time_to_str(sale.date_order, '%d/%m/%Y %H:%M:%S'), 'state': sale.state, 'product_name': product_name, 'product_not_in_id': product_not_in_id, -- cgit v1.2.3 From b9cf801ad8334fe1b5be7b13b5d0483303c297c7 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 20 Feb 2023 11:29:15 +0700 Subject: add details in sale order api midtrans --- indoteknik_api/controllers/api_v1/sale_order.py | 1 + indoteknik_api/models/sale_order.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index f6c6faa5..727d49b7 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -41,6 +41,7 @@ class SaleOrder(controller.Controller): 'state': sale.state, 'product_name': product_name, 'product_not_in_id': product_not_in_id, + 'details': [request.env['sale.order.line'].api_single_response(x, context='with_detail') for x in sale.order_line] }) return self.response(data) diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py index 7ce8ff61..66ef27fa 100644 --- a/indoteknik_api/models/sale_order.py +++ b/indoteknik_api/models/sale_order.py @@ -63,3 +63,18 @@ class SaleOrder(models.Model): data_with_detail['invoices'].append(self.env['account.move'].api_v1_single_response(invoice)) data.update(data_with_detail) return data + + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + def api_single_response(self, sale_order_line, context=False): + data = { + 'image': self.env['ir.attachment'].api_image('product.template', 'image_128', sale_order_line.product_id.product_tmpl_id.id), + 'item_code': sale_order_line.product_id.default_code, + 'product_name': sale_order_line.product_id.name, + 'price_before_discount': sale_order_line.price_unit * sale_order_line.product_uom_qty, + 'price_after_discount': sale_order_line.price_total, + 'tax': sale_order_line.price_tax + } + return data -- cgit v1.2.3 From e4cd78fc169df2ad092023ab5ffda3fa639d8704 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 20 Feb 2023 11:32:01 +0700 Subject: add amount --- indoteknik_api/controllers/api_v1/sale_order.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 727d49b7..4d27312e 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -39,6 +39,9 @@ class SaleOrder(controller.Controller): 'amount_total': sale.amount_total, 'date_order': self.time_to_str(sale.date_order, '%d/%m/%Y %H:%M:%S'), 'state': sale.state, + 'amount_untaxed': sale.amount_untaxed, + 'amount_tax': sale.amount_tax, + 'amount_total': sale.amount_total, 'product_name': product_name, 'product_not_in_id': product_not_in_id, 'details': [request.env['sale.order.line'].api_single_response(x, context='with_detail') for x in sale.order_line] -- cgit v1.2.3 From 30548ae7462eebbf28ffad5398d0510541f462c0 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 20 Feb 2023 11:34:12 +0700 Subject: remove duplicate --- indoteknik_api/controllers/api_v1/sale_order.py | 1 - 1 file changed, 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 4d27312e..15dcf0ba 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -36,7 +36,6 @@ class SaleOrder(controller.Controller): data.append({ 'id': sale.id, 'name': sale.name, - 'amount_total': sale.amount_total, 'date_order': self.time_to_str(sale.date_order, '%d/%m/%Y %H:%M:%S'), 'state': sale.state, 'amount_untaxed': sale.amount_untaxed, -- cgit v1.2.3 From 3ea572e1292eca97b193c971091d7d2f7bbb260b Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 21 Feb 2023 10:12:39 +0700 Subject: add cleanup wati notification and add some field in manufactures --- indoteknik_custom/models/wati.py | 13 +++++++++++++ indoteknik_custom/models/x_manufactures.py | 2 ++ indoteknik_custom/views/x_manufactures.xml | 6 +++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index e2e723ef..df467ea1 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -1,4 +1,5 @@ from odoo import fields, models, api +from datetime import datetime, timedelta import logging import json @@ -11,6 +12,18 @@ class WatiNotification(models.Model): json_raw = fields.Char(string='JSON Raw Text') is_lead = fields.Boolean(string='To Leads', help='apakah sudah ter-convert jadi leads') + def _cleanup(self): + current_time = datetime.now() + delta_time = current_time - timedelta(days=15) + + delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') + self.env['wati.notification'].search([ + ('create_date', '<', delta_time), + ('is_lead', '=', True), + ]).unlink() + _logger.info('Success Cleanup WATI Notification') + + def _convert_to_leads(self): query = [ ('is_lead', '=', False) diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py index e6842797..dd6948a9 100755 --- a/indoteknik_custom/models/x_manufactures.py +++ b/indoteknik_custom/models/x_manufactures.py @@ -44,6 +44,8 @@ class XManufactures(models.Model): ], string="Cache Reset") sequence = fields.Integer(string='Sequence', help='Urutan tampil di homepage jika show as new product') show_as_new_product = fields.Boolean(string='Show as New Product', help='Centang jika ingin ditammpilkan di website sebagai segment Produk Baru') + parent_id = fields.Many2one('x_manufactures', string='Parent', help='Parent Brand tersebut') + category_ids = fields.Many2many('product.public.category', string='Category', help='Brand tsb memiliki Category apa saja') def cache_reset(self): manufactures = self.env['x_manufactures'].search([ diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml index e51cb6a7..ce00c980 100755 --- a/indoteknik_custom/views/x_manufactures.xml +++ b/indoteknik_custom/views/x_manufactures.xml @@ -22,8 +22,7 @@ - - + @@ -43,7 +42,8 @@ - + + -- cgit v1.2.3 From 78e791eb0c0d28a02fd4417d5d0761066c271c86 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 21 Feb 2023 10:51:53 +0700 Subject: refactor function notification in midtrans, complicated with wati --- indoteknik_api/controllers/api_v1/midtrans.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/midtrans.py b/indoteknik_api/controllers/api_v1/midtrans.py index fdc801d3..2adf3c50 100644 --- a/indoteknik_api/controllers/api_v1/midtrans.py +++ b/indoteknik_api/controllers/api_v1/midtrans.py @@ -8,7 +8,7 @@ class Midtrans(controller.Controller): prefix = '/api/v1/' @http.route(prefix + 'midtrans/notification', auth='none', type='json', csrf=False, cors='*', methods=['POST', 'OPTIONS']) - def notification(self, **kw): + def midtrans_notification(self, **kw): json_raw = json.loads(request.httprequest.data) trx_status = json.loads(request.httprequest.data)['transaction_status'] order_no = json.loads(request.httprequest.data)['order_id'] -- cgit v1.2.3 From 093b0160a1f6146e93cb0294341d65dcee707d9c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 21 Feb 2023 10:59:31 +0700 Subject: only save withour parsing data json in midtrans notification --- indoteknik_api/controllers/api_v1/midtrans.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/midtrans.py b/indoteknik_api/controllers/api_v1/midtrans.py index 2adf3c50..d5c91cb4 100644 --- a/indoteknik_api/controllers/api_v1/midtrans.py +++ b/indoteknik_api/controllers/api_v1/midtrans.py @@ -10,17 +10,18 @@ class Midtrans(controller.Controller): @http.route(prefix + 'midtrans/notification', auth='none', type='json', csrf=False, cors='*', methods=['POST', 'OPTIONS']) def midtrans_notification(self, **kw): json_raw = json.loads(request.httprequest.data) - trx_status = json.loads(request.httprequest.data)['transaction_status'] - order_no = json.loads(request.httprequest.data)['order_id'] + json_dump = json.dumps(json_raw, indent=4, sort_keys=True) + # trx_status = json.loads(request.httprequest.data)['transaction_status'] + # order_no = json.loads(request.httprequest.data)['order_id'] - query = [('name', '=', order_no)] - order = request.env['sale.order'].sudo().search(query, limit=1) - order.payment_status = trx_status + # query = [('name', '=', order_no)] + # order = request.env['sale.order'].sudo().search(query, limit=1) + # order.payment_status = trx_status request.env['midtrans.notification'].create([{ - 'sale_order_id': order.id, - 'json_raw': json_raw, - 'payment_status': trx_status, + # 'sale_order_id': order.id, + 'json_raw': json_dump, + # 'payment_status': trx_status, }]) return -- cgit v1.2.3 From e4158dc69c7d6bca17970dfbc838d9c29a76bd2b Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 21 Feb 2023 12:01:57 +0700 Subject: scheduler for parsing midtrans notification --- indoteknik_custom/models/midtrans.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/indoteknik_custom/models/midtrans.py b/indoteknik_custom/models/midtrans.py index 76dee447..df14c129 100644 --- a/indoteknik_custom/models/midtrans.py +++ b/indoteknik_custom/models/midtrans.py @@ -1,5 +1,6 @@ from odoo import fields, models, api import logging +import json _logger = logging.getLogger(__name__) @@ -24,6 +25,30 @@ class MidtransNotification(models.Model): ('authorize', 'Authorize'), ], string='Payment Status', help='Payment Gateway Status / Midtrans / Web, https://docs.midtrans.com/en/after-payment/status-cycle') + payment_type = fields.Char(string='Payment Type', help='Jenis pembayaran dengan Midtrans') + gross_amount = fields.Float(string='Gross Amount', help='Jumlah pembayaran yang dilakukan dengan Midtrans') + + def _parse_notification(self): + query = [ + ('payment_status', '=', False) + ] + notifications = self.env['midtrans.notification'].search(query, order='id') + for notif in notifications: + payment_status = json.loads(notif.json_raw)['transaction_status'] + payment_type = json.loads(notif.json_raw)['payment_type'] + gross_amount = json.loads(notif.json_raw)['gross_amount'] + order_id = json.loads(notif.json_raw)['order_id'] + + orders = order_id.split('_') + order = orders[0] + sale_order = self.env['sale.order'].search([('name', '=', order)], limit=1) + + notif.payment_status = payment_status + notif.payment_type = payment_type + notif.gross_amount = gross_amount + notif.sale_order_id = sale_order.id + + _logger.info('Success Parsing Midtrans Notification %s' % notif.id) class MidtransRecurring(models.Model): -- cgit v1.2.3 From c2105f6b0efdd0bb74b934205bb0acc43b297bdc Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 21 Feb 2023 13:07:57 +0700 Subject: sale order set midtrans status and others --- indoteknik_custom/models/midtrans.py | 8 ++++---- indoteknik_custom/models/sale_order.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/midtrans.py b/indoteknik_custom/models/midtrans.py index df14c129..11b10292 100644 --- a/indoteknik_custom/models/midtrans.py +++ b/indoteknik_custom/models/midtrans.py @@ -25,8 +25,6 @@ class MidtransNotification(models.Model): ('authorize', 'Authorize'), ], string='Payment Status', help='Payment Gateway Status / Midtrans / Web, https://docs.midtrans.com/en/after-payment/status-cycle') - payment_type = fields.Char(string='Payment Type', help='Jenis pembayaran dengan Midtrans') - gross_amount = fields.Float(string='Gross Amount', help='Jumlah pembayaran yang dilakukan dengan Midtrans') def _parse_notification(self): query = [ @@ -44,10 +42,12 @@ class MidtransNotification(models.Model): sale_order = self.env['sale.order'].search([('name', '=', order)], limit=1) notif.payment_status = payment_status - notif.payment_type = payment_type - notif.gross_amount = gross_amount notif.sale_order_id = sale_order.id + sale_order.payment_type = payment_type + sale_order.gross_amount = gross_amount + sale_order.payment_status = payment_status + _logger.info('Success Parsing Midtrans Notification %s' % notif.id) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 519e55ce..35f1af8e 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -67,6 +67,8 @@ class SaleOrder(models.Model): ('authorize', 'Authorize'), ], string='Payment Status', help='Payment Gateway Status / Midtrans / Web, https://docs.midtrans.com/en/after-payment/status-cycle') date_doc_kirim = fields.Datetime(string='Tanggal Kirim di SJ', help="Tanggal Kirim di cetakan SJ yang terakhir, tidak berpengaruh ke Accounting") + payment_type = fields.Char(string='Payment Type', help='Jenis pembayaran dengan Midtrans') + gross_amount = fields.Float(string='Gross Amount', help='Jumlah pembayaran yang dilakukan dengan Midtrans') def calculate_line_no(self): line_no = 0 -- cgit v1.2.3 From 861bb64e5a972b8ce9b09d2345dbb6250d041435 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 21 Feb 2023 13:27:16 +0700 Subject: add cleansing wati cron --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/views/wati.xml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 indoteknik_custom/views/wati.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 051f11ec..a794a822 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -61,6 +61,7 @@ 'views/website_ads.xml', 'views/leads_monitoring.xml', 'views/ip_lookup.xml', + 'views/wati.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/views/wati.xml b/indoteknik_custom/views/wati.xml new file mode 100644 index 00000000..fd0306be --- /dev/null +++ b/indoteknik_custom/views/wati.xml @@ -0,0 +1,14 @@ + + + + Wati: Cleansing Notification + 15 + days + -1 + + + model._cleanup() + code + 28 + + -- cgit v1.2.3 From e2e755caeb00b12f469841a9b17db135790cbd32 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 21 Feb 2023 13:35:14 +0700 Subject: add cron for parsing midtrans notification --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/views/midtrans.xml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 indoteknik_custom/views/midtrans.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index a794a822..243b3028 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -62,6 +62,7 @@ 'views/leads_monitoring.xml', 'views/ip_lookup.xml', 'views/wati.xml', + 'views/midtrans.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/views/midtrans.xml b/indoteknik_custom/views/midtrans.xml new file mode 100644 index 00000000..487e7b7e --- /dev/null +++ b/indoteknik_custom/views/midtrans.xml @@ -0,0 +1,14 @@ + + + + Midtrans: Parsing Notification + 17 + minutes + -1 + + + model._parse_notification() + code + 29 + + -- cgit v1.2.3 From d67936f7c5f2e471690d0dc682b8ed97f4097e22 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 21 Feb 2023 13:43:01 +0700 Subject: replace strip with slash if searching sale order midtrans --- indoteknik_custom/models/midtrans.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/midtrans.py b/indoteknik_custom/models/midtrans.py index 11b10292..c99c8410 100644 --- a/indoteknik_custom/models/midtrans.py +++ b/indoteknik_custom/models/midtrans.py @@ -38,7 +38,7 @@ class MidtransNotification(models.Model): order_id = json.loads(notif.json_raw)['order_id'] orders = order_id.split('_') - order = orders[0] + order = orders[0].replace('-', '/') sale_order = self.env['sale.order'].search([('name', '=', order)], limit=1) notif.payment_status = payment_status -- cgit v1.2.3 From 644093559480ed41b53de9f265f1ad508f8cae79 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 21 Feb 2023 13:51:27 +0700 Subject: add midtrans info in sale order form --- indoteknik_custom/views/sale_order.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index ff684451..d6df24a0 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -69,13 +69,18 @@ - + + + + + + -- cgit v1.2.3 From b9eddb17ac8eeed2b8af734844bb1149ec4184eb Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 21 Feb 2023 14:29:50 +0700 Subject: change json raw to json dump in midtrans recurring and payaccount --- indoteknik_api/controllers/api_v1/midtrans.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/midtrans.py b/indoteknik_api/controllers/api_v1/midtrans.py index d5c91cb4..49ebce0f 100644 --- a/indoteknik_api/controllers/api_v1/midtrans.py +++ b/indoteknik_api/controllers/api_v1/midtrans.py @@ -29,15 +29,17 @@ class Midtrans(controller.Controller): @http.route(prefix + 'midtrans/recurring', auth='none', type='json', csrf=False, cors='*', methods=['POST', 'OPTIONS']) def recurring(self, **kw): json_raw = json.loads(request.httprequest.data) + json_dump = json.dumps(json_raw, indent=4, sort_keys=True) request.env['midtrans.recurring'].create([{ - 'json_raw': json_raw, + 'json_raw': json_dump, }]) return @http.route(prefix + 'midtrans/payaccount', auth='none', type='json', csrf=False, cors='*', methods=['POST', 'OPTIONS']) def payaccount(self, **kw): json_raw = json.loads(request.httprequest.data) + json_dump = json.dumps(json_raw, indent=4, sort_keys=True) request.env['midtrans.account'].create([{ - 'json_raw': json_raw, + 'json_raw': json_dump, }]) return \ No newline at end of file -- cgit v1.2.3