mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[MIG] account_asset_management: Migration to 11.0
This commit is contained in:
committed by
OCA-git-bot
parent
dda83904e5
commit
1ab818e42f
@@ -1,3 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2018 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Assets Management',
|
||||
'version': '10.0.3.1.0',
|
||||
'version': '11.0.1.0.0',
|
||||
'license': 'AGPL-3',
|
||||
'depends': [
|
||||
'account_fiscal_year',
|
||||
@@ -22,7 +21,7 @@
|
||||
'views/account_account.xml',
|
||||
'views/account_asset.xml',
|
||||
'views/account_asset_profile.xml',
|
||||
'views/account_config_settings.xml',
|
||||
'views/res_config_settings.xml',
|
||||
'views/account_invoice.xml',
|
||||
'views/account_invoice_line.xml',
|
||||
'views/account_move.xml',
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2017 Noviat
|
||||
# Copyright OpenUpgrade contributors (https://github.com/oca/openupgradelib)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
@@ -60,7 +59,7 @@ def table_exists(cr, table):
|
||||
|
||||
|
||||
def rename_columns(cr, column_spec):
|
||||
for table in column_spec.keys():
|
||||
for table in list(column_spec.keys()):
|
||||
for (old, new, comment) in column_spec[table]:
|
||||
cr.execute(
|
||||
"SELECT column_name "
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import account_account
|
||||
from . import account_asset
|
||||
from . import account_asset_profile
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2017 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2018 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
@@ -13,6 +12,7 @@ from odoo import api, fields, models, _
|
||||
import odoo.addons.decimal_precision as dp
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.osv import expression
|
||||
from functools import reduce
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -639,7 +639,7 @@ class AccountAsset(models.Model):
|
||||
factor = float(duration) / cy_days
|
||||
elif i == cnt - 1: # last year
|
||||
duration = (
|
||||
fy_date_stop - datetime(year, 01, 01)).days + 1
|
||||
fy_date_stop - datetime(year, 1, 1)).days + 1
|
||||
factor += float(duration) / cy_days
|
||||
else:
|
||||
factor += 1.0
|
||||
@@ -729,7 +729,7 @@ class AccountAsset(models.Model):
|
||||
"""
|
||||
amount = entry.get('period_amount')
|
||||
if self.prorata and self.method_time == 'year':
|
||||
dates = filter(lambda x: x <= entry['date_stop'], line_dates)
|
||||
dates = [x for x in line_dates if x <= entry['date_stop']]
|
||||
full_periods = len(dates) - 1
|
||||
amount = entry['fy_amount'] - amount * full_periods
|
||||
return amount
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2018 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
@@ -110,7 +109,7 @@ class AccountAssetLine(models.Model):
|
||||
vals['line_date'] = vals['line_date'].strftime('%Y-%m-%d')
|
||||
line_date = vals.get('line_date') or dl.line_date
|
||||
asset_lines = dl.asset_id.depreciation_line_ids
|
||||
if vals.keys() == ['move_id'] and not vals['move_id']:
|
||||
if list(vals.keys()) == ['move_id'] and not vals['move_id']:
|
||||
# allow to remove an accounting entry via the
|
||||
# 'Delete Move' button on the depreciation lines.
|
||||
if not self._context.get('unlink_from_asset'):
|
||||
@@ -118,7 +117,7 @@ class AccountAssetLine(models.Model):
|
||||
"You are not allowed to remove an accounting entry "
|
||||
"linked to an asset."
|
||||
"\nYou should remove such entries from the asset."))
|
||||
elif vals.keys() == ['asset_id']:
|
||||
elif list(vals.keys()) == ['asset_id']:
|
||||
continue
|
||||
elif dl.move_id and not self._context.get(
|
||||
'allow_asset_line_update'):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2018 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2018 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2018 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
@@ -78,7 +77,7 @@ class AccountInvoice(models.Model):
|
||||
for inv in self:
|
||||
move = inv.move_id
|
||||
assets = [aml.asset_id for aml in
|
||||
filter(lambda x: x.asset_id, move.line_ids)]
|
||||
[x for x in move.line_ids if x.asset_id]]
|
||||
for asset in assets:
|
||||
asset.code = inv.move_name
|
||||
asset_line_name = asset._get_depreciation_entry_name(0)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2018 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
@@ -102,7 +101,7 @@ class AccountMoveLine(models.Model):
|
||||
if aml.asset_id:
|
||||
if set(vals).intersection(FIELDS_AFFECTS_ASSET_MOVE_LINE):
|
||||
if not (self.env.context.get('allow_asset_removal') and
|
||||
vals.keys() == ['asset_id']):
|
||||
list(vals.keys()) == ['asset_id']):
|
||||
raise UserError(
|
||||
_("You cannot change an accounting item "
|
||||
"linked to an asset depreciation line."))
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2017 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2014 ACSONE SA/NV (http://acsone.eu).
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
@@ -6,7 +5,7 @@ from odoo import fields, models
|
||||
|
||||
|
||||
class Config(models.TransientModel):
|
||||
_inherit = 'account.config.settings'
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
module_account_asset_management = fields.Boolean(
|
||||
string='Assets management (OCA)',
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import test_account_asset_management
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2014 ACSONE SA/NV (acsone.eu).
|
||||
# Copyright 2009-2018 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
@@ -96,30 +95,30 @@ class TestAssetManagement(common.TransactionCase):
|
||||
#
|
||||
ict0 = self.browse_ref('account_asset_management.'
|
||||
'account_asset_asset_ict0')
|
||||
self.assertEquals(ict0.state, 'draft')
|
||||
self.assertEquals(ict0.purchase_value, 1500)
|
||||
self.assertEquals(ict0.salvage_value, 0)
|
||||
self.assertEquals(ict0.depreciation_base, 1500)
|
||||
self.assertEquals(len(ict0.depreciation_line_ids), 1)
|
||||
self.assertEqual(ict0.state, 'draft')
|
||||
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)
|
||||
vehicle0 = self.browse_ref('account_asset_management.'
|
||||
'account_asset_asset_vehicle0')
|
||||
self.assertEquals(vehicle0.state, 'draft')
|
||||
self.assertEquals(vehicle0.purchase_value, 12000)
|
||||
self.assertEquals(vehicle0.salvage_value, 2000)
|
||||
self.assertEquals(vehicle0.depreciation_base, 10000)
|
||||
self.assertEquals(len(vehicle0.depreciation_line_ids), 1)
|
||||
self.assertEqual(vehicle0.state, 'draft')
|
||||
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)
|
||||
|
||||
#
|
||||
# I compute the depreciation boards
|
||||
#
|
||||
ict0.compute_depreciation_board()
|
||||
ict0.refresh()
|
||||
self.assertEquals(len(ict0.depreciation_line_ids), 4)
|
||||
self.assertEquals(ict0.depreciation_line_ids[1].amount, 500)
|
||||
self.assertEqual(len(ict0.depreciation_line_ids), 4)
|
||||
self.assertEqual(ict0.depreciation_line_ids[1].amount, 500)
|
||||
vehicle0.compute_depreciation_board()
|
||||
vehicle0.refresh()
|
||||
self.assertEquals(len(vehicle0.depreciation_line_ids), 6)
|
||||
self.assertEquals(vehicle0.depreciation_line_ids[1].amount, 2000)
|
||||
self.assertEqual(len(vehicle0.depreciation_line_ids), 6)
|
||||
self.assertEqual(vehicle0.depreciation_line_ids[1].amount, 2000)
|
||||
|
||||
#
|
||||
# I post the first depreciation line
|
||||
@@ -127,15 +126,15 @@ class TestAssetManagement(common.TransactionCase):
|
||||
ict0.validate()
|
||||
ict0.depreciation_line_ids[1].create_move()
|
||||
ict0.refresh()
|
||||
self.assertEquals(ict0.state, 'open')
|
||||
self.assertEquals(ict0.value_depreciated, 500)
|
||||
self.assertEquals(ict0.value_residual, 1000)
|
||||
self.assertEqual(ict0.state, 'open')
|
||||
self.assertEqual(ict0.value_depreciated, 500)
|
||||
self.assertEqual(ict0.value_residual, 1000)
|
||||
vehicle0.validate()
|
||||
vehicle0.depreciation_line_ids[1].create_move()
|
||||
vehicle0.refresh()
|
||||
self.assertEquals(vehicle0.state, 'open')
|
||||
self.assertEquals(vehicle0.value_depreciated, 2000)
|
||||
self.assertEquals(vehicle0.value_residual, 8000)
|
||||
self.assertEqual(vehicle0.state, 'open')
|
||||
self.assertEqual(vehicle0.value_depreciated, 2000)
|
||||
self.assertEqual(vehicle0.value_residual, 8000)
|
||||
|
||||
def test_02_prorata_basic(self):
|
||||
"""Prorata temporis depreciation basic test."""
|
||||
@@ -199,7 +198,7 @@ class TestAssetManagement(common.TransactionCase):
|
||||
'type': 'depreciate',
|
||||
'init_entry': True,
|
||||
})
|
||||
self.assertEquals(len(asset.depreciation_line_ids), 2)
|
||||
self.assertEqual(len(asset.depreciation_line_ids), 2)
|
||||
asset.compute_depreciation_board()
|
||||
asset.refresh()
|
||||
# I check the depreciated value is the initial value
|
||||
@@ -245,7 +244,7 @@ class TestAssetManagement(common.TransactionCase):
|
||||
'type': 'depreciate',
|
||||
'init_entry': True,
|
||||
})
|
||||
self.assertEquals(len(asset.depreciation_line_ids), 2)
|
||||
self.assertEqual(len(asset.depreciation_line_ids), 2)
|
||||
asset.compute_depreciation_board()
|
||||
asset.refresh()
|
||||
# I check the depreciated value is the initial value
|
||||
@@ -289,7 +288,7 @@ class TestAssetManagement(common.TransactionCase):
|
||||
asset.refresh()
|
||||
|
||||
# check values in the depreciation board
|
||||
self.assertEquals(len(asset.depreciation_line_ids), 5)
|
||||
self.assertEqual(len(asset.depreciation_line_ids), 5)
|
||||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount,
|
||||
400.00, places=2)
|
||||
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount,
|
||||
@@ -318,7 +317,7 @@ class TestAssetManagement(common.TransactionCase):
|
||||
asset.refresh()
|
||||
|
||||
# check values in the depreciation board
|
||||
self.assertEquals(len(asset.depreciation_line_ids), 15)
|
||||
self.assertEqual(len(asset.depreciation_line_ids), 15)
|
||||
# lines prior to asset start period are grouped in the first entry
|
||||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount,
|
||||
300.00, places=2)
|
||||
@@ -349,7 +348,7 @@ class TestAssetManagement(common.TransactionCase):
|
||||
asset.refresh()
|
||||
|
||||
# check values in the depreciation board
|
||||
self.assertEquals(len(asset.depreciation_line_ids), 6)
|
||||
self.assertEqual(len(asset.depreciation_line_ids), 6)
|
||||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount,
|
||||
400.00, places=2)
|
||||
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount,
|
||||
@@ -380,7 +379,7 @@ class TestAssetManagement(common.TransactionCase):
|
||||
asset.refresh()
|
||||
|
||||
# check values in the depreciation board
|
||||
self.assertEquals(len(asset.depreciation_line_ids), 6)
|
||||
self.assertEqual(len(asset.depreciation_line_ids), 6)
|
||||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount,
|
||||
200.00, places=2)
|
||||
self.assertAlmostEqual(asset.depreciation_line_ids[-1].amount,
|
||||
@@ -415,7 +414,7 @@ class TestAssetManagement(common.TransactionCase):
|
||||
})
|
||||
wiz.remove()
|
||||
asset.refresh()
|
||||
self.assertEquals(len(asset.depreciation_line_ids), 3)
|
||||
self.assertEqual(len(asset.depreciation_line_ids), 3)
|
||||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount,
|
||||
81.46, places=2)
|
||||
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount,
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_account_config_settings" model="ir.ui.view">
|
||||
<field name="name">account.config.settings.inherit</field>
|
||||
<field name="inherit_id" ref="account.view_account_config_settings"/>
|
||||
<field name="model">account.config.settings</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="module_account_asset" position="replace">
|
||||
<field name="module_account_asset_management" class="oe_inline"/>
|
||||
</field>
|
||||
<xpath expr="//label[@for='module_account_asset']" position="replace">
|
||||
<label for="module_account_asset_management"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
21
account_asset_management/views/res_config_settings.xml
Normal file
21
account_asset_management/views/res_config_settings.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="res_config_settings_view_form" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.inherit.account</field>
|
||||
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="module_account_asset" position="replace">
|
||||
<field name="module_account_asset_management" class="oe_inline"/>
|
||||
</field>
|
||||
<xpath expr="//label[@for='module_account_asset']" position="replace">
|
||||
<label for="module_account_asset_management"/>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='msg_account_asset']" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('module_account_asset_management', '=', False)]}</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,3 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import account_asset_compute
|
||||
from . import account_asset_remove
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2018 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2009-2018 Noviat
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user