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 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 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 75aabb813212ab796a10ee74f7f24e337d6b7ca0 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 23 Feb 2023 10:27:19 +0700 Subject: add blog replace keyword to link --- indoteknik_custom/models/blog_post.py | 35 ++++++++++++++++++++++ .../models/product_public_category.py | 6 ++++ indoteknik_custom/views/blog_post.xml | 6 ++++ 3 files changed, 47 insertions(+) diff --git a/indoteknik_custom/models/blog_post.py b/indoteknik_custom/models/blog_post.py index 27f0c125..6e96a311 100644 --- a/indoteknik_custom/models/blog_post.py +++ b/indoteknik_custom/models/blog_post.py @@ -1,4 +1,9 @@ from odoo import models, fields +from odoo.exceptions import UserError +import logging +import re + +_logger = logging.getLogger(__name__) class BlogPost(models.Model): @@ -9,3 +14,33 @@ class BlogPost(models.Model): thumbnail_256 = fields.Image("Thumbnail 256", related="thumbnail", max_width=256, max_height=256, store=True) thumbnail_512 = fields.Image("Thumbnail 512", related="thumbnail", max_width=512, max_height=512, store=True) thumbnail_1024 = fields.Image("Thumbnail 1024", related="thumbnail", max_width=1024, max_height=1024, store=True) + replace_click = fields.Boolean(string='Replace Clicked', help='Penanda bahwa Replace Keyword sudah di klik atau belum') + category_id = fields.Many2one(string='Product Category', help='Untuk replace keyword sesuai product category yang dipilih') + + def replace_keyword_to_link(self): + if self.replace_click: + raise UserError('Sudah pernah di click') + query = [ + ('level', '=', 'level4') + # ('id', '=', 1057) for debug only + ] + categories = self.env['product.public.category'].search(query, order='id') + for category in categories: + category_name = category.name + category_name = category_name.replace(' ', '+') + link_url = '' + category.name + '' + + query = [ + ('content', 'ilike', category.name) + ] + # blogs = self.env['blog.post'].search(query, order='id') + + # for blog in blogs: + content = self.content + compiled = re.compile(re.escape(category.name), re.IGNORECASE) + res = compiled.sub(link_url, content) + # content = content.replace(category.name, link_url) + self.content = res + _logger.info('Blog: Success Replace text to URL %s' % self.id) + + self.replace_click = True diff --git a/indoteknik_custom/models/product_public_category.py b/indoteknik_custom/models/product_public_category.py index 91028ae0..f46646d6 100755 --- a/indoteknik_custom/models/product_public_category.py +++ b/indoteknik_custom/models/product_public_category.py @@ -14,4 +14,10 @@ class ProductPublicCategory(models.Model): parent_frontend_id = fields.Many2one('product.public.category', string='Parent Frontend Category', index=True) child_frontend_id = fields.One2many('product.public.category', 'parent_frontend_id', string='Children Frontend Categories') sequence_frontend = fields.Integer(help="Gives the sequence order when displaying a list of product categories.", index=True) + level = fields.Selection([ + ('level1', 'Level 1'), + ('level2', 'Level 2'), + ('level3', 'Level 3'), + ('level4', 'Level 4'), + ]) # check diff --git a/indoteknik_custom/views/blog_post.xml b/indoteknik_custom/views/blog_post.xml index abb6be8b..d34a82d4 100644 --- a/indoteknik_custom/views/blog_post.xml +++ b/indoteknik_custom/views/blog_post.xml @@ -7,7 +7,13 @@ +