Server IP : 127.0.0.2 / Your IP : 18.218.2.200 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/odoo/addons/account_asset/tests/ |
Upload File : |
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import tools from odoo.tests import common from odoo.modules.module import get_resource_path class TestAccountAsset(common.TransactionCase): def _load(self, module, *args): tools.convert_file(self.cr, 'account_asset', get_resource_path(module, *args), {}, 'init', False, 'test', self.registry._assertion_report) def test_00_account_asset_asset(self): self._load('account', 'test', 'account_minimal_test.xml') self._load('account_asset', 'test', 'account_asset_demo_test.xml') # In order to test the process of Account Asset, I perform a action to confirm Account Asset. self.browse_ref("account_asset.account_asset_asset_vehicles_test0").validate() # I check Asset is now in Open state. self.assertEqual(self.browse_ref("account_asset.account_asset_asset_vehicles_test0").state, 'open', 'Asset should be in Open state') # I compute depreciation lines for asset of CEOs Car. self.browse_ref("account_asset.account_asset_asset_vehicles_test0").compute_depreciation_board() value = self.browse_ref("account_asset.account_asset_asset_vehicles_test0") self.assertEqual(value.method_number, len(value.depreciation_line_ids), 'Depreciation lines not created correctly') # I create account move for all depreciation lines. ids = self.env['account.asset.depreciation.line'].search([('asset_id', '=', self.ref('account_asset.account_asset_asset_vehicles_test0'))]) for line in ids: line.create_move() # I check the move line is created. asset = self.env['account.asset.asset'].browse([self.ref("account_asset.account_asset_asset_vehicles_test0")])[0] self.assertEqual(len(asset.depreciation_line_ids), asset.entry_count, 'Move lines not created correctly') # I Check that After creating all the moves of depreciation lines the state "Close". self.assertEqual(self.browse_ref("account_asset.account_asset_asset_vehicles_test0").state, 'close', 'State of asset should be close') # WIZARD # I create a record to change the duration of asset for calculating depreciation. account_asset_asset_office0 = self.browse_ref('account_asset.account_asset_asset_office_test0') asset_modify_number_0 = self.env['asset.modify'].create({ 'name': 'Test reason', 'method_number': 10.0, }).with_context({'active_id': account_asset_asset_office0.id}) # I change the duration. asset_modify_number_0.with_context({'active_id': account_asset_asset_office0.id}).modify() # I check the proper depreciation lines created. self.assertEqual(account_asset_asset_office0.method_number, len(account_asset_asset_office0.depreciation_line_ids)) # I compute a asset on period. context = { "active_ids": [self.ref("account_asset.menu_asset_depreciation_confirmation_wizard")], "active_id": self.ref('account_asset.menu_asset_depreciation_confirmation_wizard'), 'type': 'sale' } asset_compute_period_0 = self.env['asset.depreciation.confirmation.wizard'].create({}) asset_compute_period_0.with_context(context).asset_compute()