summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFIN-IT_AndriFP <andrifebriyadiputra@gmail.com>2026-03-03 13:37:56 +0700
committerFIN-IT_AndriFP <andrifebriyadiputra@gmail.com>2026-03-03 13:37:56 +0700
commit6ff3a1abae7c0d9db659991811b69d4ad66effb8 (patch)
treed395be61bb0f3181668f342b85af4dcd0ec12cbc
parent5971d8f9e3543945148b7e06cf0e4ee1a0685603 (diff)
(andri) edit date accounting pada journal entries sekaligus via tree
-rw-r--r--indoteknik_custom/models/account_move.py46
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv2
-rw-r--r--indoteknik_custom/views/account_move.xml42
3 files changed, 90 insertions, 0 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index a317dccc..914a5329 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -786,6 +786,24 @@ class AccountMove(models.Model):
if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm':
raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock')
return res
+
+ def action_open_change_date_wizard(self):
+ if not self.env.user.is_accounting:
+ raise UserError('Hanya Accounting yang bisa Reset to Draft')
+ non_draft = self.filtered(lambda m: m.state != 'draft')
+ if non_draft:
+ raise UserError('Hanya invoice dengan status draft yang bisa diubah tanggalnya. Mohon reset ke draft terlebih dahulu.')
+ return{
+ 'name': 'Change Date Journal Entry',
+ 'type': 'ir.actions.act_window',
+ 'view_mode': 'form',
+ 'res_model': 'account.move.change.date.wizard',
+ 'target': 'new',
+ 'context':{
+ 'active_ids': self.ids,
+ 'active_model': self._name,
+ }
+ }
def action_post(self):
if self._name != 'account.move':
@@ -997,3 +1015,31 @@ class SyncPromiseDateWizardLine(models.TransientModel):
date_terima_tukar_faktur = fields.Date(related="invoice_id.date_terima_tukar_faktur", string="Tanggal Terima Tukar Faktur", readonly=True)
amount_total = fields.Monetary(related="invoice_id.amount_total", string="Total", readonly=True)
currency_id = fields.Many2one(related="invoice_id.currency_id", readonly=True)
+
+class AccountMoveChangeDateWizard(models.TransientModel):
+ _name = "account.move.change.date.wizard"
+ _description = "Account Move Change Date Wizard"
+
+ # move_id = fields.Many2one('account.move', string="Journal Entry", required=True)
+ new_date = fields.Date(string="New Date", required=True)
+
+ def action_change_date(self):
+ if not self.env.user.is_accounting:
+ raise UserError('Hanya Accounting yang bisa ubah tanggal')
+
+ active_ids = self.env.context.get('active_ids', [])
+ moves = self.env['account.move'].browse(active_ids)
+
+ if not moves:
+ raise UserError("Tidak ada journal entry yang dipilih.")
+
+ non_draft_moves = moves.filtered(lambda m: m.state != 'draft')
+ if non_draft_moves:
+ raise UserError("Hanya journal entry dengan status 'Draft' yang dapat diubah tanggalnya.")
+
+ for move in moves:
+ move.write({'date': self.new_date})
+ move.message_post(body="Tanggal berhasil diubah")
+
+ return {'type': 'ir.actions.act_window_close'}
+ \ No newline at end of file
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index 42c68e80..041634fc 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -222,3 +222,5 @@ access_update_depreciation_move_wizard,access.update.depreciation.move.wizard,mo
access_keywords,keywords,model_keywords,base.group_user,1,1,1,1
access_token_log,access.token.log,model_token_log,,1,1,1,1
+
+access_account_move_change_date_wizard,access.account.move.change.date.wizard,model_account_move_change_date_wizard,,1,1,1,1
diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml
index c5f9580c..4b9f5316 100644
--- a/indoteknik_custom/views/account_move.xml
+++ b/indoteknik_custom/views/account_move.xml
@@ -218,6 +218,48 @@
<field name="code">action = records.export_faktur_to_xml()</field>
</record>
+ <record id="action_set_to_draft_journal_entry" model="ir.actions.server">
+ <field name="name">Set to Draft</field>
+ <field name="model_id" ref="account.model_account_move" />
+ <field name="binding_model_id" ref="account.model_account_move" />
+ <field name="state">code</field>
+ <field name="code">action = records.button_draft()</field>
+ </record>
+
+ <!-- <record id="action_account_move_change_date_wizard" model="ir.actions.act_window">
+ <field name="name">Change Date</field>
+ <field name="res_model">account.move.change.date.wizard</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ <field name="binding_model_id" ref="account.model_account_move"/>
+ <field name="binding_view_types">list</field>
+ </record> -->
+
+ <record id="action_change_date" model="ir.actions.server">
+ <field name="name">Change Date</field>
+ <field name="model_id" ref="account.model_account_move"/>
+ <field name="binding_model_id" ref="account.model_account_move"/>
+ <field name="state">code</field>
+ <field name="code">action = records.action_open_change_date_wizard()</field>
+ </record>
+
+ <record id="view_account_move_change_date_wizard_form" model="ir.ui.view">
+ <field name="name">account.move.change.date.wizard.form</field>
+ <field name="model">account.move.change.date.wizard</field>
+ <field name="arch" type="xml">
+ <form string="Change Date">
+ <p>Ubah tanggal journal yang dipilih, pastikan untuk memeriksa kembali tanggal yang akan diubah sebelum mengkonfirmasi perubahan.</p>
+ <group>
+ <field name="new_date"/>
+ </group>
+ <footer>
+ <button name="action_change_date" string="Confirm" type="object" class="btn-primary"/>
+ <button string="Cancel" class="btn-secondary" special="cancel"/>
+ </footer>
+ </form>
+ </field>
+ </record>
+
<record id="view_sync_promise_date_wizard_form" model="ir.ui.view">
<field name="name">sync.promise.date.wizard.form</field>
<field name="model">sync.promise.date.wizard</field>