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(+) (limited to 'indoteknik_custom') 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(-) (limited to 'indoteknik_custom') 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 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 (limited to 'indoteknik_custom') 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(-) (limited to 'indoteknik_custom') 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(-) (limited to 'indoteknik_custom') 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 5fdade43dd264f834a52194b22a9d687c4dc6aab Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 22 Feb 2023 17:08:53 +0700 Subject: user company request and register logic --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/user_company_request.py | 15 ++++++++ indoteknik_custom/security/ir.model.access.csv | 3 +- indoteknik_custom/views/user_company_request.xml | 49 ++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/user_company_request.py create mode 100644 indoteknik_custom/views/user_company_request.xml (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 243b3028..5a3ffe0a 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -25,6 +25,7 @@ 'views/sale_monitoring.xml', 'views/sale_monitoring_detail.xml', 'views/user_activity_log.xml', + 'views/user_company_request.xml', 'views/vit_kelurahan.xml', 'views/vit_kecamatan.xml', 'views/vit_kota.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 62a024e3..4cb8bdda 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -32,6 +32,7 @@ from . import stock_picking_type from . import stock_picking from . import stock_vendor from . import user_activity_log +from . import user_company_request from . import users from . import website_brand_homepage from . import website_categories_homepage diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py new file mode 100644 index 00000000..c69b789c --- /dev/null +++ b/indoteknik_custom/models/user_company_request.py @@ -0,0 +1,15 @@ +from odoo import models, fields + + +class UserCompanyRequest(models.Model): + _name = 'user.company.request' + _rec_name = 'user_id' + + user_id = fields.Many2one('res.partner', string='User') + user_company_id = fields.Many2one('res.partner', string='Company') + user_input = fields.Char(string='User Input') + is_approve = fields.Selection([ + ('approved', 'Approve'), + ('rejected', 'Reject'), + ], string='Approval') + \ No newline at end of file diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 977f3a1b..26c1bd73 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -33,4 +33,5 @@ access_midtrans_recurring,access.midtrans.recurring,model_midtrans_recurring,,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 -access_wati_notification,access.wati.notification,model_wati_notification,,1,1,1,1 \ No newline at end of file +access_wati_notification,access.wati.notification,model_wati_notification,,1,1,1,1 +access_user_company_request,access.user.company.request,model_user_company_request,,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/user_company_request.xml b/indoteknik_custom/views/user_company_request.xml new file mode 100644 index 00000000..a44a48e0 --- /dev/null +++ b/indoteknik_custom/views/user_company_request.xml @@ -0,0 +1,49 @@ + + + + user.company.request.tree + user.company.request + + + + + + + + + + + + user.company.request.form + user.company.request + +
+ + + + + + + + + + +
+
+
+ + + User Company Request + ir.actions.act_window + user.company.request + tree,form + + + +
\ No newline at end of file -- cgit v1.2.3 From 5c9214c1c846e61c5356e1b19341b070c2303198 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 23 Feb 2023 10:39:40 +0700 Subject: partner company type and edit partner data --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/res_partner.py | 1 + .../models/res_partner_company_type.py | 7 ++++ indoteknik_custom/security/ir.model.access.csv | 3 +- indoteknik_custom/views/res_partner.xml | 3 ++ .../views/res_partner_company_type.xml | 43 ++++++++++++++++++++++ indoteknik_custom/views/user_company_request.xml | 2 +- 8 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 indoteknik_custom/models/res_partner_company_type.py create mode 100644 indoteknik_custom/views/res_partner_company_type.xml (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 5a3ffe0a..449fd09c 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -16,6 +16,7 @@ 'views/delivery_order.xml', 'views/product_pricelist.xml', 'views/res_groups.xml', + 'views/res_partner_company_type.xml', 'views/res_partner.xml', 'views/product_pricelist_item.xml', 'views/product_public_category.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 4cb8bdda..ebbf2e09 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -19,6 +19,7 @@ from . import purchase_order_line from . import purchase_order from . import purchase_outstanding from . import purchase_pricelist +from . import res_partner_company_type from . import res_partner from . import res_users from . import sale_monitoring_detail diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 403245fb..1cdf7c72 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -5,3 +5,4 @@ class ResPartner(models.Model): _inherit = 'res.partner' reference_number = fields.Char(string="Reference Number") + company_type_id = fields.Many2one('res.partner.company_type', string='Company Type') diff --git a/indoteknik_custom/models/res_partner_company_type.py b/indoteknik_custom/models/res_partner_company_type.py new file mode 100644 index 00000000..2bd356a1 --- /dev/null +++ b/indoteknik_custom/models/res_partner_company_type.py @@ -0,0 +1,7 @@ +from odoo import models, fields + + +class ResPartnerCompanyType(models.Model): + _name = 'res.partner.company_type' + + name = fields.Char('Name') \ No newline at end of file diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 26c1bd73..d5142381 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -34,4 +34,5 @@ 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 access_wati_notification,access.wati.notification,model_wati_notification,,1,1,1,1 -access_user_company_request,access.user.company.request,model_user_company_request,,1,1,1,1 \ No newline at end of file +access_user_company_request,access.user.company.request,model_user_company_request,,1,1,1,1 +access_res_partner_company_type,access.res.partner.company_type,model_res_partner_company_type,,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index 673718c4..47f41ab2 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -9,6 +9,9 @@ + + + diff --git a/indoteknik_custom/views/res_partner_company_type.xml b/indoteknik_custom/views/res_partner_company_type.xml new file mode 100644 index 00000000..ed21c1c9 --- /dev/null +++ b/indoteknik_custom/views/res_partner_company_type.xml @@ -0,0 +1,43 @@ + + + + res.partner.company_type.tree + res.partner.company_type + + + + + + + + + res.partner.company_type.form + res.partner.company_type + +
+ + + + + + + +
+
+
+ + + Company Type + ir.actions.act_window + res.partner.company_type + tree,form + + + +
\ No newline at end of file diff --git a/indoteknik_custom/views/user_company_request.xml b/indoteknik_custom/views/user_company_request.xml index a44a48e0..0b787683 100644 --- a/indoteknik_custom/views/user_company_request.xml +++ b/indoteknik_custom/views/user_company_request.xml @@ -43,7 +43,7 @@ id="menu_user_company_request" name="User Company Request" parent="contacts.menu_contacts" - sequence="5" + sequence="3" action="action_user_company_request" /> \ No newline at end of file -- cgit v1.2.3 From b94e4ff577c023d0ce1717c01c6080efc988acb7 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 23 Feb 2023 10:44:53 +0700 Subject: change scheduled action to automated action for parsing midtrans --- indoteknik_custom/views/midtrans.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/views/midtrans.xml b/indoteknik_custom/views/midtrans.xml index 487e7b7e..1773b9fd 100644 --- a/indoteknik_custom/views/midtrans.xml +++ b/indoteknik_custom/views/midtrans.xml @@ -9,6 +9,7 @@ model._parse_notification() code - 29 + 100 + False -- cgit v1.2.3 From 029e8fce907060de2a2514b5abc731f4cd9da96e Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 24 Feb 2023 15:44:15 +0700 Subject: User company request approve and reject action --- indoteknik_custom/models/user_company_request.py | 16 ++++++++++++++++ indoteknik_custom/views/user_company_request.xml | 17 ++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index c69b789c..2467261a 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -1,4 +1,5 @@ from odoo import models, fields +from odoo.exceptions import UserError class UserCompanyRequest(models.Model): @@ -12,4 +13,19 @@ class UserCompanyRequest(models.Model): ('approved', 'Approve'), ('rejected', 'Reject'), ], string='Approval') + + def write(self, vals): + is_approve = vals.get('is_approve') + if self.is_approve and is_approve: + raise UserError('Tidak dapat mengubah approval yang sudah diisi') + + if not self.is_approve and is_approve: + if is_approve == 'approved': + self.user_id.parent_id = self.user_company_id.id + else: + new_company = self.env['res.partner'].create({ + 'name': self.user_input + }) + self.user_id.parent_id = new_company.id + return super(UserCompanyRequest, self).write(vals) \ No newline at end of file diff --git a/indoteknik_custom/views/user_company_request.xml b/indoteknik_custom/views/user_company_request.xml index 0b787683..2efc1e9b 100644 --- a/indoteknik_custom/views/user_company_request.xml +++ b/indoteknik_custom/views/user_company_request.xml @@ -4,11 +4,17 @@ user.company.request.tree user.company.request - + - + + @@ -24,7 +30,12 @@ - + -- cgit v1.2.3