2018-08-05 20:33:56 +02:00
|
|
|
# Copyright (c) 2014 ACSONE SA/NV (acsone.eu).
|
|
|
|
# Copyright 2009-2018 Noviat
|
2021-01-14 08:53:25 +01:00
|
|
|
# Copyright 2021 Tecnativa - João Marques
|
2018-08-05 20:33:56 +02:00
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
2015-02-12 11:51:18 +01:00
|
|
|
|
2018-08-05 20:33:56 +02:00
|
|
|
import calendar
|
2015-02-12 11:51:18 +01:00
|
|
|
import time
|
2020-01-29 18:34:31 +01:00
|
|
|
from datetime import date, datetime
|
2015-02-12 11:51:18 +01:00
|
|
|
|
2021-04-15 11:14:09 +02:00
|
|
|
from odoo import fields
|
2021-01-14 08:53:25 +01:00
|
|
|
from odoo.tests.common import Form
|
2018-08-05 20:33:56 +02:00
|
|
|
|
2021-01-14 08:53:25 +01:00
|
|
|
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
2015-02-12 11:51:18 +01:00
|
|
|
|
2018-08-05 20:33:56 +02:00
|
|
|
|
2021-01-14 08:53:25 +01:00
|
|
|
class TestAssetManagement(AccountTestInvoicingCommon):
|
2018-10-01 11:57:07 +02:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super().setUpClass()
|
2021-04-19 13:04:19 +02:00
|
|
|
# ENVIRONMENTS
|
2020-01-29 18:34:31 +01:00
|
|
|
cls.asset_model = cls.env["account.asset"]
|
2021-01-14 08:53:25 +01:00
|
|
|
cls.asset_profile_model = cls.env["account.asset.profile"]
|
2020-01-29 18:34:31 +01:00
|
|
|
cls.dl_model = cls.env["account.asset.line"]
|
|
|
|
cls.remove_model = cls.env["account.asset.remove"]
|
2018-08-05 20:33:56 +02:00
|
|
|
# INSTANCES
|
2021-01-14 08:53:25 +01:00
|
|
|
cls.partner = cls.env["res.partner"].create({"name": "Test Partner"})
|
|
|
|
cls.product = cls.env["product.product"].create(
|
|
|
|
{"name": "Test", "standard_price": 500.0}
|
|
|
|
)
|
2020-01-29 18:37:08 +01:00
|
|
|
move_form = Form(
|
|
|
|
cls.env["account.move"].with_context(
|
2021-01-14 08:53:25 +01:00
|
|
|
default_move_type="in_invoice", check_move_validity=False
|
2020-01-29 18:37:08 +01:00
|
|
|
)
|
2020-01-29 18:34:31 +01:00
|
|
|
)
|
2021-04-15 11:14:09 +02:00
|
|
|
move_form.invoice_date = fields.Date.context_today(cls.env.user)
|
2020-01-29 18:37:08 +01:00
|
|
|
move_form.partner_id = cls.partner
|
|
|
|
with move_form.invoice_line_ids.new() as line_form:
|
|
|
|
line_form.name = "test"
|
|
|
|
line_form.product_id = cls.product
|
|
|
|
line_form.price_unit = 2000.00
|
|
|
|
line_form.quantity = 1
|
|
|
|
cls.invoice = move_form.save()
|
|
|
|
move_form = Form(
|
|
|
|
cls.env["account.move"].with_context(
|
2021-01-14 08:53:25 +01:00
|
|
|
default_move_type="in_invoice", check_move_validity=False
|
2020-01-29 18:37:08 +01:00
|
|
|
)
|
2020-01-29 18:34:31 +01:00
|
|
|
)
|
2021-04-15 11:14:09 +02:00
|
|
|
move_form.invoice_date = fields.Date.context_today(cls.env.user)
|
2020-01-29 18:37:08 +01:00
|
|
|
move_form.partner_id = cls.partner
|
|
|
|
with move_form.invoice_line_ids.new() as line_form:
|
|
|
|
line_form.name = "test 2"
|
|
|
|
line_form.product_id = cls.product
|
|
|
|
line_form.price_unit = 10000.00
|
|
|
|
line_form.quantity = 1
|
|
|
|
with move_form.invoice_line_ids.new() as line_form:
|
|
|
|
line_form.name = "test 3"
|
|
|
|
line_form.product_id = cls.product
|
|
|
|
line_form.price_unit = 20000.00
|
|
|
|
line_form.quantity = 1
|
|
|
|
cls.invoice_2 = move_form.save()
|
2021-04-06 15:24:08 +02:00
|
|
|
|
|
|
|
# analytic configuration
|
|
|
|
cls.env.user.write(
|
|
|
|
{
|
|
|
|
"groups_id": [
|
|
|
|
(4, cls.env.ref("analytic.group_analytic_accounting").id),
|
|
|
|
(4, cls.env.ref("analytic.group_analytic_tags").id),
|
|
|
|
],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
cls.analytic_account = cls.env["account.analytic.account"].create(
|
|
|
|
{"name": "test_analytic_account"}
|
|
|
|
)
|
|
|
|
cls.analytic_tag = cls.env["account.analytic.tag"].create(
|
|
|
|
{"name": "test_analytic_tag"}
|
|
|
|
)
|
|
|
|
|
2021-01-14 08:53:25 +01:00
|
|
|
# Asset Profile 1
|
|
|
|
cls.ict3Y = cls.asset_profile_model.create(
|
|
|
|
{
|
|
|
|
"account_expense_depreciation_id": cls.company_data[
|
|
|
|
"default_account_expense"
|
|
|
|
].id,
|
|
|
|
"account_asset_id": cls.company_data["default_account_assets"].id,
|
|
|
|
"account_depreciation_id": cls.company_data[
|
|
|
|
"default_account_assets"
|
|
|
|
].id,
|
|
|
|
"journal_id": cls.company_data["default_journal_purchase"].id,
|
|
|
|
"name": "Hardware - 3 Years",
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 3,
|
|
|
|
"method_period": "year",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
# Asset Profile 2
|
|
|
|
cls.car5y = cls.asset_profile_model.create(
|
|
|
|
{
|
|
|
|
"account_expense_depreciation_id": cls.company_data[
|
|
|
|
"default_account_expense"
|
|
|
|
].id,
|
|
|
|
"account_asset_id": cls.company_data["default_account_assets"].id,
|
|
|
|
"account_depreciation_id": cls.company_data[
|
|
|
|
"default_account_assets"
|
|
|
|
].id,
|
|
|
|
"journal_id": cls.company_data["default_journal_purchase"].id,
|
|
|
|
"name": "Cars - 5 Years",
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "year",
|
2021-04-06 15:24:08 +02:00
|
|
|
"account_analytic_id": cls.analytic_account.id,
|
|
|
|
"analytic_tag_ids": [(4, cls.analytic_tag.id)],
|
2021-01-14 08:53:25 +01:00
|
|
|
}
|
|
|
|
)
|
2019-05-24 08:30:45 +02:00
|
|
|
|
2021-03-11 09:18:10 +01:00
|
|
|
def test_invoice_line_without_product(self):
|
|
|
|
tax = self.env["account.tax"].create(
|
|
|
|
{
|
|
|
|
"name": "TAX 15%",
|
|
|
|
"amount_type": "percent",
|
|
|
|
"type_tax_use": "purchase",
|
|
|
|
"amount": 15.0,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
move_form = Form(
|
|
|
|
self.env["account.move"].with_context(
|
|
|
|
default_move_type="in_invoice", check_move_validity=False
|
|
|
|
)
|
|
|
|
)
|
2021-04-15 11:14:09 +02:00
|
|
|
move_form.invoice_date = fields.Date.context_today(self.env.user)
|
2021-03-11 09:18:10 +01:00
|
|
|
move_form.partner_id = self.partner
|
|
|
|
with move_form.invoice_line_ids.new() as line_form:
|
|
|
|
line_form.name = "Line 1"
|
|
|
|
line_form.price_unit = 200.0
|
|
|
|
line_form.quantity = 1
|
|
|
|
line_form.tax_ids.clear()
|
|
|
|
line_form.tax_ids.add(tax)
|
|
|
|
invoice = move_form.save()
|
|
|
|
self.assertEqual(invoice.partner_id, self.partner)
|
|
|
|
|
2021-03-22 08:11:23 +01:00
|
|
|
def test_00_fiscalyear_lock_date_month(self):
|
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
|
|
|
"profile_id": self.car5y.id,
|
|
|
|
"purchase_value": 1500,
|
|
|
|
"date_start": "1901-02-01",
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 3,
|
|
|
|
"method_period": "month",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.refresh()
|
|
|
|
self.assertTrue(asset.depreciation_line_ids[0].init_entry)
|
|
|
|
for i in range(1, 36):
|
|
|
|
self.assertFalse(asset.depreciation_line_ids[i].init_entry)
|
|
|
|
|
|
|
|
def test_00_fiscalyear_lock_date_year(self):
|
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
|
|
|
"profile_id": self.car5y.id,
|
|
|
|
"purchase_value": 1500,
|
|
|
|
"date_start": "1901-02-01",
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 3,
|
|
|
|
"method_period": "year",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.refresh()
|
|
|
|
self.assertTrue(asset.depreciation_line_ids[0].init_entry)
|
|
|
|
for i in range(1, 4):
|
|
|
|
self.assertFalse(asset.depreciation_line_ids[i].init_entry)
|
|
|
|
|
2018-08-05 20:33:56 +02:00
|
|
|
def test_01_nonprorata_basic(self):
|
|
|
|
"""Basic tests of depreciation board computations and postings."""
|
2021-01-14 08:53:25 +01:00
|
|
|
# First create demo assets and do some sanity checks
|
|
|
|
# Asset Model 1
|
|
|
|
ict0 = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"state": "draft",
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 3,
|
|
|
|
"method_period": "year",
|
|
|
|
"name": "Laptop",
|
|
|
|
"code": "PI00101",
|
|
|
|
"purchase_value": 1500.0,
|
|
|
|
"profile_id": self.ict3Y.id,
|
|
|
|
"date_start": time.strftime("%Y-01-01"),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
# Sanity checks
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertEqual(ict0.state, "draft")
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(ict0.purchase_value, 1500)
|
|
|
|
self.assertEqual(ict0.salvage_value, 0)
|
|
|
|
self.assertEqual(ict0.depreciation_base, 1500)
|
|
|
|
self.assertEqual(len(ict0.depreciation_line_ids), 1)
|
2021-01-14 08:53:25 +01:00
|
|
|
# Asset Model 2
|
|
|
|
vehicle0 = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"state": "draft",
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "year",
|
|
|
|
"name": "CEO's Car",
|
|
|
|
"purchase_value": 12000.0,
|
|
|
|
"salvage_value": 2000.0,
|
|
|
|
"profile_id": self.car5y.id,
|
|
|
|
"date_start": time.strftime("%Y-01-01"),
|
|
|
|
}
|
2020-01-29 18:34:31 +01:00
|
|
|
)
|
2021-01-14 08:53:25 +01:00
|
|
|
# Sanity checks
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertEqual(vehicle0.state, "draft")
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(vehicle0.purchase_value, 12000)
|
|
|
|
self.assertEqual(vehicle0.salvage_value, 2000)
|
|
|
|
self.assertEqual(vehicle0.depreciation_base, 10000)
|
|
|
|
self.assertEqual(len(vehicle0.depreciation_line_ids), 1)
|
2021-01-14 08:53:25 +01:00
|
|
|
# Compute the depreciation boards
|
2018-08-05 20:33:56 +02:00
|
|
|
ict0.compute_depreciation_board()
|
2015-02-12 11:51:18 +01:00
|
|
|
ict0.refresh()
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(len(ict0.depreciation_line_ids), 4)
|
|
|
|
self.assertEqual(ict0.depreciation_line_ids[1].amount, 500)
|
2018-08-05 20:33:56 +02:00
|
|
|
vehicle0.compute_depreciation_board()
|
2015-02-12 11:51:18 +01:00
|
|
|
vehicle0.refresh()
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(len(vehicle0.depreciation_line_ids), 6)
|
|
|
|
self.assertEqual(vehicle0.depreciation_line_ids[1].amount, 2000)
|
2021-01-14 08:53:25 +01:00
|
|
|
# Post the first depreciation line
|
2015-02-12 11:51:18 +01:00
|
|
|
ict0.validate()
|
|
|
|
ict0.depreciation_line_ids[1].create_move()
|
|
|
|
ict0.refresh()
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertEqual(ict0.state, "open")
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(ict0.value_depreciated, 500)
|
|
|
|
self.assertEqual(ict0.value_residual, 1000)
|
2015-02-12 11:51:18 +01:00
|
|
|
vehicle0.validate()
|
2021-04-06 15:24:08 +02:00
|
|
|
created_move_ids = vehicle0.depreciation_line_ids[1].create_move()
|
|
|
|
for move_id in created_move_ids:
|
|
|
|
move = self.env["account.move"].browse(move_id)
|
|
|
|
expense_line = move.line_ids.filtered(
|
|
|
|
lambda line: line.account_id.internal_group == "expense"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
expense_line.analytic_account_id.id,
|
|
|
|
self.analytic_account.id,
|
|
|
|
)
|
|
|
|
self.assertEqual(expense_line.analytic_tag_ids.id, self.analytic_tag.id)
|
2015-02-12 11:51:18 +01:00
|
|
|
vehicle0.refresh()
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertEqual(vehicle0.state, "open")
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(vehicle0.value_depreciated, 2000)
|
|
|
|
self.assertEqual(vehicle0.value_residual, 8000)
|
2015-02-12 11:51:18 +01:00
|
|
|
|
2018-08-05 20:33:56 +02:00
|
|
|
def test_02_prorata_basic(self):
|
2015-02-12 11:51:18 +01:00
|
|
|
"""Prorata temporis depreciation basic test."""
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 3333,
|
|
|
|
"salvage_value": 0,
|
|
|
|
"date_start": time.strftime("%Y-07-07"),
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "month",
|
|
|
|
"prorata": True,
|
|
|
|
}
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
asset.compute_depreciation_board()
|
2015-02-12 11:51:18 +01:00
|
|
|
asset.refresh()
|
2018-08-05 20:33:56 +02:00
|
|
|
if calendar.isleap(date.today().year):
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[1].amount, 46.44, places=2
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
else:
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[1].amount, 47.33, places=2
|
|
|
|
)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount, 55.55, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[3].amount, 55.55, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[4].amount, 55.55, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[5].amount, 55.55, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[6].amount, 55.55, places=2)
|
2018-08-05 20:33:56 +02:00
|
|
|
if calendar.isleap(date.today().year):
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[-1].amount, 9.11, places=2
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
else:
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[-1].amount, 8.22, places=2
|
|
|
|
)
|
2015-02-12 11:51:18 +01:00
|
|
|
|
2018-08-05 20:33:56 +02:00
|
|
|
def test_03_proprata_init_prev_year(self):
|
2015-02-12 11:51:18 +01:00
|
|
|
"""Prorata temporis depreciation with init value in prev year."""
|
2021-01-14 08:53:25 +01:00
|
|
|
# Create an asset in current year
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 3333,
|
|
|
|
"salvage_value": 0,
|
|
|
|
"date_start": "%d-07-07" % (datetime.now().year - 1,),
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "month",
|
|
|
|
"prorata": True,
|
|
|
|
}
|
|
|
|
)
|
2021-01-14 08:53:25 +01:00
|
|
|
# Create a initial depreciation line in previous year
|
2020-01-29 18:34:31 +01:00
|
|
|
self.dl_model.create(
|
|
|
|
{
|
|
|
|
"asset_id": asset.id,
|
|
|
|
"amount": 325.08,
|
|
|
|
"line_date": "%d-12-31" % (datetime.now().year - 1,),
|
|
|
|
"type": "depreciate",
|
|
|
|
"init_entry": True,
|
|
|
|
}
|
|
|
|
)
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(len(asset.depreciation_line_ids), 2)
|
2018-08-05 20:33:56 +02:00
|
|
|
asset.compute_depreciation_board()
|
2015-02-12 11:51:18 +01:00
|
|
|
asset.refresh()
|
2021-01-14 08:53:25 +01:00
|
|
|
# check the depreciated value is the initial value
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(asset.value_depreciated, 325.08, places=2)
|
2021-01-14 08:53:25 +01:00
|
|
|
# check computed values in the depreciation board
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[3].amount, 55.55, places=2)
|
2018-08-05 20:33:56 +02:00
|
|
|
if calendar.isleap(date.today().year - 1):
|
|
|
|
# for leap years the first year depreciation amount of 325.08
|
|
|
|
# is too high and hence a correction is applied to the next
|
|
|
|
# entry of the table
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[2].amount, 54.66, places=2
|
|
|
|
)
|
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[3].amount, 55.55, places=2
|
|
|
|
)
|
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[-1].amount, 9.11, places=2
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
else:
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[2].amount, 55.55, places=2
|
|
|
|
)
|
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[-1].amount, 8.22, places=2
|
|
|
|
)
|
2015-02-12 11:51:18 +01:00
|
|
|
|
2018-08-05 20:33:56 +02:00
|
|
|
def test_04_prorata_init_cur_year(self):
|
2015-02-12 11:51:18 +01:00
|
|
|
"""Prorata temporis depreciation with init value in curent year."""
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 3333,
|
|
|
|
"salvage_value": 0,
|
|
|
|
"date_start": time.strftime("%Y-07-07"),
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "month",
|
|
|
|
"prorata": True,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
self.dl_model.create(
|
|
|
|
{
|
|
|
|
"asset_id": asset.id,
|
|
|
|
"amount": 279.44,
|
|
|
|
"line_date": time.strftime("%Y-11-30"),
|
|
|
|
"type": "depreciate",
|
|
|
|
"init_entry": True,
|
|
|
|
}
|
|
|
|
)
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(len(asset.depreciation_line_ids), 2)
|
2018-08-05 20:33:56 +02:00
|
|
|
asset.compute_depreciation_board()
|
2015-02-12 11:51:18 +01:00
|
|
|
asset.refresh()
|
2021-01-14 08:53:25 +01:00
|
|
|
# check the depreciated value is the initial value
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(asset.value_depreciated, 279.44, places=2)
|
2021-01-14 08:53:25 +01:00
|
|
|
# check computed values in the depreciation board
|
2018-08-05 20:33:56 +02:00
|
|
|
if calendar.isleap(date.today().year):
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[2].amount, 44.75, places=2
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
else:
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[2].amount, 45.64, places=2
|
|
|
|
)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[3].amount, 55.55, places=2)
|
2018-08-05 20:33:56 +02:00
|
|
|
if calendar.isleap(date.today().year):
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[-1].amount, 9.11, places=2
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
else:
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[-1].amount, 8.22, places=2
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
|
|
|
|
def test_05_degressive_linear(self):
|
|
|
|
"""Degressive-Linear with annual and quarterly depreciation."""
|
|
|
|
# annual depreciation
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 1000,
|
|
|
|
"salvage_value": 0,
|
|
|
|
"date_start": time.strftime("%Y-07-07"),
|
|
|
|
"method_time": "year",
|
|
|
|
"method": "degr-linear",
|
|
|
|
"method_progress_factor": 0.40,
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "year",
|
|
|
|
"prorata": False,
|
|
|
|
}
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.refresh()
|
|
|
|
# check values in the depreciation board
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(len(asset.depreciation_line_ids), 5)
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 400.00, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount, 240.00, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[3].amount, 200.00, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[4].amount, 160.00, places=2)
|
2018-08-05 20:33:56 +02:00
|
|
|
# quarterly depreciation
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 1000,
|
|
|
|
"salvage_value": 0,
|
|
|
|
"date_start": time.strftime("%Y-07-07"),
|
|
|
|
"method_time": "year",
|
|
|
|
"method": "degr-linear",
|
|
|
|
"method_progress_factor": 0.40,
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "quarter",
|
|
|
|
"prorata": False,
|
|
|
|
}
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.refresh()
|
|
|
|
# check values in the depreciation board
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(len(asset.depreciation_line_ids), 15)
|
2018-08-05 20:33:56 +02:00
|
|
|
# lines prior to asset start period are grouped in the first entry
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 300.00, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[3].amount, 60.00, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[7].amount, 50.00, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[13].amount, 40.00, places=2)
|
2018-08-05 20:33:56 +02:00
|
|
|
|
|
|
|
def test_06_degressive_limit(self):
|
|
|
|
"""Degressive with annual depreciation."""
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 1000,
|
|
|
|
"salvage_value": 100,
|
|
|
|
"date_start": time.strftime("%Y-07-07"),
|
|
|
|
"method_time": "year",
|
|
|
|
"method": "degr-limit",
|
|
|
|
"method_progress_factor": 0.40,
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "year",
|
|
|
|
"prorata": False,
|
|
|
|
}
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.refresh()
|
|
|
|
# check values in the depreciation board
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(len(asset.depreciation_line_ids), 6)
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 400.00, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount, 240.00, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[3].amount, 144.00, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[4].amount, 86.40, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[5].amount, 29.60, places=2)
|
2018-08-05 20:33:56 +02:00
|
|
|
|
|
|
|
def test_07_linear_limit(self):
|
|
|
|
"""Degressive with annual depreciation."""
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 1000,
|
|
|
|
"salvage_value": 100,
|
|
|
|
"date_start": time.strftime("%Y-07-07"),
|
|
|
|
"method_time": "year",
|
|
|
|
"method": "linear-limit",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "year",
|
|
|
|
"prorata": False,
|
|
|
|
}
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.refresh()
|
|
|
|
# check values in the depreciation board
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(len(asset.depreciation_line_ids), 6)
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 200.00, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[-1].amount, 100.00, places=2)
|
2018-08-05 20:33:56 +02:00
|
|
|
|
|
|
|
def test_08_asset_removal(self):
|
|
|
|
"""Asset removal"""
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset removal",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 5000,
|
|
|
|
"salvage_value": 0,
|
|
|
|
"date_start": "2019-01-01",
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "quarter",
|
|
|
|
"prorata": False,
|
|
|
|
}
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.validate()
|
2020-01-29 18:34:31 +01:00
|
|
|
wiz_ctx = {"active_id": asset.id, "early_removal": True}
|
|
|
|
wiz = self.remove_model.with_context(wiz_ctx).create(
|
|
|
|
{
|
|
|
|
"date_remove": "2019-01-31",
|
|
|
|
"sale_value": 0.0,
|
|
|
|
"posting_regime": "gain_loss_on_sale",
|
2021-01-14 08:53:25 +01:00
|
|
|
"account_plus_value_id": self.company_data[
|
|
|
|
"default_account_revenue"
|
|
|
|
].id,
|
|
|
|
"account_min_value_id": self.company_data["default_account_expense"].id,
|
2020-01-29 18:34:31 +01:00
|
|
|
}
|
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
wiz.remove()
|
|
|
|
asset.refresh()
|
2018-10-01 11:57:07 +02:00
|
|
|
self.assertEqual(len(asset.depreciation_line_ids), 3)
|
2020-08-19 12:08:42 +02:00
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 83.33, places=2)
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount, 4916.67, places=2)
|
2018-08-05 20:33:56 +02:00
|
|
|
|
|
|
|
def test_09_asset_from_invoice(self):
|
2020-01-29 18:34:31 +01:00
|
|
|
all_asset = self.env["account.asset"].search([])
|
2018-08-05 20:33:56 +02:00
|
|
|
invoice = self.invoice
|
2021-01-14 08:53:25 +01:00
|
|
|
asset_profile = self.car5y
|
2018-08-05 20:33:56 +02:00
|
|
|
asset_profile.asset_product_item = False
|
|
|
|
self.assertTrue(len(invoice.invoice_line_ids) > 0)
|
|
|
|
line = invoice.invoice_line_ids[0]
|
|
|
|
self.assertTrue(line.price_unit > 0.0)
|
2020-04-06 19:19:40 +02:00
|
|
|
move_form = Form(invoice)
|
|
|
|
with move_form.invoice_line_ids.edit(0) as line_form:
|
|
|
|
line_form.quantity = 2
|
|
|
|
line_form.asset_profile_id = asset_profile
|
|
|
|
invoice = move_form.save()
|
2021-01-14 08:53:25 +01:00
|
|
|
invoice.action_post()
|
|
|
|
# get all asset after invoice validation
|
2020-01-29 18:34:31 +01:00
|
|
|
current_asset = self.env["account.asset"].search([])
|
2021-01-14 08:53:25 +01:00
|
|
|
# get the new asset
|
2018-08-05 20:33:56 +02:00
|
|
|
new_asset = current_asset - all_asset
|
2021-01-14 08:53:25 +01:00
|
|
|
# check that a new asset is created
|
2018-08-05 20:33:56 +02:00
|
|
|
self.assertEqual(len(new_asset), 1)
|
2021-01-14 08:53:25 +01:00
|
|
|
# check that the new asset has the correct purchase value
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(
|
2020-01-29 18:37:08 +01:00
|
|
|
new_asset.purchase_value, line.price_unit * line.quantity, places=2
|
2020-01-29 18:34:31 +01:00
|
|
|
)
|
2018-08-05 20:33:56 +02:00
|
|
|
|
|
|
|
def test_10_asset_from_invoice_product_item(self):
|
2020-01-29 18:34:31 +01:00
|
|
|
all_asset = self.env["account.asset"].search([])
|
2018-08-05 20:33:56 +02:00
|
|
|
invoice = self.invoice
|
2021-01-14 08:53:25 +01:00
|
|
|
asset_profile = self.car5y
|
2018-08-05 20:33:56 +02:00
|
|
|
asset_profile.asset_product_item = True
|
|
|
|
self.assertTrue(len(invoice.invoice_line_ids) > 0)
|
|
|
|
line = invoice.invoice_line_ids[0]
|
|
|
|
self.assertTrue(line.price_unit > 0.0)
|
|
|
|
line.quantity = 2
|
|
|
|
line.asset_profile_id = asset_profile
|
2020-01-29 18:37:08 +01:00
|
|
|
self.assertEqual(len(invoice.invoice_line_ids), 2)
|
2021-01-14 08:53:25 +01:00
|
|
|
invoice.action_post()
|
|
|
|
# get all asset after invoice validation
|
2020-01-29 18:34:31 +01:00
|
|
|
current_asset = self.env["account.asset"].search([])
|
2021-01-14 08:53:25 +01:00
|
|
|
# get the new asset
|
2018-08-05 20:33:56 +02:00
|
|
|
new_asset = current_asset - all_asset
|
2021-01-14 08:53:25 +01:00
|
|
|
# check that a new asset is created
|
2020-01-29 18:37:08 +01:00
|
|
|
self.assertEqual(len(new_asset), 2)
|
2018-08-05 20:33:56 +02:00
|
|
|
for asset in new_asset:
|
2021-01-14 08:53:25 +01:00
|
|
|
# check that the new asset has the correct purchase value
|
2020-01-29 18:37:08 +01:00
|
|
|
self.assertAlmostEqual(asset.purchase_value, line.price_unit, places=2)
|
2019-05-24 08:30:45 +02:00
|
|
|
|
|
|
|
def test_11_assets_from_invoice(self):
|
2020-01-29 18:34:31 +01:00
|
|
|
all_assets = self.env["account.asset"].search([])
|
2020-01-29 18:37:08 +01:00
|
|
|
ctx = dict(self.invoice_2._context)
|
2021-01-14 08:53:25 +01:00
|
|
|
del ctx["default_move_type"]
|
2020-01-29 18:37:08 +01:00
|
|
|
invoice = self.invoice_2.with_context(ctx)
|
2021-01-14 08:53:25 +01:00
|
|
|
asset_profile = self.car5y
|
2019-05-24 08:30:45 +02:00
|
|
|
asset_profile.asset_product_item = True
|
|
|
|
# Compute depreciation lines on invoice validation
|
|
|
|
asset_profile.open_asset = True
|
|
|
|
self.assertTrue(len(invoice.invoice_line_ids) == 2)
|
2020-01-29 18:34:31 +01:00
|
|
|
invoice.invoice_line_ids.write(
|
|
|
|
{"quantity": 1, "asset_profile_id": asset_profile.id}
|
|
|
|
)
|
2021-01-14 08:53:25 +01:00
|
|
|
invoice.action_post()
|
2019-05-24 08:30:45 +02:00
|
|
|
# Retrieve all assets after invoice validation
|
2020-01-29 18:34:31 +01:00
|
|
|
current_assets = self.env["account.asset"].search([])
|
2019-05-24 08:30:45 +02:00
|
|
|
# What are the new assets?
|
|
|
|
new_assets = current_assets - all_assets
|
|
|
|
self.assertEqual(len(new_assets), 2)
|
|
|
|
for asset in new_assets:
|
|
|
|
dlines = asset.depreciation_line_ids.filtered(
|
2020-01-29 18:34:31 +01:00
|
|
|
lambda l: l.type == "depreciate"
|
|
|
|
)
|
2019-05-24 08:30:45 +02:00
|
|
|
dlines = dlines.sorted(key=lambda l: l.line_date)
|
|
|
|
self.assertAlmostEqual(dlines[0].depreciated_value, 0.0)
|
|
|
|
self.assertAlmostEqual(dlines[-1].remaining_value, 0.0)
|
2019-07-08 13:21:20 +02:00
|
|
|
|
|
|
|
def test_12_prorata_days_calc(self):
|
|
|
|
"""Prorata temporis depreciation with days calc option."""
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 3333,
|
|
|
|
"salvage_value": 0,
|
|
|
|
"date_start": "2019-07-07",
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "month",
|
|
|
|
"prorata": True,
|
|
|
|
"days_calc": True,
|
|
|
|
"use_leap_years": False,
|
|
|
|
}
|
|
|
|
)
|
2019-07-08 13:21:20 +02:00
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.refresh()
|
2020-01-03 13:40:59 +01:00
|
|
|
day_rate = 3333 / 1827 # 3333 / 1827 depreciation days
|
2019-07-08 13:21:20 +02:00
|
|
|
for i in range(1, 10):
|
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[i].amount,
|
2020-01-29 18:34:31 +01:00
|
|
|
asset.depreciation_line_ids[i].line_days * day_rate,
|
|
|
|
places=2,
|
|
|
|
)
|
2019-07-08 13:21:20 +02:00
|
|
|
# Last depreciation remaining
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[-1].amount, 11.05, places=2)
|
2019-10-22 09:59:57 +02:00
|
|
|
|
|
|
|
def test_13_use_leap_year(self):
|
|
|
|
# When you use the depreciation with years method and using lap years,
|
|
|
|
# the depreciation amount is calculated as 10000 / 1826 days * 365 days
|
|
|
|
# = yearly depreciation amount of 1998.90.
|
|
|
|
# Then 1998.90 / 12 = 166.58
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 10000,
|
|
|
|
"salvage_value": 0,
|
|
|
|
"date_start": time.strftime("2019-01-01"),
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "month",
|
|
|
|
"prorata": False,
|
|
|
|
"days_calc": False,
|
|
|
|
"use_leap_years": True,
|
|
|
|
}
|
|
|
|
)
|
2019-10-22 09:59:57 +02:00
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.refresh()
|
|
|
|
for i in range(2, 11):
|
|
|
|
self.assertAlmostEqual(
|
2020-01-29 18:34:31 +01:00
|
|
|
asset.depreciation_line_ids[i].amount, 166.58, places=2
|
|
|
|
)
|
2019-10-22 09:59:57 +02:00
|
|
|
self.assertAlmostEqual(
|
2020-01-29 18:34:31 +01:00
|
|
|
asset.depreciation_line_ids[13].depreciated_value, 1998.90, places=2
|
|
|
|
)
|
2019-10-22 09:59:57 +02:00
|
|
|
|
|
|
|
def test_14_not_use_leap_year(self):
|
|
|
|
# When you run a depreciation with method = 'year' and no not use
|
|
|
|
# lap years you divide 1000 / 5 years = 2000, then divided by 12 months
|
|
|
|
# to get 166.67 per month, equal for all periods.
|
2020-01-29 18:34:31 +01:00
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
2021-01-14 08:53:25 +01:00
|
|
|
"profile_id": self.car5y.id,
|
2020-01-29 18:34:31 +01:00
|
|
|
"purchase_value": 10000,
|
|
|
|
"salvage_value": 0,
|
|
|
|
"date_start": time.strftime("2019-01-01"),
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "month",
|
|
|
|
"prorata": False,
|
|
|
|
"days_calc": False,
|
|
|
|
"use_leap_years": False,
|
|
|
|
}
|
|
|
|
)
|
2019-10-22 09:59:57 +02:00
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.refresh()
|
2020-01-29 18:37:08 +01:00
|
|
|
for _i in range(1, 11):
|
2019-10-22 09:59:57 +02:00
|
|
|
self.assertAlmostEqual(
|
2020-01-29 18:34:31 +01:00
|
|
|
asset.depreciation_line_ids[1].amount, 166.67, places=2
|
|
|
|
)
|
2019-10-22 09:59:57 +02:00
|
|
|
# In the last month of the fiscal year we compensate for the small
|
|
|
|
# deviations if that is necessary.
|
2020-01-29 18:34:31 +01:00
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[12].amount, 166.63, places=2)
|
2021-02-03 20:22:01 +01:00
|
|
|
|
|
|
|
def test_15_account_asset_group(self):
|
|
|
|
"""Group's name_get behaves differently depending on code and context"""
|
|
|
|
group_fa = self.env["account.asset.group"].create(
|
|
|
|
{
|
|
|
|
"name": "Fixed Assets",
|
|
|
|
"code": "FA",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
group_tfa = self.env["account.asset.group"].create(
|
|
|
|
{
|
|
|
|
"name": "Tangible Fixed Assets",
|
|
|
|
"code": "TFA",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
# Groups are displayed by code (if any) plus name
|
|
|
|
self.assertEqual(
|
2021-04-30 11:37:17 +02:00
|
|
|
self.env["account.asset.group"].name_search("FA"),
|
2021-02-03 20:22:01 +01:00
|
|
|
[(group_fa.id, "FA Fixed Assets")],
|
|
|
|
)
|
|
|
|
# Groups with code are shown by code in list views
|
|
|
|
self.assertEqual(
|
|
|
|
self.env["account.asset.group"]
|
|
|
|
.with_context(params={"view_type": "list"})
|
2021-04-30 11:37:17 +02:00
|
|
|
.name_search("FA"),
|
2021-02-03 20:22:01 +01:00
|
|
|
[(group_fa.id, "FA")],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
2021-04-30 11:37:17 +02:00
|
|
|
self.env["account.asset.group"].name_search("TFA"),
|
2021-02-03 20:22:01 +01:00
|
|
|
[(group_tfa.id, "TFA Tangible Fixed Assets")],
|
|
|
|
)
|
|
|
|
group_tfa.code = False
|
|
|
|
group_fa.code = False
|
|
|
|
self.assertEqual(group_fa.name_get(), [(group_fa.id, "Fixed Assets")])
|
|
|
|
# Groups without code are shown by truncated name in lists
|
|
|
|
self.assertEqual(
|
|
|
|
group_tfa.name_get(), [(group_tfa.id, "Tangible Fixed Assets")]
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
group_tfa.with_context(params={"view_type": "list"}).name_get(),
|
|
|
|
[(group_tfa.id, "Tangible Fixed A...")],
|
|
|
|
)
|
2021-04-30 11:37:17 +02:00
|
|
|
self.assertFalse(self.env["account.asset.group"].name_search("stessA dexiF"))
|
2021-04-19 13:04:19 +02:00
|
|
|
|
|
|
|
def test_16_use_number_of_depreciations(self):
|
|
|
|
# When you run a depreciation with method = 'number'
|
|
|
|
profile = self.car5y
|
|
|
|
profile.method_time = "number"
|
|
|
|
asset = self.asset_model.create(
|
|
|
|
{
|
|
|
|
"name": "test asset",
|
|
|
|
"profile_id": profile.id,
|
|
|
|
"purchase_value": 10000,
|
|
|
|
"salvage_value": 0,
|
|
|
|
"date_start": time.strftime("2019-01-01"),
|
|
|
|
"method_time": "year",
|
|
|
|
"method_number": 5,
|
|
|
|
"method_period": "month",
|
|
|
|
"prorata": False,
|
|
|
|
"days_calc": False,
|
|
|
|
"use_leap_years": False,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
asset.compute_depreciation_board()
|
|
|
|
asset.refresh()
|
|
|
|
for _i in range(1, 11):
|
|
|
|
self.assertAlmostEqual(
|
|
|
|
asset.depreciation_line_ids[1].amount, 166.67, places=2
|
|
|
|
)
|
|
|
|
# In the last month of the fiscal year we compensate for the small
|
|
|
|
# deviations if that is necessary.
|
|
|
|
self.assertAlmostEqual(asset.depreciation_line_ids[12].amount, 166.63, places=2)
|