diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-02-20 09:52:42 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-02-20 09:52:42 +0700 |
| commit | 1b53c0081b925e54e056c94b355a9b99320e0ea5 (patch) | |
| tree | 74a20d5a5efdeb23a779adc340681718f697d7b9 | |
| parent | ce3e018ad61808b7e581e416525e6696ed088916 (diff) | |
| parent | 4a7d62d40a47ae894e2e22171105332ada9516ee (diff) | |
Merge branch 'midtrans' into staging
| -rw-r--r-- | indoteknik_api/controllers/api_v1/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/sale_order.py | 1 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/wati.py | 20 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/crm_lead.py | 4 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 7 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 7 | ||||
| -rw-r--r-- | indoteknik_custom/models/wati.py | 77 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/dunning_run.xml | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 4 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_picking.xml | 2 |
12 files changed, 125 insertions, 3 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/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 8fe4b1d5..84c34a7d 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, 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/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/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 f21554f7..519e55ce 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 @@ -103,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 @@ -214,6 +214,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..e2e723ef --- /dev/null +++ b/indoteknik_custom/models/wati.py @@ -0,0 +1,77 @@ +from odoo import fields, models, api +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 _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/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/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"/> |
