diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-25 11:53:29 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-25 11:53:29 +0700 |
| commit | 13c90b5a95391d797b89c39b90c1430400ed29b7 (patch) | |
| tree | 1df668fee68e72a76cbcc5255e5d533b3721d190 /indoteknik_custom/models | |
| parent | 0f7f7fa273295fadde403c4ff9333b3bbe14489a (diff) | |
| parent | 029e8fce907060de2a2514b5abc731f4cd9da96e (diff) | |
Merge branch 'staging' into release
Diffstat (limited to 'indoteknik_custom/models')
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/midtrans.py | 25 | ||||
| -rw-r--r-- | indoteknik_custom/models/res_partner.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/res_partner_company_type.py | 7 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/user_company_request.py | 31 |
6 files changed, 68 insertions, 0 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 62a024e3..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 @@ -32,6 +33,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/midtrans.py b/indoteknik_custom/models/midtrans.py index 76dee447..c99c8410 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__) @@ -25,6 +26,30 @@ class MidtransNotification(models.Model): ], string='Payment Status', help='Payment Gateway Status / Midtrans / Web, https://docs.midtrans.com/en/after-payment/status-cycle') + 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].replace('-', '/') + sale_order = self.env['sale.order'].search([('name', '=', order)], limit=1) + + notif.payment_status = payment_status + 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) + class MidtransRecurring(models.Model): _name = 'midtrans.recurring' 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/models/sale_order.py b/indoteknik_custom/models/sale_order.py index ae769ae7..2dcfa718 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -69,6 +69,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') @api.model def _generate_so_access_token(self, limit=50): diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py new file mode 100644 index 00000000..2467261a --- /dev/null +++ b/indoteknik_custom/models/user_company_request.py @@ -0,0 +1,31 @@ +from odoo import models, fields +from odoo.exceptions import UserError + + +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') + + 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 |
