Server IP : 127.0.0.2 / Your IP : 3.15.145.122 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/report/ |
Upload File : |
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import api, fields, models, tools class AssetAssetReport(models.Model): _name = "asset.asset.report" _description = "Assets Analysis" _auto = False name = fields.Char(string='Year', required=False, readonly=True) date = fields.Date(readonly=True) depreciation_date = fields.Date(string='Depreciation Date', readonly=True) asset_id = fields.Many2one('account.asset.asset', string='Asset', readonly=True) asset_category_id = fields.Many2one('account.asset.category', string='Asset category', readonly=True) partner_id = fields.Many2one('res.partner', string='Partner', readonly=True) state = fields.Selection([('draft', 'Draft'), ('open', 'Running'), ('close', 'Close')], string='Status', readonly=True) depreciation_value = fields.Float(string='Amount of Depreciation Lines', readonly=True) installment_value = fields.Float(string='Amount of Installment Lines', readonly=True) move_check = fields.Boolean(string='Posted', readonly=True) installment_nbr = fields.Integer(string='# of Installment Lines', readonly=True) depreciation_nbr = fields.Integer(string='# of Depreciation Lines', readonly=True) gross_value = fields.Float(string='Gross Amount', readonly=True) posted_value = fields.Float(string='Posted Amount', readonly=True) unposted_value = fields.Float(string='Unposted Amount', readonly=True) company_id = fields.Many2one('res.company', string='Company', readonly=True) @api.model_cr def init(self): tools.drop_view_if_exists(self._cr, 'asset_asset_report') self._cr.execute(""" create or replace view asset_asset_report as ( select min(dl.id) as id, dl.name as name, dl.depreciation_date as depreciation_date, a.date as date, (CASE WHEN dlmin.id = min(dl.id) THEN a.value ELSE 0 END) as gross_value, dl.amount as depreciation_value, dl.amount as installment_value, (CASE WHEN dl.move_check THEN dl.amount ELSE 0 END) as posted_value, (CASE WHEN NOT dl.move_check THEN dl.amount ELSE 0 END) as unposted_value, dl.asset_id as asset_id, dl.move_check as move_check, a.category_id as asset_category_id, a.partner_id as partner_id, a.state as state, count(dl.*) as installment_nbr, count(dl.*) as depreciation_nbr, a.company_id as company_id from account_asset_depreciation_line dl left join account_asset_asset a on (dl.asset_id=a.id) left join (select min(d.id) as id,ac.id as ac_id from account_asset_depreciation_line as d inner join account_asset_asset as ac ON (ac.id=d.asset_id) group by ac_id) as dlmin on dlmin.ac_id=a.id group by dl.amount,dl.asset_id,dl.depreciation_date,dl.name, a.date, dl.move_check, a.state, a.category_id, a.partner_id, a.company_id, a.value, a.id, a.salvage_value, dlmin.id )""")