summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-02-23 14:41:48 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-02-23 14:41:48 +0700
commitae475a8d1dc9fa291d079e00d4194c55a0bb408c (patch)
tree82a7d96f161e1c0b2ece24171bd5ac3d4f4484d7
parent6538d8958c541e208df9a5fd83d5bdd5a0ae021c (diff)
parentde4a6c2c2ce115d169a3a85548ff95c8789e25c8 (diff)
Merge branch 'release' of bitbucket.org:altafixco/indoteknik-addons into release
-rw-r--r--indoteknik_api/controllers/api_v1/__init__.py1
-rw-r--r--indoteknik_api/controllers/api_v1/wati.py20
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/blog_post.py26
-rwxr-xr-xindoteknik_custom/models/crm_lead.py4
-rwxr-xr-xindoteknik_custom/models/sale_order.py7
-rw-r--r--indoteknik_custom/models/stock_picking.py7
-rw-r--r--indoteknik_custom/models/wati.py90
-rwxr-xr-xindoteknik_custom/models/x_manufactures.py2
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv3
-rw-r--r--indoteknik_custom/views/blog_post.xml6
-rw-r--r--indoteknik_custom/views/dunning_run.xml1
-rwxr-xr-xindoteknik_custom/views/sale_order.xml4
-rw-r--r--indoteknik_custom/views/stock_picking.xml2
-rw-r--r--indoteknik_custom/views/wati.xml14
-rwxr-xr-xindoteknik_custom/views/x_manufactures.xml6
17 files changed, 189 insertions, 6 deletions
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..68ff1640
--- /dev/null
+++ b/indoteknik_api/controllers/api_v1/wati.py
@@ -0,0 +1,20 @@
+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)
+ json_dump = json.dumps(json_raw, indent=4, sort_keys=True)
+
+ request.env['wati.notification'].create([{
+ 'json_raw': json_dump,
+ 'is_lead': False
+ }])
+
+ return
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/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/blog_post.py b/indoteknik_custom/models/blog_post.py
index 27f0c125..18844f0f 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,24 @@ 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('product.public.category', string='Product Category', help='Untuk replace keyword sesuai product category yang dipilih')
+
+ def replace_keyword_to_link(self):
+ if not self.category_id:
+ return
+ if self.replace_click:
+ raise UserError('Sudah pernah di klik sekali')
+
+ category_name = self.category_id.name
+ category_name = category_name.replace(' ', '+')
+ link_url = '<a href="https://indoteknik.com/shop/search?product_name=' + category_name + '">' + self.category_id.name + '</a>'
+
+ content = self.content
+ compiled = re.compile(re.escape(self.category_id.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/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/sale_order.py b/indoteknik_custom/models/sale_order.py
index b172b94c..f17ccee5 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -68,6 +68,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 _generate_access_token(self, limit):
orders = self.search(['access_token', '=', False], limit=limit)
@@ -111,10 +112,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
@@ -222,6 +222,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")
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 2c75ccbc..1dba31a3 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -56,6 +56,13 @@ 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")
+
+ @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()
diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py
new file mode 100644
index 00000000..df467ea1
--- /dev/null
+++ b/indoteknik_custom/models/wati.py
@@ -0,0 +1,90 @@
+from odoo import fields, models, api
+from datetime import datetime, timedelta
+import logging
+import json
+
+_logger = logging.getLogger(__name__)
+
+
+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 _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)
+ ]
+ watis = self.env['wati.notification'].search(query, order='id')
+
+ for wati in watis:
+ _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 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 = 25 #System
+ 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
+ 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
+ else:
+ # create new leads
+ contact_name = json.loads(wati.json_raw)['senderName']
+ phone = json.loads(wati.json_raw)['waId']
+ name = 'Ada pesan dari WATI '+str(phone)+' '+str(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': "c:" +str(text)
+ }])
+ wati.is_lead = True
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/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
diff --git a/indoteknik_custom/views/blog_post.xml b/indoteknik_custom/views/blog_post.xml
index abb6be8b..de346d1f 100644
--- a/indoteknik_custom/views/blog_post.xml
+++ b/indoteknik_custom/views/blog_post.xml
@@ -8,6 +8,12 @@
<field name="arch" type="xml">
<field name="blog_id" position="before">
<field name="thumbnail" widget="image" width="240" />
+ <button name="replace_keyword_to_link"
+ string="Replace Keyword"
+ type="object"
+ class="oe_highlight oe_edit_only"
+ />
+ <field name="category_id"/>
</field>
<page name="seo" position="attributes">
<attribute name="groups"/>
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 @@
<search string="Search Dunning Run">
<field name="number"/>
<field name="partner_id"/>
+ <field name="dunning_line" string="Invoice" filter_domain="[('dunning_line.invoice_id', 'ilike', self)]"/>
</search>
</field>
</record>
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 @@
<field name="sales_tax_id" domain="[('type_tax_use','=','sale')]" required="1"/>
<field name="carrier_id" required="1"/>
</field>
+ <field name="source_id" position="after">
+ <field name="date_doc_kirim" readonly="1"/>
+ </field>
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_unit']" position="attributes">
<attribute name="attrs">
{
@@ -101,6 +104,7 @@
<field name="approval_status" />
<field name="client_order_ref"/>
<field name="so_status"/>
+ <field name="date_doc_kirim" string="Tgl Kirim"/>
</field>
</field>
</record>
diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml
index a189e399..866c1aac 100644
--- a/indoteknik_custom/views/stock_picking.xml
+++ b/indoteknik_custom/views/stock_picking.xml
@@ -8,6 +8,7 @@
<field name="arch" type="xml">
<field name="json_popover" position="after">
<field name="date_done"/>
+ <field name="date_doc_kirim"/>
<field name="driver_departure_date"/>
<field name="driver_arrival_date"/>
</field>
@@ -45,6 +46,7 @@
<field name="real_shipping_id"/>
</field>
<field name="origin" position="after">
+ <field name="date_doc_kirim"/>
<field name="approval_status" attrs="{'invisible': [('is_internal_use', '=', False)]}"/>
<field name="approval_return_status" attrs="{'invisible': [('approval_return_status', '=', False)]}"/>
<field name="summary_qty_operation"/>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<odoo>
+ <record id="cron_wati_cleanup" model="ir.cron">
+ <field name="name">Wati: Cleansing Notification</field>
+ <field name="interval_number">15</field>
+ <field name="interval_type">days</field>
+ <field name="numbercall">-1</field>
+ <field name="doall" eval="False"/>
+ <field name="model_id" ref="model_wati_notification"/>
+ <field name="code">model._cleanup()</field>
+ <field name="state">code</field>
+ <field name="priority">28</field>
+ </record>
+</odoo>
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 @@
<field name="x_manufacture_level"/>
<field name="x_manufacture_service_center"/>
<field name="cache_reset_status"/>
- <field name="show_as_new_product"/>
- <field name="sequence"/>
+ <field name="parent_id"/>
</tree>
</field>
</record>
@@ -43,7 +42,8 @@
<field name="x_manufacture_level"/>
<field name="x_produk_aksesoris_sparepart"/>
<field name="cache_reset_status"/>
- <field name="sequence"/>
+ <field name="parent_id"/>
+ <field name="category_ids" widget="many2many_tags"/>
</group>
<group>
<field name="x_logo_manufacture" widget="image"/>