summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/user_merchant_request.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-12-30 14:09:50 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-12-30 14:09:50 +0700
commit7d5204a92422848f617af2d0e50d7069bf9f7824 (patch)
tree139718306bb1be2d9cccd3de8fb4c56c0a5b6b1b /indoteknik_custom/models/user_merchant_request.py
parentefe91d5ed3170b1d8e2dc217a05261dfbd9687d5 (diff)
<iman> add form merchant
Diffstat (limited to 'indoteknik_custom/models/user_merchant_request.py')
-rw-r--r--indoteknik_custom/models/user_merchant_request.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/indoteknik_custom/models/user_merchant_request.py b/indoteknik_custom/models/user_merchant_request.py
new file mode 100644
index 00000000..b47f6d1d
--- /dev/null
+++ b/indoteknik_custom/models/user_merchant_request.py
@@ -0,0 +1,96 @@
+from odoo import models, fields, api, _
+from odoo.exceptions import UserError
+from odoo.http import request
+
+
+class RejectReasonWizardMerchant(models.TransientModel):
+ _name = 'reject.reason.wizard.merchant'
+ _description = 'Wizard for Reject Reason'
+
+ request_id = fields.Many2one('user.merchant.request', string='Request')
+ reason_reject = fields.Text(string='Reason for Rejection', required=True)
+
+ def confirm_reject(self):
+ merchant = self.request_id
+ if merchant:
+ merchant.write({'reason_reject': self.reason_reject})
+ merchant.state_merchant = 'reject'
+ return {'type': 'ir.actions.act_window_close'}
+
+
+class ConfirmApprovalWizardMerchant(models.TransientModel):
+ _name = 'confirm.approval.wizard.merchant'
+ _description = 'Wizard Konfirmasi Approval'
+
+ merchant_id = fields.Many2one('user.merchant.request', string='Merchant', required=True)
+
+ def confirm_approval(self):
+ merchant = self.merchant_id
+ if merchant.state_merchant == 'draft':
+ merchant.state_merchant = 'approved'
+
+
+class UserMerchantRequest(models.Model):
+ _name = 'user.merchant.request'
+ _inherit = ['mail.thread', 'mail.activity.mixin']
+ _rec_name = 'user_id'
+
+ user_id = fields.Many2one('res.partner', string='User')
+ merchant_id = fields.Many2one('user.form.merchant', string='Form Merchant')
+ user_company_id = fields.Many2one('res.partner', string='Company')
+ state_merchant = fields.Selection([
+ ('draft', 'Pengajuan Merchant'),
+ ('approved', 'Approved Merchant'),
+ ('reject', 'Rejected'),
+ ], string='Status', readonly=True, copy=False, index=True, track_visibility='onchange', default='draft')
+ reason_reject = fields.Char(string='Reaject Reason')
+
+ def button_approve(self):
+ for merchant in self:
+ return {
+ 'type': 'ir.actions.act_window',
+ 'name': 'Konfirmasi Approve',
+ 'res_model': 'confirm.approval.wizard.merchant',
+ 'view_mode': 'form',
+ 'target': 'new',
+ 'context': {
+ 'default_merchant_id': merchant.id,
+ }}
+
+ def button_reject(self):
+ return {
+ 'type': 'ir.actions.act_window',
+ 'name': _('Reject Reason'),
+ 'res_model': 'reject.reason.wizard.merchant',
+ 'view_mode': 'form',
+ 'target': 'new',
+ 'context': {'default_request_id': self.id},
+ }
+
+ def write(self, vals):
+ is_approve = True if self.state_merchant == 'approved' or vals.get('state_merchant') == 'approved' else False
+ if is_approve:
+ self.user_company_id.name_merchant = self.merchant_id.name_merchant
+ self.user_company_id.address_merchant = self.merchant_id.address
+ self.user_company_id.state_merchant = self.merchant_id.state
+ self.user_company_id.city_merchant = self.merchant_id.city
+ self.user_company_id.district_merchant = self.merchant_id.district
+ self.user_company_id.subDistrict_merchant = self.merchant_id.subDistrict
+ self.user_company_id.zip_merchant = self.merchant_id.zip
+ self.user_company_id.bank_name_merchant = self.merchant_id.bank_name
+ self.user_company_id.rekening_name_merchant = self.merchant_id.rekening_name
+ self.user_company_id.account_number_merchant = self.merchant_id.account_number
+ self.user_company_id.email_company_merchant = self.merchant_id.email_company
+ self.user_company_id.email_sales_merchant = self.merchant_id.email_sales
+ self.user_company_id.email_finance_merchant = self.merchant_id.email_finance
+ self.user_company_id.phone_merchant = self.merchant_id.phone
+ self.user_company_id.mobile_merchant = self.merchant_id.mobile
+ self.user_company_id.file_dokumenKtpDirut = self.merchant_id.file_dokumenKtpDirut
+ self.user_company_id.file_kartuNama = self.merchant_id.file_kartuNama
+ self.user_company_id.file_npwp = self.merchant_id.file_npwp
+ self.user_company_id.file_sppkp = self.merchant_id.file_sppkp
+ self.user_company_id.file_suratPernyataan = self.merchant_id.file_suratPernyataan
+ self.user_company_id.file_fotoKantor = self.merchant_id.file_fotoKantor
+ self.user_company_id.description = self.merchant_id.description
+
+ return super(UserMerchantRequest, self).write(vals) \ No newline at end of file