diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2026-03-13 15:32:12 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2026-03-13 15:32:12 +0700 |
| commit | 8289cee1b6a599eaa7c07494bc8bef3d90fe7f0b (patch) | |
| tree | bc2861309b61a8678227bc1c1a77ff0046e59d35 | |
| parent | 6916edb441654f906bf3076f82df168dfa1ffde8 (diff) | |
<Miqdad> date approved
| -rw-r--r-- | indoteknik_custom/models/upah_harian_office.py | 36 | ||||
| -rw-r--r-- | indoteknik_custom/views/upah_harian_office_views.xml | 12 |
2 files changed, 32 insertions, 16 deletions
diff --git a/indoteknik_custom/models/upah_harian_office.py b/indoteknik_custom/models/upah_harian_office.py index 46b79fef..bdbb3cc4 100644 --- a/indoteknik_custom/models/upah_harian_office.py +++ b/indoteknik_custom/models/upah_harian_office.py @@ -29,9 +29,9 @@ class UpahHarian(models.Model): state = fields.Selection([ ('draft', 'Draft'), ('pic', 'Approval PIC'), - ('approved', 'Approval Kepala Departemen'), - ('waiting_payment', 'Waiting for Payment'), - ('paid', 'Paid'), + ('dept', 'Approval Kepala Departemen'), + ('waiting_payment', 'Menunggu Pembayaran'), + ('paid', 'Lunas'), ('cancel', 'Canceled') ], default='draft', tracking=True) @@ -41,6 +41,11 @@ class UpahHarian(models.Model): approved_by_dept = fields.Char('Approved By Dept', readonly=True) approved_by_finance = fields.Char('Approved By Finance', readonly=True) + date_approved_pic = fields.Datetime('Date Approved PIC', readonly=True) + date_approved_dept = fields.Datetime('Date Approved Dept', readonly=True) + date_approved_finance = fields.Datetime('Date Approved Finance', readonly=True) + + departement_type = fields.Selection([ ('sales', 'Sales'), ('merchandiser', 'Merchandiser'), @@ -151,26 +156,30 @@ class UpahHarian(models.Model): # ========================================================= # ACTION # ========================================================= - def action_approve(self): self.cancel_reason = False or "" + dept_head_ids = [25] if not self.upah_harian_line.mapped('kegiatan'): raise UserError("Harus Isi Kegiatan yang dilakukan") - if not self.env.user.pic: - raise UserError("Only PIC user can approve this document.") + approver = self.env.user.name if self.state == 'draft': self.state = 'pic' - self.approved_by_pic = self.env.user.name elif self.state == 'pic': - self.state = 'approved' - self.approved_by_dept = self.env.user.name - elif self.state == 'approved': + if not self.env.user.pic: + raise UserError("Only PIC user can approve this document.") + self.state = 'dept' + self.approved_by_pic = approver + self.date_approved_pic = fields.Datetime.now() + elif self.state == 'dept': + if self.env.user.id not in dept_head_ids: + raise UserError("Harus di Approve kepala departemen") self.state = 'waiting_payment' - self.approved_by_finance = self.env.user.name + self.approved_by_dept = approver + self.date_approved_dept = fields.Datetime.now() def action_reset_to_draft(self): @@ -184,12 +193,15 @@ class UpahHarian(models.Model): def action_cancel(self): if not self.cancel_reason: raise UserError('Harus Isi Alasan Cancel') - if self.state in ['paid', 'approved']: + if self.state in ['paid', 'dept']: raise UserError('Tidak Bisa Cancel Karena pengajuan sudah diapprove') self.state = 'cancel' self.approved_by_pic = False or "" self.approved_by_dept = False or "" self.approved_by_finance = False or "" + self.date_approved_finance = False or "" + self.date_approved_dept= False or "" + self.date_approved_pic = False or "" def write(self, vals): diff --git a/indoteknik_custom/views/upah_harian_office_views.xml b/indoteknik_custom/views/upah_harian_office_views.xml index 8e49db03..db941279 100644 --- a/indoteknik_custom/views/upah_harian_office_views.xml +++ b/indoteknik_custom/views/upah_harian_office_views.xml @@ -27,7 +27,8 @@ <header> <button name="action_create_journal_entries" class="btn-primary" type="object" string="Create Journal Entries" attrs="{'invisible': [('state', 'not in', ['waiting_payment'])]}"/> - <button name="action_approve" class="btn-primary" type="object" string="Approve" attrs="{'invisible': [('state', 'in', ['paid', 'cancel', 'waiting_payment'])]}"/> + <button name="action_approve" class="btn-primary" type="object" string="Submit" attrs="{'invisible': [('state', '!=', 'draft')]}"/> + <button name="action_approve" class="btn-primary" type="object" string="Approve" attrs="{'invisible': [('state', 'in', ['draft','paid','cancel','waiting_payment'])]}"/> <button name="action_cancel" class="btn-secondary" type="object" string="Cancel" attrs="{'invisible': [('state', 'in', ['paid', 'cancel'])]}"/> <button name="action_reset_to_draft" class="btn-secondary" type="object" string="Reset to Draft" attrs="{'invisible': [('state', 'not in', ['cancel'])]}"/> @@ -58,8 +59,11 @@ <field name="upah_harian"/> <field name="sisa_jam_mingguan" class="text-danger" attrs="{'invisible':[('sisa_jam_mingguan','=',0)]}"/> <field name="approved_by_pic" attrs="{'invisible': [('state', 'in', ['draft', 'cancel'])]}"/> + <field name="date_approved_pic" attrs="{'invisible': [('state', 'in', ['draft', 'cancel'])]}"/> <field name="approved_by_dept" attrs="{'invisible': [('state', 'in', ['draft', 'cancel'])]}"/> + <field name="date_approved_dept" attrs="{'invisible': [('state', 'in', ['draft', 'cancel'])]}"/> <field name="approved_by_finance" attrs="{'invisible': [('state', 'in', ['draft', 'cancel'])]}"/> + <field name="date_approved_finance" attrs="{'invisible': [('state', 'in', ['draft', 'cancel'])]}"/> <field name="cancel_reason"/> </group> @@ -67,13 +71,13 @@ <!-- ATTACHMENT --> <group> - <field name="attachment_type" attrs="{'readonly': [('state', '=', 'approved')]}"/> + <field name="attachment_type" attrs="{'readonly': [('state', '=', 'dept')]}"/> <field name="attachment_file_pdf" filename="attachment_filename" widget="pdf_viewer" attrs="{'invisible': [('attachment_type', '!=', 'pdf')], - 'readonly': [('state', '=', 'approved')]}"/> + 'readonly': [('state', '=', 'dept')]}"/> <field name="attachment_file_image" filename="attachment_filename" widget="image" attrs="{'invisible': [('attachment_type', '!=', 'image')], - 'readonly': [('state', '=', 'approved')]}" style="max-width:250px; max-height:250px; object-fit:contain;"/> + 'readonly': [('state', '=', 'dept')]}" style="max-width:250px; max-height:250px; object-fit:contain;"/> </group> |
