diff options
| author | Indoteknik . <it@fixcomart.co.id> | 2025-07-25 16:00:48 +0700 |
|---|---|---|
| committer | Indoteknik . <it@fixcomart.co.id> | 2025-07-25 16:00:48 +0700 |
| commit | 1f5366bece1c1237d078c63926b5f95de49b2c28 (patch) | |
| tree | c65bb39831b380e4d691918dbe50959a76c216ed | |
| parent | 758db1e691ca9193ce5029246c98e3b27be540f6 (diff) | |
(andri) fix validation only AP
| -rw-r--r-- | indoteknik_custom/models/down_payment.py | 59 | ||||
| -rw-r--r-- | indoteknik_custom/views/down_payment_realization.xml | 2 |
2 files changed, 34 insertions, 27 deletions
diff --git a/indoteknik_custom/models/down_payment.py b/indoteknik_custom/models/down_payment.py index 0263937b..4ed7d91c 100644 --- a/indoteknik_custom/models/down_payment.py +++ b/indoteknik_custom/models/down_payment.py @@ -105,6 +105,11 @@ class DownPayment(models.Model): def action_view_journal_uangmuka(self): self.ensure_one() + + ap_user_ids = [23, 9468] + if self.env.user.id not in ap_user_ids: + raise UserError('Hanya User AP yang dapat menggunakan fitur ini.') + if not self.move_id: raise UserError("Journal Uang Muka belum tersedia.") @@ -309,9 +314,15 @@ class DownPayment(models.Model): def action_ap_only(self): - # ap_user_ids = [23, 9468] # List user ID yang boleh approve sebagai Finance AP - # if self.env.user.id not in ap_user_ids: - # raise UserError('Hanya User AP yang dapat menggunakan ini.') + self.ensure_one() + + ap_user_ids = [23, 9468] # Ganti sesuai kebutuhan + if self.env.user.id not in ap_user_ids: + raise UserError('Hanya User AP yang dapat menggunakan fitur ini.') + + if self.move_id: + raise UserError('CAB / Jurnal sudah pernah dibuat untuk PUM ini.') + return { 'name': 'Create CAB AP Only', 'type': 'ir.actions.act_window', @@ -395,7 +406,9 @@ class RealizationDownPaymentUseLine(models.Model): @api.onchange('done_attachment') def _onchange_done_attachment(self): - if self.done_attachment and self.env.user.id != 23: + ap_user_ids = [23, 9468] # List user ID yang boleh approve sebagai Finance AP + + if self.done_attachment and self.env.user.id not in ap_user_ids: self.done_attachment = False return { 'warning': { @@ -491,6 +504,11 @@ class RealizationDownPayment(models.Model): def action_view_journal_uangmuka(self): self.ensure_one() + + ap_user_ids = [23, 9468] + if self.env.user.id not in ap_user_ids: + raise UserError('Hanya User AP yang dapat menggunakan fitur ini.') + if not self.move_id: raise UserError("Journal Uang Muka belum tersedia.") @@ -530,7 +548,8 @@ class RealizationDownPayment(models.Model): self.ensure_one() # Validasi hanya AP yang bisa validasi - if self.env.user.id != 23: + ap_user_ids = [23, 9468] # List user ID yang boleh approve sebagai Finance AP + if self.env.user.id not in ap_user_ids: raise UserError('Hanya AP yang dapat melakukan validasi realisasi.') if self.done_status == 'remaining': @@ -544,11 +563,14 @@ class RealizationDownPayment(models.Model): 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_cab(self): - # ap_user_ids = [23, 9468] # List user ID yang boleh approve sebagai Finance AP - # if self.env.user.id not in ap_user_ids: - # raise UserError('Hanya User AP yang dapat menggunakan ini.') self.ensure_one() + ap_user_ids = [23, 9468] # List user ID yang boleh approve sebagai Finance AP + if self.env.user.id not in ap_user_ids: + raise UserError('Hanya User AP yang dapat menggunakan ini.') + if self.move_id: + raise UserError("CAB / Jurnal sudah pernah dibuat untuk Realisasi ini.") + if not self.pum_id or not self.pum_id.move_id: raise UserError("PUM terkait atau CAB belum tersedia.") @@ -632,10 +654,10 @@ class RealizationDownPayment(models.Model): formatted_date = now.strftime('%d %B %Y %H:%M') for rec in self: - if not rec.departement_type: + if not rec.pum_id.departement_type: raise UserError("Field 'departement_type' wajib diisi sebelum approval.") - approver_id = rec._get_departement_approver() + approver_id = rec.pum_id._get_departement_approver() if rec.status == 'pengajuan1': if self.env.user.id != approver_id: @@ -653,7 +675,7 @@ class RealizationDownPayment(models.Model): 'fat': 'Finance & Accounting Manager', 'hr_ga': 'HR & GA Manager', } - rec.position_department = department_titles.get(rec.departement_type, 'Departement Manager') + rec.position_department = department_titles.get(rec.pum_id.departement_type, 'Departement Manager') rec.status = 'pengajuan2' @@ -765,18 +787,3 @@ class DownPaymentApOnly(models.TransientModel): 'target': 'current', } - - - - - - - - - - - - - - - diff --git a/indoteknik_custom/views/down_payment_realization.xml b/indoteknik_custom/views/down_payment_realization.xml index e20a5e66..c0181fcf 100644 --- a/indoteknik_custom/views/down_payment_realization.xml +++ b/indoteknik_custom/views/down_payment_realization.xml @@ -30,7 +30,7 @@ icon="fa-book" attrs="{'invisible': [('is_cab_visible', '=', False)]}" style="width: 200px;"> - <field name="move_id" widget="statinfo" string="Journal MISC"/> + <field name="move_id" widget="statinfo" string="Journal Entries"/> <span class="o_stat_text"> <t t-esc="record.move_misc_id.name"/> </span> |
