summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-07-22 13:08:25 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-07-22 13:08:25 +0700
commit96b986a27a356dfd026144ceed41608adde661a1 (patch)
treed1ebf5d6ef3b2a0deba5301dde1a7fea89cd26a1
parent6b68c39ebe116ccb16a5d77ab74b8b4a59958f20 (diff)
(andri) add validation approval, add jenis biaya di line penggunaan realisasi
-rw-r--r--indoteknik_custom/models/down_payment.py73
-rw-r--r--indoteknik_custom/views/down_payment_realization.xml4
2 files changed, 63 insertions, 14 deletions
diff --git a/indoteknik_custom/models/down_payment.py b/indoteknik_custom/models/down_payment.py
index 881829c8..573028b9 100644
--- a/indoteknik_custom/models/down_payment.py
+++ b/indoteknik_custom/models/down_payment.py
@@ -60,6 +60,10 @@ class DownPayment(models.Model):
('payment', 'Payment'),
], string='Status Pembayaran', default='pending', tracking=3)
+ name_approval_departement = fields.Char(string='Approval Departement')
+ name_approval_ap = fields.Char(string='Approval AP')
+ name_approval_pimpinan = fields.Char(string='Approval Pimpinan')
+
departement_type = fields.Selection([
('sales', 'Sales'),
('merchandiser', 'Merchandiser'),
@@ -174,17 +178,45 @@ class DownPayment(models.Model):
rec.status_pay_down_payment = 'payment'
+ # def action_approval_check(self):
+ # for record in self:
+ # # user = record.user_id
+ # user = self.env['res.users'].browse(3401)
+ # roles = sorted(set(
+ # f"{group
+ # .name} (Category: {group.category_id.name})"
+ # for group in user.groups_id
+ # if group.category_id.name == 'Roles'
+ # ))
+ # _logger.info(f"[ROLE CHECK] User: {user.name} (Login: {user.login}) Roles: {roles}")
+ # return
+
def action_approval_check(self):
- for record in self:
- # user = record.user_id
- user = self.env['res.users'].browse(3401)
- roles = sorted(set(
- f"{group.name} (Category: {group.category_id.name})"
- for group in user.groups_id
- if group.category_id.name == 'Roles'
- ))
- _logger.info(f"[ROLE CHECK] User: {user.name} (Login: {user.login}) Roles: {roles}")
- return
+ for rec in self:
+ approver_id = rec._get_departement_approver()
+ if rec.status == 'pengajuan1':
+ if self.env.user.id != approver_id:
+ raise UserError("Hanya approver departement yang berhak menyetujui tahap ini.")
+ rec.name_approval_departement = self.env.user.name
+ rec.status = 'pengajuan2'
+
+ elif rec.status == 'pengajuan2':
+ if self.env.user.id != 23: # ID user AP
+ raise UserError("Hanya AP yang berhak menyetujui tahap ini.")
+ rec.name_approval_ap = self.env.user.name
+ rec.status = 'pengajuan3'
+
+ elif rec.status == 'pengajuan3':
+ if self.env.user.id != 7: # ID user Pimpinan
+ raise UserError("Hanya Pimpinan yang berhak menyetujui tahap ini.")
+ rec.name_approval_pimpinan = self.env.user.name
+ rec.status = 'approved'
+
+ else:
+ raise UserError("Status saat ini tidak bisa di-approve lagi.")
+
+ rec.message_post(body=f"Approval oleh {self.env.user.name} pada tahap {rec.status}")
+
def action_reject(self):
# Logic untuk konfirmasi pembayaran
@@ -197,7 +229,7 @@ class DownPayment(models.Model):
def action_ap_only(self):
# if self.env.user.id != 23:
- # raise UserError('Hanya AP yang dapat menggunakan ini.')
+ # raise UserError('Hanya User AP yang dapat menggunakan ini.')
return {
'name': 'Create CAB AP Only',
'type': 'ir.actions.act_window',
@@ -225,9 +257,9 @@ class DownPayment(models.Model):
def create(self, vals):
if not vals.get('number') or vals['number'] == 'New Draft':
vals['number'] = self.env['ir.sequence'].next_by_code('down.payment') or 'New Draft'
-
if not vals.get('estimated_return_date'):
vals['estimated_return_date'] = date.today() + timedelta(days=7)
+ vals['status'] = 'pengajuan1'
return super(DownPayment, self).create(vals)
@@ -261,6 +293,17 @@ class RealizationDownPaymentUseLine(models.Model):
attachment_filename_image = fields.Char(string='Filename Image')
attachment_filename_pdf = fields.Char(string='Filename PDF')
+ account_id = fields.Many2one(
+ 'account.account', string='Jenis Biaya', required=True,
+ domain="[('id', 'in', [484, 486, 488, 506, 507, 625, 471, 519, 527, 528, 529, 530, 565])]" # ID Jenis Biaya yang dibutuhkan
+ )
+
+ @api.onchange('account_id')
+ def _onchange_account_id(self):
+ for rec in self:
+ if rec.account_id:
+ rec.description = rec.account_id.name + " - "
+
@api.onchange('attachment_type')
def _onchange_attachment_type(self):
self.attachment_file_image = False
@@ -364,6 +407,8 @@ class RealizationDownPayment(models.Model):
# Opsional: Tambah log di chatter
self.message_post(body=f"Status realisasi diperbarui menjadi <b>{dict(self._fields['done_status'].selection).get(self.done_status)}</b> oleh {self.env.user.name}.")
+ def action_misc(self):
+ return
class DownPaymentApOnly(models.TransientModel):
_name = 'down.payment.ap.only'
@@ -372,9 +417,9 @@ class DownPaymentApOnly(models.TransientModel):
down_payment_id = fields.Many2one('down.payment', string='Down Payment', required=True)
account_id = fields.Many2one(
'account.account', string='Bank Intransit', required=True,
- domain="[('name', 'ilike', 'intransit')]"
+ domain="[('id', 'in', [573, 389, 392])]" # ID Bank Intransit
)
- nominal = fields.Float(string='Nominal', related='down_payment_id.nominal', readonly=True)
+ nominal = fields.Float(string='Nominal', related='down_payment_id.nominal')
def action_create_cab(self):
self.ensure_one()
diff --git a/indoteknik_custom/views/down_payment_realization.xml b/indoteknik_custom/views/down_payment_realization.xml
index 2ee1a6d5..1138b59e 100644
--- a/indoteknik_custom/views/down_payment_realization.xml
+++ b/indoteknik_custom/views/down_payment_realization.xml
@@ -9,6 +9,9 @@
type="object"
string="Validasi"
class="btn-primary"/>
+ <button name="action_misc"
+ type="object"
+ string="AP Only"/>
<field name="done_status" widget="statusbar"
statusbar_visible="remaining,done_not_realized,done_realized"
statusbar_colors='{"done_realized":"green"}'
@@ -53,6 +56,7 @@
<form>
<group>
<field name="date"/>
+ <field name="account_id"/>
<field name="description"/>
<field name="nominal"/>
<field name="attachment_type"/>