From ddc46950eb87a8a86bcde41eab0235189d014edf Mon Sep 17 00:00:00 2001 From: Cybrosys Technologies Date: Fri, 13 Jun 2025 08:53:25 +0530 Subject: [PATCH] Jun 13: [FIX] Bug fixed 'base_accounting_kit' --- base_accounting_kit/__manifest__.py | 2 +- base_accounting_kit/doc/RELEASE_NOTES.md | 5 +++ .../models/account_asset_asset.py | 43 ++++++++++++------- .../wizard/asset_depreciation_confirmation.py | 2 + 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/base_accounting_kit/__manifest__.py b/base_accounting_kit/__manifest__.py index 11ecf3ee5..8e77d8858 100644 --- a/base_accounting_kit/__manifest__.py +++ b/base_accounting_kit/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################# { 'name': 'Odoo 18 Full Accounting Kit for Community', - 'version': '18.0.3.0.6', + 'version': '18.0.4.0.6', 'category': 'Accounting', 'live_test_url': 'https://kit.easyinstance.com/web/login?redirect=/odoo/accounting', 'summary': """Odoo 18 Accounting, Odoo 18 Accounting Reports, Odoo18 Accounting, Odoo Accounting, Odoo18 Financial Reports, Odoo18 Asset, Odoo18 Profit and Loss, PDC, Followups, Odoo18, Accounting, Odoo Apps, Reports""", diff --git a/base_accounting_kit/doc/RELEASE_NOTES.md b/base_accounting_kit/doc/RELEASE_NOTES.md index 40b45e87b..c266eec37 100644 --- a/base_accounting_kit/doc/RELEASE_NOTES.md +++ b/base_accounting_kit/doc/RELEASE_NOTES.md @@ -39,3 +39,8 @@ #### Version 18.0.3.0.6 #### FIX - Fixed the CSV bank statement import errors for unformatted files. + +#### 12.06.2025 +#### Version 18.0.4.0.6 +#### FIX +- Updated the generation of asset entry when the compute depreciation button click. diff --git a/base_accounting_kit/models/account_asset_asset.py b/base_accounting_kit/models/account_asset_asset.py index a8ccb6ff5..2c9764a98 100644 --- a/base_accounting_kit/models/account_asset_asset.py +++ b/base_accounting_kit/models/account_asset_asset.py @@ -324,13 +324,17 @@ class AccountAssetAsset(models.Model): year = depreciation_date.year self.write({'depreciation_line_ids': commands}) - + last_depr_date = None + if self.depreciation_line_ids: + last_depr_date = max(self.depreciation_line_ids.mapped('depreciation_date')) + if last_depr_date: + self._compute_entries(date=last_depr_date) return True def validate(self): """Update the state to 'open' and track specific fields based on the asset's method.""" self.write({'state': 'open'}) - fields = [ + field = [ 'method', 'method_number', 'method_period', @@ -340,7 +344,7 @@ class AccountAssetAsset(models.Model): 'salvage_value', 'invoice_id', ] - ref_tracked_fields = self.env['account.asset.asset'].fields_get(fields) + ref_tracked_fields = self.env['account.asset.asset'].fields_get(field) for asset in self: tracked_fields = ref_tracked_fields.copy() if asset.method == 'linear': @@ -351,20 +355,28 @@ class AccountAssetAsset(models.Model): del (tracked_fields['method_number']) dummy, tracking_value_ids = asset._mail_track(tracked_fields, dict.fromkeys( - fields)) + field)) asset.message_post(subject=_('Asset created'), tracking_value_ids=tracking_value_ids) - return { - 'name': _('Asset Depreciation Confirmation'), - 'type': 'ir.actions.act_window', - 'res_model': 'asset.depreciation.confirmation', - 'view_mode': 'form', - 'target': 'new', - 'context': { - 'default_date': Date.today(), - 'asset_type': self.type, - }, - } + + today_date = fields.Date.context_today(self) + + # Split lines based on depreciation_date + draft_lines = asset.depreciation_line_ids.filtered(lambda l: l.move_id and l.move_id.state == 'draft') + + #Post only entries before today + lines_to_post_now = draft_lines.filtered(lambda l: l.depreciation_date < today_date) + moves_to_post_now = lines_to_post_now.mapped('move_id') + if moves_to_post_now: + moves_to_post_now._post() + + #Set auto_post='at_date' for entries today or later + future_lines = draft_lines.filtered(lambda l: l.depreciation_date >= today_date) + future_moves = future_lines.mapped('move_id') + if future_moves: + future_moves.write({'auto_post': 'at_date'}) + + return True def _get_disposal_moves(self): @@ -544,6 +556,7 @@ class AccountAssetAsset(models.Model): 'name': _('Journal Entries'), 'view_mode': 'list,form', 'res_model': 'account.move', + 'views': [(self.env.ref('account.view_move_tree').id, 'list'), (False, 'form')], 'view_id': False, 'type': 'ir.actions.act_window', 'domain': [('id', 'in', move_ids)], diff --git a/base_accounting_kit/wizard/asset_depreciation_confirmation.py b/base_accounting_kit/wizard/asset_depreciation_confirmation.py index b2cf498e3..f800d4c68 100644 --- a/base_accounting_kit/wizard/asset_depreciation_confirmation.py +++ b/base_accounting_kit/wizard/asset_depreciation_confirmation.py @@ -46,3 +46,5 @@ class AssetDepreciationConfirmationWizard(models.TransientModel): 'domain': "[('id','in',[" + ','.join(str(id) for id in created_move_ids) + "])]", 'type': 'ir.actions.act_window', } + +