diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2026-02-12 14:18:25 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2026-02-12 14:18:25 +0700 |
| commit | 387334dc0929087ac51cc09a90d2db15d79413f1 (patch) | |
| tree | 2d2f48a8da7fdb6f92d6e02f3696dec97dcf34ba | |
| parent | 6c749fd5c8deee7e38cc123b77e06b938bdcc3b3 (diff) | |
automatic reconcile by GL and automatic penyusutan asset
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move_line.py | 65 | ||||
| -rw-r--r-- | indoteknik_custom/models/update_depreciation_move_wizard.py | 48 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_move_line.xml | 12 | ||||
| -rw-r--r-- | indoteknik_custom/views/update_depreciation_move_wizard_view.xml | 35 |
7 files changed, 163 insertions, 2 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 61eef35b..51cfa592 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -193,7 +193,8 @@ 'views/close_tempo_mail_template.xml', 'views/domain_apo.xml', 'views/uom_uom.xml', - 'views/commission_internal.xml' + 'views/commission_internal.xml', + 'views/update_depreciation_move_wizard_view.xml' ], 'demo': [], 'css': [], diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index a14c766e..19a96bee 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -165,3 +165,4 @@ from . import partial_delivery from . import domain_apo from . import uom_uom from . import commission_internal +from . import update_depreciation_move_wizard
\ No newline at end of file diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 7c95d4ef..5edea25f 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -1,5 +1,5 @@ from odoo import models, api, fields - +from odoo.exceptions import AccessError, UserError, ValidationError class AccountMoveLine(models.Model): _inherit = "account.move.line" @@ -9,6 +9,69 @@ class AccountMoveLine(models.Model): analytic_account_ids = fields.Many2many('account.analytic.account', string='Analytic Account') line_no = fields.Integer('No', default=0) + def action_gl_reconcile(self): + lines = self + + journal = self.env['account.journal'].search([ + ('suspense_account_id', '=', lines[0].account_id.id) + ], limit=1) + + if not journal: + raise UserError('Journal dengan suspense account ini tidak ditemukan!') + + statement = self.env['account.bank.statement'].create({ + 'journal_id': journal.id, + 'name': f'REKONSIL {journal.name} {lines[0].date.strftime("%d-%m-%Y")}', + 'company_id': self.env.company.id, + 'date': lines[0].date, + }) + + widget_vals = [] + st_line_ids = [] + + for line in lines: + amount = line.debit - line.credit + + st_line = self.env['account.bank.statement.line'].create({ + 'statement_id': statement.id, + 'date': line.date or fields.Date.today(), + 'payment_ref': line.name, + 'partner_id': line.partner_id.id, + 'amount': amount, + 'ref': line.name, + }) + + st_line_ids.append(st_line.id) + + widget_vals.append({ + 'partner_id': st_line.partner_id.id, + 'counterpart_aml_dicts': [{ + 'counterpart_aml_id': line.id, + 'debit': abs(amount) if amount < 0 else 0, + 'credit': abs(amount) if amount > 0 else 0, + 'name': line.name or '/', + }], + 'payment_aml_ids': [], + 'new_aml_dicts': [], + 'to_check': False, + }) + + statement.button_post() + + self.env['account.reconciliation.widget'].process_bank_statement_line( + st_line_ids, + widget_vals + ) + # statement.button_validate_or_action() + + return { + 'effect': { + 'fadeout': 'slow', + 'message': 'Statement + Auto Reconcile sukses besar 😎🔥', + 'type': 'rainbow_man', + } + } + @api.onchange('account_id') def _onchange_account_id(self): for account in self: diff --git a/indoteknik_custom/models/update_depreciation_move_wizard.py b/indoteknik_custom/models/update_depreciation_move_wizard.py new file mode 100644 index 00000000..7d465f1d --- /dev/null +++ b/indoteknik_custom/models/update_depreciation_move_wizard.py @@ -0,0 +1,48 @@ +from odoo import models, fields, api +from odoo.exceptions import UserError + +class UpdateDepreciationMoveWizard(models.TransientModel): + _name = 'update.depreciation.move.wizard' + _description = 'Wizard untuk Update Move Check Depreciation Line' + + target_date = fields.Date(string="Tanggal Depresiasi", required=True) + + # def action_update_move_check(self): + # lines = self.env['account.asset.depreciation.line'].search([ + # ('depreciation_date', '=', self.target_date), + # ]) + # if not lines: + # raise UserError("Tidak ada baris depresiasi dengan tanggal tersebut.") + + # updated_count = 0 + # for line in lines: + # if not line.move_check: + # line.move_check = True + # line.move_posted_check = True + # updated_count += 1 + + # return { + # 'type': 'ir.actions.client', + # 'tag': 'display_notification', + # 'params': { + # 'title': 'Update Selesai', + # 'message': f'{updated_count} baris berhasil di-update.', + # 'type': 'success', + # 'sticky': False, + # } + # } + + def action_update_move_check(self): + assets = self.env['account.asset.asset'] + assets.compute_generated_entries(self.target_date) + + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': 'Update Selesai', + 'message': 'Depresiasi berhasil di-update.', + 'type': 'success', + 'sticky': False, + } + }
\ 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 d501de1a..bc290370 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -215,3 +215,4 @@ access_surat_piutang_user,surat.piutang user,model_surat_piutang,,1,1,1,1 access_surat_piutang_line_user,surat.piutang.line user,model_surat_piutang_line,,1,1,1,1 access_sj_tele,access.sj.tele,model_sj_tele,base.group_system,1,1,1,1 access_stock_picking_sj_document,stock.picking.sj.document,model_stock_picking_sj_document,base.group_user,1,1,1,1 +access_update_depreciation_move_wizard,access.update.depreciation.move.wizard,model_update_depreciation_move_wizard,,1,1,1,1
\ No newline at end of file diff --git a/indoteknik_custom/views/account_move_line.xml b/indoteknik_custom/views/account_move_line.xml index cb24a0f0..838596c8 100644 --- a/indoteknik_custom/views/account_move_line.xml +++ b/indoteknik_custom/views/account_move_line.xml @@ -22,4 +22,16 @@ </field> </record> </data> + <data> + <record id="action_gl_reconcile_server" model="ir.actions.server"> + <field name="name">Reconcile Selected</field> + <field name="model_id" ref="account.model_account_move_line"/> + <field name="binding_model_id" ref="account.model_account_move_line"/> + <field name="binding_view_types">list</field> + <field name="state">code</field> + <field name="code"> + action = records.action_gl_reconcile() + </field> + </record> + </data> </odoo> diff --git a/indoteknik_custom/views/update_depreciation_move_wizard_view.xml b/indoteknik_custom/views/update_depreciation_move_wizard_view.xml new file mode 100644 index 00000000..ff128a71 --- /dev/null +++ b/indoteknik_custom/views/update_depreciation_move_wizard_view.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <record id="view_update_depreciation_move_wizard_form" model="ir.ui.view"> + <field name="name">update.depreciation.move.wizard.form</field> + <field name="model">update.depreciation.move.wizard</field> + <field name="arch" type="xml"> + <form string="Update Move Check"> + <group> + <field name="target_date"/> + </group> + <footer> + <button string="Update" type="object" name="action_update_move_check" class="btn-primary"/> + <button string="Batal" special="cancel" class="btn-secondary"/> + </footer> + </form> + </field> + </record> + + <record id="update_depreciation_move_wizard_action" model="ir.actions.act_window"> + <field name="name">Update Depreciation Asset</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">update.depreciation.move.wizard</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + <menuitem + id="menu_update_depreciation_move_wizard" + name="Update Depreciation Asset" + parent="account.menu_finance_entries_management" + sequence="4" + action="update_depreciation_move_wizard_action" + /> +</odoo> +
\ No newline at end of file |
