Browse Source

Aug 30 [UPDT] Updated 'base_accounting_kit'

14.0
AjmalCybro 8 months ago
parent
commit
ef5183bcfd
  1. 7
      base_accounting_kit/doc/changelog.md
  2. 44
      base_accounting_kit/models/account_asset.py
  3. 20
      base_accounting_kit/security/security.xml

7
base_accounting_kit/doc/changelog.md

@ -104,9 +104,4 @@
#### 14.01.2022 #### 14.01.2022
#### Version 14.0.3.13.14 #### Version 14.0.3.13.14
#### FIX #### FIX
- Dashboard cash and bank balance issue fix - Dashboard cash and bank balance issue fix
#### 23.04.2024
#### Version 14.0.3.13.15
#### FIX
- Residual value and Archive issue Fix

44
base_accounting_kit/models/account_asset.py

@ -57,8 +57,7 @@ class AccountAssetCategory(models.Model):
journal_id = fields.Many2one('account.journal', string='Journal', journal_id = fields.Many2one('account.journal', string='Journal',
required=True) required=True)
company_id = fields.Many2one('res.company', string='Company', company_id = fields.Many2one('res.company', string='Company',
required=True, required=True, default=lambda self: self.env.company)
default=lambda self: self.env.company)
method = fields.Selection( method = fields.Selection(
[('linear', 'Linear'), ('degressive', 'Degressive')], [('linear', 'Linear'), ('degressive', 'Degressive')],
string='Computation Method', required=True, default='linear', string='Computation Method', required=True, default='linear',
@ -201,7 +200,7 @@ class AccountAssetAsset(models.Model):
if asset.state in ['open', 'close']: if asset.state in ['open', 'close']:
raise UserError( raise UserError(
_('You cannot delete a document is in %s state.') % ( _('You cannot delete a document is in %s state.') % (
asset.state,)) asset.state,))
for depreciation_line in asset.depreciation_line_ids: for depreciation_line in asset.depreciation_line_ids:
if depreciation_line.move_id: if depreciation_line.move_id:
raise UserError(_( raise UserError(_(
@ -267,16 +266,16 @@ class AccountAssetAsset(models.Model):
if self.method_period % 12 != 0: if self.method_period % 12 != 0:
date = datetime.strptime(str(self.date), '%Y-%m-%d') date = datetime.strptime(str(self.date), '%Y-%m-%d')
month_days = \ month_days = \
calendar.monthrange(date.year, date.month)[1] calendar.monthrange(date.year, date.month)[1]
days = month_days - date.day + 1 days = month_days - date.day + 1
amount = ( amount = (
amount_to_depr / self.method_number) / month_days * days amount_to_depr / self.method_number) / month_days * days
else: else:
days = (self.company_id.compute_fiscalyear_dates( days = (self.company_id.compute_fiscalyear_dates(
depreciation_date)[ depreciation_date)[
'date_to'] - depreciation_date).days + 1 'date_to'] - depreciation_date).days + 1
amount = ( amount = (
amount_to_depr / self.method_number) / total_days * days amount_to_depr / self.method_number) / total_days * days
elif self.method == 'degressive': elif self.method == 'degressive':
amount = residual_amount * self.method_progress_factor amount = residual_amount * self.method_progress_factor
if self.prorata: if self.prorata:
@ -284,16 +283,16 @@ class AccountAssetAsset(models.Model):
if self.method_period % 12 != 0: if self.method_period % 12 != 0:
date = datetime.strptime(str(self.date), '%Y-%m-%d') date = datetime.strptime(str(self.date), '%Y-%m-%d')
month_days = \ month_days = \
calendar.monthrange(date.year, date.month)[1] calendar.monthrange(date.year, date.month)[1]
days = month_days - date.day + 1 days = month_days - date.day + 1
amount = ( amount = (
residual_amount * self.method_progress_factor) / month_days * days residual_amount * self.method_progress_factor) / month_days * days
else: else:
days = (self.company_id.compute_fiscalyear_dates( days = (self.company_id.compute_fiscalyear_dates(
depreciation_date)[ depreciation_date)[
'date_to'] - depreciation_date).days + 1 'date_to'] - depreciation_date).days + 1
amount = ( amount = (
residual_amount * self.method_progress_factor) / total_days * days residual_amount * self.method_progress_factor) / total_days * days
return amount return amount
def _compute_board_undone_dotation_nb(self, depreciation_date, total_days): def _compute_board_undone_dotation_nb(self, depreciation_date, total_days):
@ -396,7 +395,7 @@ class AccountAssetAsset(models.Model):
'name': (self.code or '') + '/' + str(sequence), 'name': (self.code or '') + '/' + str(sequence),
'remaining_value': residual_amount, 'remaining_value': residual_amount,
'depreciated_value': self.value - ( 'depreciated_value': self.value - (
self.salvage_value + residual_amount), self.salvage_value + residual_amount),
'depreciation_date': depreciation_date.strftime(DF), 'depreciation_date': depreciation_date.strftime(DF),
} }
commands.append((0, False, vals)) commands.append((0, False, vals))
@ -437,8 +436,6 @@ class AccountAssetAsset(models.Model):
fields)) fields))
asset.message_post(subject=_('Asset created'), asset.message_post(subject=_('Asset created'),
tracking_value_ids=tracking_value_ids) tracking_value_ids=tracking_value_ids)
if self.value_residual == 0.0:
self.write({'state': 'close'})
def _get_disposal_moves(self): def _get_disposal_moves(self):
move_ids = [] move_ids = []
@ -479,9 +476,8 @@ class AccountAssetAsset(models.Model):
tracked_fields, old_values) tracked_fields, old_values)
if changes: if changes:
asset.message_post(subject=_( asset.message_post(subject=_(
'Asset sold or disposed. Accounting entry awaiting ' 'Asset sold or disposed. Accounting entry awaiting for validation.'),
'for validation.'), tracking_value_ids=tracking_value_ids)
tracking_value_ids=tracking_value_ids)
move_ids += asset.depreciation_line_ids[-1].create_move( move_ids += asset.depreciation_line_ids[-1].create_move(
post_move=False) post_move=False)
@ -489,7 +485,6 @@ class AccountAssetAsset(models.Model):
def set_to_close(self): def set_to_close(self):
move_ids = self._get_disposal_moves() move_ids = self._get_disposal_moves()
self.write({'state': 'close'})
if move_ids: if move_ids:
name = _('Disposal Move') name = _('Disposal Move')
view_mode = 'form' view_mode = 'form'
@ -504,6 +499,8 @@ class AccountAssetAsset(models.Model):
'target': 'current', 'target': 'current',
'res_id': move_ids[0], 'res_id': move_ids[0],
} }
# Fallback, as if we just clicked on the smartbutton
return self.open_entries()
def set_to_draft(self): def set_to_draft(self):
self.write({'state': 'draft'}) self.write({'state': 'draft'})
@ -533,15 +530,7 @@ class AccountAssetAsset(models.Model):
def _check_prorata(self): def _check_prorata(self):
if self.prorata and self.method_time != 'number': if self.prorata and self.method_time != 'number':
raise ValidationError(_( raise ValidationError(_(
'Prorata temporis can be applied only for time method "number ' 'Prorata temporis can be applied only for time method "number of depreciations".'))
'of depreciations".'))
@api.constrains('active', 'state')
def _check_active(self):
for record in self:
if not record.active and record.state not in ['draft', 'close']:
raise UserError(
"You cannot archive a record in a running state.")
@api.onchange('category_id') @api.onchange('category_id')
def onchange_category_id(self): def onchange_category_id(self):
@ -633,8 +622,7 @@ class AccountAssetDepreciationLine(models.Model):
required=True) required=True)
depreciation_date = fields.Date('Depreciation Date', index=True) depreciation_date = fields.Date('Depreciation Date', index=True)
move_id = fields.Many2one('account.move', string='Depreciation Entry') move_id = fields.Many2one('account.move', string='Depreciation Entry')
move_check = fields.Boolean(compute='_get_move_check', string='Linked', move_check = fields.Boolean(compute='_get_move_check', string='Linked', store=True)
store=True)
move_posted_check = fields.Boolean(compute='_get_move_posted_check', move_posted_check = fields.Boolean(compute='_get_move_posted_check',
string='Posted', store=True) string='Posted', store=True)
@ -664,7 +652,7 @@ class AccountAssetDepreciationLine(models.Model):
amount = current_currency.with_context( amount = current_currency.with_context(
date=depreciation_date).compute(line.amount, company_currency) date=depreciation_date).compute(line.amount, company_currency)
asset_name = line.asset_id.name + ' (%s/%s)' % ( asset_name = line.asset_id.name + ' (%s/%s)' % (
line.sequence, len(line.asset_id.depreciation_line_ids)) line.sequence, len(line.asset_id.depreciation_line_ids))
partner = self.env['res.partner']._find_accounting_partner( partner = self.env['res.partner']._find_accounting_partner(
line.asset_id.partner_id) line.asset_id.partner_id)
move_line_1 = { move_line_1 = {

20
base_accounting_kit/security/security.xml

@ -5,35 +5,27 @@
<field name="name">Account Asset Category multi-company</field> <field name="name">Account Asset Category multi-company</field>
<field ref="model_account_asset_category" name="model_id"/> <field ref="model_account_asset_category" name="model_id"/>
<field eval="True" name="global"/> <field eval="True" name="global"/>
<field name="domain_force"> <field name="domain_force">['|',('company_id','=',False),'|',('company_id','child_of',[user.company_id.id]),('company_id','=',user.company_id.id)]</field>
['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
</field>
</record> </record>
<record id="account_asset_asset_multi_company_rule" model="ir.rule"> <record id="account_asset_asset_multi_company_rule" model="ir.rule">
<field name="name">Account Asset multi-company</field> <field name="name">Account Asset multi-company</field>
<field ref="model_account_asset_asset" name="model_id"/> <field ref="model_account_asset_asset" name="model_id"/>
<field eval="True" name="global"/> <field eval="True" name="global"/>
<field name="domain_force"> <field name="domain_force">['|',('company_id','=',False),'|',('company_id','child_of',[user.company_id.id]),('company_id','=',user.company_id.id)]</field>
['|',('company_id','=',False),('company_id', 'in', company_ids)]
</field>
</record> </record>
<!-- Rename user group as Accountant --> <!-- Rename user group as Accountant -->
<record id="account.group_account_user" model="res.groups"> <record id="account.group_account_user" model="res.groups">
<field name="name">Accountant</field> <field name="name">Accountant</field>
<field name="implied_ids" <field name="implied_ids" eval="[(4, ref('account.group_account_invoice'))]"/>
eval="[(4, ref('account.group_account_invoice'))]"/> <field name="category_id" ref="base.module_category_accounting_accounting"/>
<field name="category_id"
ref="base.module_category_accounting_accounting"/>
</record> </record>
<!-- Rename user group as Chief Accountant --> <!-- Rename user group as Chief Accountant -->
<record id="account.group_account_manager" model="res.groups"> <record id="account.group_account_manager" model="res.groups">
<field name="name">Chief Accountant</field> <field name="name">Chief Accountant</field>
<field name="implied_ids" <field name="implied_ids" eval="[(3, ref('account.group_account_invoice')), (4, ref('account.group_account_user'))]"/>
eval="[(3, ref('account.group_account_invoice')), (4, ref('account.group_account_user'))]"/> <field name="category_id" ref="base.module_category_accounting_accounting"/>
<field name="category_id"
ref="base.module_category_accounting_accounting"/>
</record> </record>
</data> </data>
</odoo> </odoo>

Loading…
Cancel
Save