diff --git a/dynamic_financial_report/README.rst b/dynamic_financial_report/README.rst deleted file mode 100644 index 9e9b62ff9..000000000 --- a/dynamic_financial_report/README.rst +++ /dev/null @@ -1,48 +0,0 @@ -Dynamic Financial Reports -========================= -* Dynamic financial reports for Odoo 14 community editions - -Installation -============ - - www.odoo.com/documentation/14.0/setup/install.html - - Install our custom addon - -License -------- -General Public License, Version 3 (LGPL v3). -(https://www.odoo.com/documentation/user/13.0/legal/licenses/licenses.html) - -Company -------- -* 'Cybrosys Techno Solutions `__ - -Credits -------- -* Developer: -(v14) Mehjabin @ Cybrosys -(v14) Jibin @ Cybrosys -(v14) Sachin @ Cybrosys -(v14) Mily @ Cybrosys -(v14) Arunima @ Cybrosys -(v14) Aneesh @ Cybrosys -(v14) Sonu @ Cybrosys -(v14) Vaishnavi @ Cybrosys - -Contacts --------- -* Mail Contact : odoo@cybrosys.com - -Bug Tracker ------------ -Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. - -Maintainer -========== -This module is maintained by Cybrosys Technologies. - -For support and more information, please visit https://www.cybrosys.com - -Further information -=================== -HTML Description: ``__ - diff --git a/dynamic_financial_report/__init__.py b/dynamic_financial_report/__init__.py deleted file mode 100644 index 70c683fb4..000000000 --- a/dynamic_financial_report/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from . import wizard -from . import report -from . import controllers \ No newline at end of file diff --git a/dynamic_financial_report/__manifest__.py b/dynamic_financial_report/__manifest__.py deleted file mode 100644 index 4a4c789ce..000000000 --- a/dynamic_financial_report/__manifest__.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################# -# -# Cybrosys Technologies Pvt. Ltd. -# -# Copyright (C) 2020-TODAY Cybrosys Technologies() -# Author: Cybrosys Techno Solutions() -# -# You can modify it under the terms of the GNU LESSER -# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. -# -# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE -# (LGPL v3) along with this program. -# If not, see . -# -############################################################################# - -{ - 'name': 'Dynamic Financial Reports', - 'version': '14.0.1.0.1', - 'category': 'Accounting', - 'summary': """Dynamic Financial Reports with drill - down and filters– Community Edition""", - 'description': "This module creates dynamic Accounting General Ledger, Trial Balance, Balance Sheet " - "Proft and Loss, Cash Flow Statements, Partner Ledger," - "Partner Ageing, Day book" - "Bank book and Cash book reports in Odoo 14 community edition.", - 'author': 'Cybrosys Techno Solutions', - 'website': "https://www.cybrosys.com", - 'company': 'Cybrosys Techno Solutions', - 'maintainer': 'Cybrosys Techno Solutions', - 'depends': ['base', 'base_accounting_kit'], - 'data': [ - 'security/ir.model.access.csv', - 'views/general_ledger_view.xml', - 'views/gl_template.xml', - 'wizard/dynamic_ledger_view.xml', - 'views/templates.xml', - 'views/pl_template.xml', - 'wizard/partner_ledger_view.xml', - 'views/al_template.xml', - 'views/kit_menus.xml', - 'wizard/dynamic_partner_ageing.xml', - 'views/bank_book_pdf_template.xml', - 'views/cash_book_pdf_template.xml', - 'views/cashfl.xml', - 'views/financial_report_qweb_pdf_template.xml', - 'views/menu_dynamic_financial_reports.xml', - 'views/db_templates.xml', - ], - 'qweb': [ - 'static/src/xml/views.xml', - 'static/src/xml/tb_view.xml', - 'static/src/xml/bs_template_views.xml', - 'static/src/xml/profit_loss_template_views.xml', - 'static/src/xml/partner_ledger_views.xml', - 'static/src/xml/al_views.xml', - 'static/src/xml/bank_book_view.xml', - 'static/src/xml/cash_book_view.xml', - 'static/src/xml/cash_flow.xml', - 'static/src/xml/db_lines.xml', - ], - 'license': 'LGPL-3', - 'images': ['static/description/banner.jpg'], - 'installable': True, - 'auto_install': False, - 'application': True, -} diff --git a/dynamic_financial_report/controllers/__init__.py b/dynamic_financial_report/controllers/__init__.py deleted file mode 100644 index deec4a8b8..000000000 --- a/dynamic_financial_report/controllers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import main \ No newline at end of file diff --git a/dynamic_financial_report/controllers/main.py b/dynamic_financial_report/controllers/main.py deleted file mode 100644 index 716af6400..000000000 --- a/dynamic_financial_report/controllers/main.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- - -import json -from odoo import http -from odoo.http import content_disposition, request -from odoo.addons.web.controllers.main import _serialize_exception -from odoo.tools import html_escape - - -class TBXLSXReportController(http.Controller): - @http.route('/xlsx_reports', type='http', auth='user', methods=['POST'], csrf=False) - def get_report_xlsx(self, model, options, output_format, token, report_data, report_name, dfr_data, **kw): - - uid = request.session.uid - report_obj = request.env[model].with_user(uid) - dfr_data = dfr_data - - options = options - - try: - if output_format == 'xlsx': - response = request.make_response( - None, - headers=[ - ('Content-Type', 'application/vnd.ms-excel'), - ('Content-Disposition', content_disposition(report_name + '.xlsx')) - ] - ) - report_obj.get_xlsx_report(options, response, report_data, dfr_data) - response.set_cookie('fileToken', token) - return response - except Exception as e: - se = _serialize_exception(e) - error = { - 'code': 200, - 'message': 'Odoo Server Error', - 'data': se - } - return request.make_response(html_escape(json.dumps(error))) diff --git a/dynamic_financial_report/doc/changelog.md b/dynamic_financial_report/doc/changelog.md deleted file mode 100644 index 06ba265c6..000000000 --- a/dynamic_financial_report/doc/changelog.md +++ /dev/null @@ -1,15 +0,0 @@ -## Module - -#### 29.03.2021 -#### Version 14.0.1.0.0 -#### ADD -- Initial commit for Odoo 14 dynamic financial reports - -#### 04.04.2021 -#### Version 14.0.1.0.1 -#### UPDT -- Currency issue in trial balance - - - - diff --git a/dynamic_financial_report/report/__init__.py b/dynamic_financial_report/report/__init__.py deleted file mode 100644 index 66ee53dd6..000000000 --- a/dynamic_financial_report/report/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from . import general_ledger -from . import financial_reports -from . import partner_ledger -from . import ageing_partner -from . import bank_book -from . import cash_flow_report -from . import daybook_report diff --git a/dynamic_financial_report/report/ageing_partner.py b/dynamic_financial_report/report/ageing_partner.py deleted file mode 100644 index a43a42387..000000000 --- a/dynamic_financial_report/report/ageing_partner.py +++ /dev/null @@ -1,15 +0,0 @@ -from odoo import api, models - - -class InsReportAgeingPartner(models.AbstractModel): - _name = 'report.dynamic_financial_report.ageing_partner' - - @api.model - def _get_report_values(self, docids, data=None): - """ fetch values for get pdf report""" - if self.env.context.get('js_report'): - if data.get('report_data'): - data.update({'account_data': data.get('report_data')[1], - 'Filters': data.get('report_data')[0], - }) - return data diff --git a/dynamic_financial_report/report/bank_book.py b/dynamic_financial_report/report/bank_book.py deleted file mode 100644 index 8f0068632..000000000 --- a/dynamic_financial_report/report/bank_book.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- - -import time -from odoo import api, models, _ -from odoo.exceptions import UserError - - -class InsReportBankBook(models.AbstractModel): - _name = 'report.dynamic_financial_report.bank_book' - - @api.model - def _get_report_values(self, docids, data=None): - if self.env.context.get('js_report'): - if data.get('report_data'): - data.update({'account_data': data.get('report_data')[1], - 'Filters': data.get('report_data')[0], - }) - return data - - -class InsReportCashBook(models.AbstractModel): - _name = 'report.dynamic_financial_report.cash_book' - - @api.model - def _get_report_values(self, docids, data=None): - if self.env.context.get('js_report'): - if data.get('report_data'): - data.update({'account_data': data.get('report_data')[1], - 'Filters': data.get('report_data')[0], - }) - return data diff --git a/dynamic_financial_report/report/cash_flow_report.py b/dynamic_financial_report/report/cash_flow_report.py deleted file mode 100644 index 966f55fc4..000000000 --- a/dynamic_financial_report/report/cash_flow_report.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- - -from odoo import api, models - - -class InsReportCashFlow(models.AbstractModel): - _name = 'report.dynamic_financial_report.cash_flow' - - @api.model - def _get_report_values(self, docids, data=None): - if self.env.context.get('js_report'): - if data.get('report_data'): - - data.update({'account_data': data.get('report_data')[1], - 'Filters': data.get('report_data')[0], - }) - return data diff --git a/dynamic_financial_report/report/daybook_report.py b/dynamic_financial_report/report/daybook_report.py deleted file mode 100644 index d51322098..000000000 --- a/dynamic_financial_report/report/daybook_report.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -from odoo import api, models, _ - - -class InsReportDayBook(models.AbstractModel): - _name = 'report.dynamic_financial_report.dynamic_day_book' - - @api.model - def _get_report_values(self, docids, data=None): - """ fetch values for get pdf report""" - if self.env.context.get('js_report'): - if data.get('report_data'): - data.update({'account_data': data.get('report_data')[1], - 'Filters': data.get('report_data')[0], - 'lines': data.get('report_data')[2], - }) - - return data diff --git a/dynamic_financial_report/report/financial_reports.py b/dynamic_financial_report/report/financial_reports.py deleted file mode 100644 index 5ae1e2ee4..000000000 --- a/dynamic_financial_report/report/financial_reports.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -import time -from odoo import api, models, _ -from odoo.exceptions import UserError - - -class InsReportBalanceSheet(models.AbstractModel): - _name = 'report.dynamic_financial_report.balance_sheet' - - @api.model - def _get_report_values(self, docids, data=None): - if self.env.context.get('js_report'): - if data.get('report_data'): - data.update({ - 'Filters': data.get('report_data')[0], - 'account_data': data.get('report_data')[1], - 'report_lines': data.get('report_data')[2], - 'report_name': data.get('report_name') - }) - - return data diff --git a/dynamic_financial_report/report/general_ledger.py b/dynamic_financial_report/report/general_ledger.py deleted file mode 100644 index 171960652..000000000 --- a/dynamic_financial_report/report/general_ledger.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- - -import time -from odoo import api, models, _ -from odoo.exceptions import UserError - - -class InsReportGeneralLedger(models.AbstractModel): - _name = 'report.dynamic_financial_report.general_ledger' - @api.model - def _get_report_values(self, docids, data=None): - if self.env.context.get('js_report'): - if data.get('report_data'): - data.update({'account_data': data.get('report_data')[1], - 'Filters': data.get('report_data')[0], - }) - return data - - -class InsReportTrialBalance(models.AbstractModel): - _name = 'report.dynamic_financial_report.trial_balance' - - @api.model - def _get_report_values(self, docids, data=None): - if self.env.context.get('js_report'): - - if data.get('report_data'): - data.update({'account_data': data.get('report_data')[1], - 'Filters': data.get('report_data')[0], - 'total': data.get('report_data')[2], - }) - return data diff --git a/dynamic_financial_report/report/partner_ledger.py b/dynamic_financial_report/report/partner_ledger.py deleted file mode 100644 index a33466185..000000000 --- a/dynamic_financial_report/report/partner_ledger.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from odoo import api, models - - -class InsReportPartnerLedger(models.AbstractModel): - _name = 'report.dynamic_financial_report.partner_ledger' - - @api.model - def _get_report_values(self, docids, data=None): - if self.env.context.get('js_report'): - if data.get('report_data'): - data.update({'account_data': data.get('report_data')[1], - 'Filters': data.get('report_data')[0], - }) - return data diff --git a/dynamic_financial_report/security/ir.model.access.csv b/dynamic_financial_report/security/ir.model.access.csv deleted file mode 100644 index 3593e2e27..000000000 --- a/dynamic_financial_report/security/ir.model.access.csv +++ /dev/null @@ -1,9 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_dynamic_general_ledger,access.dynamic.general.ledger,model_dynamic_general_ledger,base.group_user,1,1,1,1 -access_dynamic_trial_balance,access.dynamic.trial.balance,model_dynamic_trial_balance,base.group_user,1,1,1,1 -access_dynamic_balance_sheet,access.dynamic.balance.sheet,model_dynamic_balance_sheet,base.group_user,1,1,1,1 -access_dynamic_partner_ledger,access.dynamic.partner.ledger,model_dynamic_partner_ledger,base.group_user,1,1,1,1 -access_dynamic_ageing_partner,access.dynamic.ageing.partner,model_dynamic_ageing_partner,base.group_user,1,1,1,1 -access_bank_book,access.dynamic.bank.book,model_dynamic_bank_book,base.group_user,1,1,1,1 -access_dynamic_cash_flow,access.dynamic.cash.flow,model_dynamic_cash_flow,base.group_user,1,1,1,1 -access_dynamic_day_book,access.dynamic.day.book,model_dynamic_day_book,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/dynamic_financial_report/static/description/banner.jpg b/dynamic_financial_report/static/description/banner.jpg deleted file mode 100644 index c07cc0e38..000000000 Binary files a/dynamic_financial_report/static/description/banner.jpg and /dev/null differ diff --git a/dynamic_financial_report/static/description/cybro_logo.png b/dynamic_financial_report/static/description/cybro_logo.png deleted file mode 100644 index bb309114c..000000000 Binary files a/dynamic_financial_report/static/description/cybro_logo.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/icon.png b/dynamic_financial_report/static/description/icon.png deleted file mode 100644 index ee925d0ec..000000000 Binary files a/dynamic_financial_report/static/description/icon.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/11.jpg b/dynamic_financial_report/static/description/images/11.jpg deleted file mode 100644 index 7a2e022ca..000000000 Binary files a/dynamic_financial_report/static/description/images/11.jpg and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/Accounting kit -2.png b/dynamic_financial_report/static/description/images/Accounting kit -2.png deleted file mode 100644 index 783144844..000000000 Binary files a/dynamic_financial_report/static/description/images/Accounting kit -2.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/BB_m.png b/dynamic_financial_report/static/description/images/BB_m.png deleted file mode 100644 index 80b476910..000000000 Binary files a/dynamic_financial_report/static/description/images/BB_m.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/account_dynamic_report_banner.gif b/dynamic_financial_report/static/description/images/account_dynamic_report_banner.gif deleted file mode 100644 index d4530e466..000000000 Binary files a/dynamic_financial_report/static/description/images/account_dynamic_report_banner.gif and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/accounting_kit_window.gif b/dynamic_financial_report/static/description/images/accounting_kit_window.gif deleted file mode 100644 index 5d00f83a5..000000000 Binary files a/dynamic_financial_report/static/description/images/accounting_kit_window.gif and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/auto_payroll_banner.png b/dynamic_financial_report/static/description/images/auto_payroll_banner.png deleted file mode 100644 index 4d9844fc9..000000000 Binary files a/dynamic_financial_report/static/description/images/auto_payroll_banner.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/bb_pdf.png b/dynamic_financial_report/static/description/images/bb_pdf.png deleted file mode 100644 index 45be4a97d..000000000 Binary files a/dynamic_financial_report/static/description/images/bb_pdf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/bb_xls.png b/dynamic_financial_report/static/description/images/bb_xls.png deleted file mode 100644 index b908d220b..000000000 Binary files a/dynamic_financial_report/static/description/images/bb_xls.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/bs_m.png b/dynamic_financial_report/static/description/images/bs_m.png deleted file mode 100644 index 455f6f679..000000000 Binary files a/dynamic_financial_report/static/description/images/bs_m.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/bs_pdf.png b/dynamic_financial_report/static/description/images/bs_pdf.png deleted file mode 100644 index 6d1f2be91..000000000 Binary files a/dynamic_financial_report/static/description/images/bs_pdf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/bs_xls.png b/dynamic_financial_report/static/description/images/bs_xls.png deleted file mode 100644 index c7d9e69b6..000000000 Binary files a/dynamic_financial_report/static/description/images/bs_xls.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/bud_banner.png b/dynamic_financial_report/static/description/images/bud_banner.png deleted file mode 100644 index eff7d49a6..000000000 Binary files a/dynamic_financial_report/static/description/images/bud_banner.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/cb_m.png b/dynamic_financial_report/static/description/images/cb_m.png deleted file mode 100644 index a5e5f3241..000000000 Binary files a/dynamic_financial_report/static/description/images/cb_m.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/cb_pdf.png b/dynamic_financial_report/static/description/images/cb_pdf.png deleted file mode 100644 index a617639f0..000000000 Binary files a/dynamic_financial_report/static/description/images/cb_pdf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/cb_xls.png b/dynamic_financial_report/static/description/images/cb_xls.png deleted file mode 100644 index c467b8fb3..000000000 Binary files a/dynamic_financial_report/static/description/images/cb_xls.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/cf.png b/dynamic_financial_report/static/description/images/cf.png deleted file mode 100644 index b7fb7b53d..000000000 Binary files a/dynamic_financial_report/static/description/images/cf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/cf_pdf.png b/dynamic_financial_report/static/description/images/cf_pdf.png deleted file mode 100644 index fcd7b0b33..000000000 Binary files a/dynamic_financial_report/static/description/images/cf_pdf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/cf_xls.png b/dynamic_financial_report/static/description/images/cf_xls.png deleted file mode 100644 index 305804f20..000000000 Binary files a/dynamic_financial_report/static/description/images/cf_xls.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/checked.png b/dynamic_financial_report/static/description/images/checked.png deleted file mode 100644 index 578cedb80..000000000 Binary files a/dynamic_financial_report/static/description/images/checked.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/crm_dashboard_banner.gif b/dynamic_financial_report/static/description/images/crm_dashboard_banner.gif deleted file mode 100644 index b80a0bfc9..000000000 Binary files a/dynamic_financial_report/static/description/images/crm_dashboard_banner.gif and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/cybrosys.png b/dynamic_financial_report/static/description/images/cybrosys.png deleted file mode 100644 index d76b5bafb..000000000 Binary files a/dynamic_financial_report/static/description/images/cybrosys.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/db_m.png b/dynamic_financial_report/static/description/images/db_m.png deleted file mode 100644 index 2d3d4892e..000000000 Binary files a/dynamic_financial_report/static/description/images/db_m.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/db_pdf.png b/dynamic_financial_report/static/description/images/db_pdf.png deleted file mode 100644 index b43c5302a..000000000 Binary files a/dynamic_financial_report/static/description/images/db_pdf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/db_xls.png b/dynamic_financial_report/static/description/images/db_xls.png deleted file mode 100644 index 00c3e9967..000000000 Binary files a/dynamic_financial_report/static/description/images/db_xls.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/dynamic_banner.gif b/dynamic_financial_report/static/description/images/dynamic_banner.gif deleted file mode 100644 index 68c750b72..000000000 Binary files a/dynamic_financial_report/static/description/images/dynamic_banner.gif and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/dynamic_financial_reports.png b/dynamic_financial_report/static/description/images/dynamic_financial_reports.png deleted file mode 100644 index a14661347..000000000 Binary files a/dynamic_financial_report/static/description/images/dynamic_financial_reports.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/dynamic_gl.png b/dynamic_financial_report/static/description/images/dynamic_gl.png deleted file mode 100644 index 26e725e0e..000000000 Binary files a/dynamic_financial_report/static/description/images/dynamic_gl.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/dynamic_tb.png b/dynamic_financial_report/static/description/images/dynamic_tb.png deleted file mode 100644 index ba1f50b9d..000000000 Binary files a/dynamic_financial_report/static/description/images/dynamic_tb.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/gl_journal.png b/dynamic_financial_report/static/description/images/gl_journal.png deleted file mode 100644 index ca9cc1073..000000000 Binary files a/dynamic_financial_report/static/description/images/gl_journal.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/gl_pdf.png b/dynamic_financial_report/static/description/images/gl_pdf.png deleted file mode 100644 index dced02cec..000000000 Binary files a/dynamic_financial_report/static/description/images/gl_pdf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/gl_xlsx.png b/dynamic_financial_report/static/description/images/gl_xlsx.png deleted file mode 100644 index d792aa98b..000000000 Binary files a/dynamic_financial_report/static/description/images/gl_xlsx.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/hr_acc_cc_banner.png b/dynamic_financial_report/static/description/images/hr_acc_cc_banner.png deleted file mode 100644 index 471b30611..000000000 Binary files a/dynamic_financial_report/static/description/images/hr_acc_cc_banner.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/mobile_service_shop_pro_banner.png b/dynamic_financial_report/static/description/images/mobile_service_shop_pro_banner.png deleted file mode 100644 index 68d11114c..000000000 Binary files a/dynamic_financial_report/static/description/images/mobile_service_shop_pro_banner.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/o_hrms_banner.gif b/dynamic_financial_report/static/description/images/o_hrms_banner.gif deleted file mode 100644 index e30392344..000000000 Binary files a/dynamic_financial_report/static/description/images/o_hrms_banner.gif and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/odoo11_magento_banner.jpg b/dynamic_financial_report/static/description/images/odoo11_magento_banner.jpg deleted file mode 100644 index b2d9b33ce..000000000 Binary files a/dynamic_financial_report/static/description/images/odoo11_magento_banner.jpg and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/pa_m.png b/dynamic_financial_report/static/description/images/pa_m.png deleted file mode 100644 index 0c0d52166..000000000 Binary files a/dynamic_financial_report/static/description/images/pa_m.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/pa_pdf.png b/dynamic_financial_report/static/description/images/pa_pdf.png deleted file mode 100644 index 6bd391161..000000000 Binary files a/dynamic_financial_report/static/description/images/pa_pdf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/pa_xls.png b/dynamic_financial_report/static/description/images/pa_xls.png deleted file mode 100644 index 39b917e67..000000000 Binary files a/dynamic_financial_report/static/description/images/pa_xls.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/pal_pdf.png b/dynamic_financial_report/static/description/images/pal_pdf.png deleted file mode 100644 index f6ed76d5e..000000000 Binary files a/dynamic_financial_report/static/description/images/pal_pdf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/pal_xls.png b/dynamic_financial_report/static/description/images/pal_xls.png deleted file mode 100644 index 2b99482c6..000000000 Binary files a/dynamic_financial_report/static/description/images/pal_xls.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/payroll_banner.gif b/dynamic_financial_report/static/description/images/payroll_banner.gif deleted file mode 100644 index 8a6949d91..000000000 Binary files a/dynamic_financial_report/static/description/images/payroll_banner.gif and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/pl_m.png b/dynamic_financial_report/static/description/images/pl_m.png deleted file mode 100644 index 3f85211ed..000000000 Binary files a/dynamic_financial_report/static/description/images/pl_m.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/pl_m1.png b/dynamic_financial_report/static/description/images/pl_m1.png deleted file mode 100644 index 5ca197928..000000000 Binary files a/dynamic_financial_report/static/description/images/pl_m1.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/pl_pdf.png b/dynamic_financial_report/static/description/images/pl_pdf.png deleted file mode 100644 index 8e3c7b8f1..000000000 Binary files a/dynamic_financial_report/static/description/images/pl_pdf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/pl_xls.png b/dynamic_financial_report/static/description/images/pl_xls.png deleted file mode 100644 index a6ec068b1..000000000 Binary files a/dynamic_financial_report/static/description/images/pl_xls.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/project_custome_gantt_banner.gif b/dynamic_financial_report/static/description/images/project_custome_gantt_banner.gif deleted file mode 100644 index 3ee64f1c5..000000000 Binary files a/dynamic_financial_report/static/description/images/project_custome_gantt_banner.gif and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/report_maker_banner.gif b/dynamic_financial_report/static/description/images/report_maker_banner.gif deleted file mode 100644 index db6305f39..000000000 Binary files a/dynamic_financial_report/static/description/images/report_maker_banner.gif and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/tb_gl.png b/dynamic_financial_report/static/description/images/tb_gl.png deleted file mode 100644 index ac72065b5..000000000 Binary files a/dynamic_financial_report/static/description/images/tb_gl.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/tb_pdf.png b/dynamic_financial_report/static/description/images/tb_pdf.png deleted file mode 100644 index 861060047..000000000 Binary files a/dynamic_financial_report/static/description/images/tb_pdf.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/images/tb_xlsx.png b/dynamic_financial_report/static/description/images/tb_xlsx.png deleted file mode 100644 index d99937649..000000000 Binary files a/dynamic_financial_report/static/description/images/tb_xlsx.png and /dev/null differ diff --git a/dynamic_financial_report/static/description/index.html b/dynamic_financial_report/static/description/index.html deleted file mode 100644 index 184111147..000000000 --- a/dynamic_financial_report/static/description/index.html +++ /dev/null @@ -1,1122 +0,0 @@ - - -
-
-
-

Odoo 14 Dynamic Financial Reports

-

Accounting General Ledger, Trial Balance, Balance Sheet, Proft and Loss, Cash Flow Statements, Partner Ledger, Partner Ageing, Day book, - Bank book and Cash book reports in Odoo 14 community edition.

-
-

Key Highlights

-
    -
  • - - Dynamic Financial Reports for Odoo14 Community Edition. -
  • -
  • - - Drill-down approach enabled. -
  • -
  • - - Various Filters to Compare. -
  • -
  • - - Access the Journal Entries. -
  • -
  • - - PDF and XLSX Reports available. -
  • -
-
-
-
-
-
- - -
-
-
- - - -
-
-
- - -

Screenshots

-
-
-
- -
- -
-
- -
- -
- -

Dynamic Financial Report

-
- -

- - Drill-down approach enabled. -

- -

- - User friendly filters. -

-

- - Can print in PDF and XLSX. -

-

- - Day book, Bank book and Cash book reports. -

-

- - Financial reports. -

-

- - Trial balance report. -

-

- - Cash Flow Statements. -

-

- - General ledger report. -

-

- - Partner ledger report. -

-

- - Aged partner balance. -

- - -
- - - -
- - - -

Overview

-
-

- Accounting in odoo is sufficient for any organization to meet all their needs related to - accounting. As you know for any organization, accounting is one of the most important - processes in order to run the company without any financial losses. Odoo accounting is - connected with all the other apps such as sales, purchase, inventory and more. -
-
- This module comes under Odoo14 Full Accounting Kit by Cybrosys Technologies which is - built under the V14 platform. It facilitates the dynamic financial report of general ledger, trial balance, balance sheet, profit & loss, cash flow statements, partner ledger, partner ageing, day book, bank book and cashbook. - We can drill down from the main report to the journal entries associated with each account. - One can open the form view of each journal entry and view the complete details here. Along with the drill down option, various supporting filters can be applied on each report. - Also, one can print the reports in both the pdf and the xlsx formats. - - -

- - -
- - - - - - - - - - - - - - - - - - -
-
    - - -
-
-
-
-
-
- -
-

Suggested Products

-
- -
- - -
-

Our Service

-
- -
-
-
-

Our Industries

-
- -
-
-
-
- Odoo Industry
-
-
-

- - Trading

-

- Easily procure and sell your products.

-
-
-
-
-
- Odoo Industry -
-
-
-

- - Manufacturing

-

- Plan, track and schedule your operations.

-
-
-
-
-
- - Odoo Industry
-
-
-

- - Restaurant

-

- Run your bar or restaurant methodical.

-
-
-
-
-
- Odoo Industry
-
-
-

- - POS

-

- Easy configuring and convivial selling.

-
-
-
-
-
- Odoo Industry
-
-
-

- - E-commerce & Website

-

- Mobile friendly, awe-inspiring product pages.

-
-
-
-
-
- - Odoo Industry
-
-
-

- - Hotel Management

-

- An all-inclusive hotel management application.

-
-
-
-
-
- - Odoo Industry
-
-
-

- - Education

-

- A Collaborative platform for educational management.

-
-
-
-
-
- Odoo Industry
-
-
-

- - Service Management

-

- Keep track of services and invoice accordingly.

-
-
-
-
-
- - -
-
-
-

Need Any Help?

-
- -

If you have anything to share with us based on your use of this module, - please - let us know. We are ready to offer our support.

-
-

Email us

-

odoo@cybrosys.com / info@cybrosys.com

- -
-
-

Contact Us

- www.cybrosys.com -
-
- -
-
- - -
-
-
- - -
-
- -
- - - - - - - - -
-
-
-
- - diff --git a/dynamic_financial_report/static/src/js/action_manager.js b/dynamic_financial_report/static/src/js/action_manager.js deleted file mode 100644 index 72dbd2e42..000000000 --- a/dynamic_financial_report/static/src/js/action_manager.js +++ /dev/null @@ -1,52 +0,0 @@ -odoo.define('dynamic_financial_report.action_manager', function (require) { -"use strict"; -/** - * The purpose of this file is to add the actions of type - * 'xlsx' to the ActionManager. - */ -var ActionManager = require('web.ActionManager'); -var framework = require('web.framework'); -var session = require('web.session'); - - -ActionManager.include({ - - /** - * Executes actions of type 'ir.actions.report'. - * - * @private - * @param {Object} action the description of the action to execute - * @param {Object} options @see doAction for details - * @returns {Promise} resolved when the action has been executed - */ - _executexlsxReportDownloadAction: function (action) { - framework.blockUI(); - var def = $.Deferred(); - session.get_file({ - url: '/xlsx_reports', - data: action.data, - success: def.resolve.bind(def), - error: (error) => this.call('crash_manager', 'rpc_error', error), - complete: framework.unblockUI, - }); - return def; - }, - /** - * Overrides to handle the 'ir.actions.report' actions. - * - * @override - * @private - */ - - _handleAction: function (action, options) { - - if (action.type === 'ir_actions_xlsx_download') { - return this._executexlsxReportDownloadAction(action, options); - } - return this._super.apply(this, arguments); - }, - - -}); - -}); diff --git a/dynamic_financial_report/static/src/js/ageing_partner.js b/dynamic_financial_report/static/src/js/ageing_partner.js deleted file mode 100644 index 1756b53b3..000000000 --- a/dynamic_financial_report/static/src/js/ageing_partner.js +++ /dev/null @@ -1,558 +0,0 @@ -odoo.define('dynamic_financial_report.ageing_partner', function(require) { - 'use strict'; - - var AbstractAction = require('web.AbstractAction'); - var core = require('web.core'); - var field_utils = require('web.field_utils'); - var rpc = require('web.rpc'); - var session = require('web.session'); - var utils = require('web.utils'); - var QWeb = core.qweb; - var _t = core._t; - - var AgeingPartner = AbstractAction.extend({ - template: 'AgeingPartner', - events: { - 'click .al-line': 'get_move_lines', - 'click .view-move': 'view_move', - 'click #filter_apply_button': 'apply_filter', - 'click #pdf': 'print_pdf', - 'click #xlsx': 'print_xlsx', - }, - init: function(view, code) { - this._super(view, code); - this.wizard = code.context.wizard | null; - this.session = session; - }, - start: function() { - var self = this; - self.initial_render = true; - rpc.query({ - model: 'dynamic.ageing.partner', - method: 'create', - args: [{ - res_model: this.res_model - }] - }).then(function(res) { - self.wizard = res; - self.ledger_view(self.initial_render); - }) - }, - - apply_filter: function(event) { - event.preventDefault(); - var self = this; - - self.initial_render = false; - var output = {}; - output.type=false - output.partner_type=false - var partner_ids = []; - var partner_text = []; - var span_res = document.getElementById("partner_res") - var partner_list = $(".partners").select2('data') - - for (var i = 0; i < partner_list.length; i++) { - if(partner_list[i].element[0].selected === true) - {partner_ids.push(parseInt(partner_list[i].id)) - if(partner_text.includes(partner_list[i].text) === false) - {partner_text.push(partner_list[i].text) - } - span_res.value = partner_text - span_res.innerHTML=span_res.value; - } - } - if (partner_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; } - output.partner_ids = partner_ids - var partner_category_ids = []; - var category_text = []; - var span_res = document.getElementById("category_res") - - var category_list = $(".partner-tag").select2('data') - for (var i = 0; i < category_list.length; i++) { - - if(category_list[i].element[0].selected === true) - {partner_category_ids.push(parseInt(category_list[i].id)) - if(category_text.includes(category_list[i].text) === false) - {category_text.push(category_list[i].text) - - } - - span_res.value = category_text - span_res.innerHTML=span_res.value; - } - } - if (category_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; } - output.partner_category_ids = partner_category_ids - - if ($(".target-moves").length){ - var target_res = document.getElementById("target_res") - output.target_moves = $(".target-moves")[1].value - target_res.value = $(".target-moves")[1].value - target_res.innerHTML=target_res.value; - if ($(".target-moves").value==""){ - target_res.innerHTML="draft"; - output.target_moves = "draft" - } - } - - if ($(".partner-type").length){ - var partner_type_res = document.getElementById("partner_type_res") - output.partner_type = $(".partner-type")[1].value - partner_type_res.value = $(".partner-type")[1].value - partner_type_res.innerHTML=partner_type_res.value; - if ($(".partner-type").value==""){ - partner_type_res.innerHTML="customer"; - output.partner_type = "customer" - } - } - - if ($(".account").length){ - var type_res = document.getElementById("type_res") - output.type = $(".account")[1].value - type_res.value = $(".account")[1].value - type_res.innerHTML=type_res.value; - if ($(".account").value==""){ - type_res.innerHTML="receivable"; - output.type = "receivable" - } - } - - if ($("#as_on_date").val()) { - var dateObject = $("#as_on_date").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.as_on_date = dateString; - } - output.include_details = true; - - - rpc.query({ - model: 'dynamic.ageing.partner', - method: 'write', - args: [ - [self.wizard], output - ], - }).then(function(res) { - self.ledger_view(self.initial_render); - - }); - }, - - print_pdf: function(e) { - e.preventDefault(); - var self = this; - self._rpc({ - model: 'dynamic.ageing.partner', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - - - var action = { - 'type': 'ir.actions.report', - 'report_type': 'qweb-pdf', - 'report_name': 'dynamic_financial_report.ageing_partner', - 'report_file': 'dynamic_financial_report.ageing_partner', - 'data': { - 'report_data': data - }, - 'context': { - 'active_model': 'dynamic.ageing.partner', - 'landscape': 1, - 'js_report': true - }, - 'display_name': 'Ageing Partner Report', - }; - return self.do_action(action); - }); - }, - print_xlsx: function() { - var self = this; - self._rpc({ - model: 'dynamic.ageing.partner', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - - - var action = { - 'type': 'ir_actions_xlsx_download', - 'data': { - 'model': 'dynamic.ageing.partner', - 'options': JSON.stringify(data[1]), - 'output_format': 'xlsx', - 'report_data': JSON.stringify(data[0]), - 'report_name': 'Partner Ageing', - 'dfr_data': JSON.stringify(data), - }, - }; - - return self.do_action(action); - }); - }, - ledger_view: function(initial_render = true) { - var self = this; - var node = self.$('.container-al-main'); - var last; - while (last = node.lastChild) node.removeChild(last); - rpc.query({ - model: 'dynamic.ageing.partner', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(datas) { - self.filter_data = datas[0] - - - - self.account_data = datas[1] - - - - _.each(self.account_data, function(account) { - - var currency_format = { - currency_id: account.company_currency_id, - position: account.company_currency_position, - symbol: account.company_currency_symbol, - - noSymbol: true, - }; - - if (currency_format.position == "before") { - - if (account.total == 0) { - account.total = ' - ' - } else { - account.total = currency_format.symbol + ' ' + account.total.toFixed(2) + ' '; - - } - if (account.Not == 0) { - account.Not = ' - ' - - } else { - account.Not = currency_format.symbol + ' ' + account.Not.toFixed(2) + ' '; - - } - if (account.value_20 == 0) { - account.value_20 = ' - ' - - } else { - account.value_20 = currency_format.symbol + ' ' + account.value_20.toFixed(2) + ' '; - - } - if (account[2140] == 0) { - account[2140] = ' - ' - - } else { - account[2140] = currency_format.symbol + ' ' + account[2140].toFixed(2) + ' '; - - } - if (account[4160] == 0) { - account[4160] = ' - ' - - } else { - account[4160] = currency_format.symbol + ' ' + account[4160].toFixed(2) + ' '; - - } - if (account[6180] == 0) { - account[6180] = ' - ' - - } else { - account[6180] = currency_format.symbol + ' ' + account[6180].toFixed(2) + ' '; - - } - if (account[81100] == 0) { - account[81100] = ' - ' - - } else { - account[81100] = currency_format.symbol + ' ' + account[81100].toFixed(2) + ' '; - - } - if (account[100] == 0) { - account[100] = ' - ' - - } else { - account[100] = currency_format.symbol + ' ' + account[100].toFixed(2) + ' '; - - } - } else { - - if (account.total == 0) { - account.total = ' - ' - } else { - account.total = account.total.toFixed(2) + ' ' + currency_id.symbol; -// - } - if (account.Not == 0) { - account.Not = ' - ' - - } else { - account.Not = account.Not.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.value_20 == 0) { - account.value_20 = ' - ' - } else { - account.value_20 = account.value_20.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account[2140] == 0) { - account[2140] = ' - ' - } else { - account[2140] = account[2140].toFixed(2) + ' ' + currency_id.symbol; - - } - if (account[4160] == 0) { - account[4160] = ' - ' - } else { - account[4160] = account[4160].toFixed(2) + ' ' + currency_id.symbol; - - } - if (account[6180] == 0) { - account[6180] = ' - ' - } else { - account[6180] = account[6180].toFixed(2) + ' ' + currency_id.symbol; - - } - if (account[81100] == 0) { - account[81100] = ' - ' - } else { - account[81100] = account[81100].toFixed(2) + ' ' + currency_id.symbol; - - } - if (account[100] == 0) { - account[100] = ' - ' - } else { - account[100] = account[100].toFixed(2) + ' ' + currency_id.symbol; - - } - } - - }); - if (initial_render) { - self.$('.al-filter').html(QWeb.render('FilterSection-al', { - filter_data: datas[0], - })); - self.$el.find('.account').select2({ - placeholder: 'Select Account Type...', - }); - self.$el.find('.partner-type').select2({ - placeholder: 'Select Partner Type...', - }); - self.$el.find('.partner-tag').select2({ - placeholder: 'Select Partner Tag...', - }); - self.$el.find('.partners').select2({ - placeholder: 'Select Partners...', - }); - self.$el.find('.target-moves').select2({ - placeholder: 'Posted or All Entries...', - }); - self.$el.find('#as_on_date').datepicker({ - dateFormat: 'dd-mm-yy' - }); - - } - - self.$('.container-al-main').html(QWeb.render('AgeingPartnerData', { - account_data: datas[1] - })); - - }); - }, - al_lines_by_page: function(offset, account_id) { - - var self = this; - return rpc.query({ - model: 'dynamic.ageing.partner', - method: 'al_move_lines', - args: [self.wizard, offset, account_id], - }) - }, -get_move_lines: function(event) { - event.preventDefault(); - var self = this; - var account_id = $(event.currentTarget).data('account-id'); - var offset = 0; - var td = $(event.currentTarget).next('tr').find('td'); - - - if (td.length == 1) { - self.al_lines_by_page(offset, account_id).then(function(datas) { - - _.each(datas[2], function(data) { - - var currency_format = { - currency_id: data.company_currency_id, - position: data.company_currency_position, - symbol: data.company_currency_symbol, - noSymbol: true, - }; - - if (currency_format.position == "before") { - if (data.range_0 == 0) { - data.range_0 = ' - ' - } else { - data.range_0 = currency_format.symbol + data.range_0.toFixed(2) ; - - } - if (data.range_1 == 0) { - data.range_1 = ' - ' - - } else { - data.range_1 = currency_format.symbol + data.range_1.toFixed(2) ; - - } - if (data.range_2 == 0) { - data.range_2 = ' - ' - - } else { - data.range_2 = currency_format.symbol + data.range_2.toFixed(2) ; - - } - if (data.range_3 == 0) { - data.range_3 = ' - ' - - } else { - data.range_3 = currency_format.symbol + data.range_3.toFixed(2) ; - - } - if (data.range_4 == 0) { - data.range_4 = ' - ' - - } else { - data.range_4 = currency_format.symbol + data.range_4.toFixed(2) ; - - } - if (data.range_5 == 0) { - data.range_5 = ' - ' - - } else { - data.range_5 = currency_format.symbol + data.range_5.toFixed(2) ; - - } - if (data.range_6 == 0) { - data.range_6 = ' - ' - - } else { - data.range_6 = currency_format.symbol + data.range_6.toFixed(2) ; - - } - } else { - if (data.range_0 == 0) { - data.range_0 = ' - ' - } else { - data.range_0 = data.range_0.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.range_1 == 0) { - data.range_1 = ' - ' - - } else { - data.range_1 = data.range_1.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.range_2 == 0) { - data.range_2 = ' - ' - } else { - data.range_2 = data.range_2.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.range_3 == 0) { - data.range_3 = ' - ' - } else { - data.range_3 = data.range_3.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.range_4 == 0) { - data.range_4 = ' - ' - } else { - data.range_4 = data.range_4.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.range_5 == 0) { - data.range_5 = ' - ' - } else { - data.range_5 = data.range_5.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.range_6 == 0) { - data.range_6 = ' - ' - } else { - data.range_6 = data.range_6.toFixed(2) + ' ' + currency_id.symbol; - - } - } - - - }); - $(event.currentTarget).next('tr').find('td .al-table-div').remove(); - $(event.currentTarget).next('tr').find('td ul').after( - QWeb.render('SubSection_al', { - count: datas[0], - offset: datas[1], - account_data: datas[2], - })) - - $(event.currentTarget).next('tr').find('td ul li:first a').css({ - 'background-color': '#00ede8', - 'font-weight': 'bold', - }); - - }) - } - }, - - - view_move: function(event) { - event.preventDefault(); - var self = this; - var context = {}; - var redirect_to_document = function(res_model, res_id, view_id) { - - var action = { - type: 'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: res_model, - views: [ - [view_id || false, 'form'] - ], - res_id: res_id, - target: 'current', - context: context, - }; - return self.do_action(action); - }; - rpc.query({ - model: 'account.move', - method: 'search_read', - domain: [ - ['id', '=', $(event.currentTarget).data('move-id')] - ], - fields: ['id'], - limit: 1, - }) - .then(function(record) { - if (record.length > 0) { - redirect_to_document('account.move', record[0].id); - } else { - redirect_to_document('account.move', $(event.currentTarget).data('move-id')); - } - }); - }, - - }); - core.action_registry.add('dynamic.al', AgeingPartner); - -}); \ No newline at end of file diff --git a/dynamic_financial_report/static/src/js/balance_sheet.js b/dynamic_financial_report/static/src/js/balance_sheet.js deleted file mode 100644 index ed4efc8b8..000000000 --- a/dynamic_financial_report/static/src/js/balance_sheet.js +++ /dev/null @@ -1,527 +0,0 @@ -odoo.define('dynamic_financial_report.balance_sheet', function(require) { - 'use strict'; - var AbstractAction = require('web.AbstractAction'); - var core = require('web.core'); - var field_utils = require('web.field_utils'); - var rpc = require('web.rpc'); - var session = require('web.session'); - var utils = require('web.utils'); - var QWeb = core.qweb; - var _t = core._t; - - var BalanceSheet = AbstractAction.extend({ - template: 'BalanceSheet', - events: { - 'click .bs-line': 'get_move_lines', - 'click .view-move': 'view_move', - 'click #filter_apply_button': 'apply_filter', - 'click #pdf': 'print_pdf', - 'click #xlsx': 'print_xlsx', - 'click .open-gl': 'get_gl', - }, - init: function(view, code) { - this._super(view, code); - this.wizard = code.context.wizard | null; - this.session = session; - }, - start: function() { - var self = this; - self.initial_render = true; - rpc.query({ - model: 'dynamic.balance.sheet', - method: 'create', - args: [{ - - }] - }).then(function(res) { - self.wizard = res; - self.sheet_view(self.initial_render); - }) - }, - apply_filter: function(event) { - - event.preventDefault(); - var self = this; - - self.initial_render = false; - var output = {}; - - - var account_ids = []; - var account_text = []; - var account_res = document.getElementById("acc_res") - var account_list = $(".account").select2('data') - for (var i = 0; i < account_list.length; i++) { - - if(account_list[i].element[0].selected === true){ - - account_ids.push(parseInt(account_list[i].id)) - if(account_text.includes(account_list[i].text) === false){ - account_text.push(account_list[i].text) - - } - account_res.value = account_text - account_res.innerHTML=account_res.value; - } - } - if (account_list.length == 0){ - account_res.value = "" - account_res.innerHTML=""; - - } - output.account_ids = account_ids - - - var journal_ids = []; - var journal_text = []; - var journal_res = document.getElementById("journal_res") - var journal_list = $(".journal").select2('data') - for (var i = 0; i < journal_list.length; i++) { - - if(journal_list[i].element[0].selected === true){ - - journal_ids.push(parseInt(journal_list[i].id)) - if(journal_text.includes(journal_list[i].text) === false){ - journal_text.push(journal_list[i].text) - - } - - journal_res.value = journal_text - journal_res.innerHTML=journal_res.value; - } - } - if (journal_list.length == 0){ - journal_res.value = "" - journal_res.innerHTML=""; - - } - output.journal_ids = journal_ids - - - var account_tag_ids = []; - var account_tag_text = []; - var account_tag_res = document.getElementById("acc_tag_res") - var account_tag_list = $(".account-tag").select2('data') - for (var i = 0; i < account_tag_list.length; i++) { - if(account_tag_list[i].element[0].selected === true){ - - account_tag_ids.push(parseInt(account_tag_list[i].id)) - if(account_tag_text.includes(account_tag_list[i].text) === false){ - account_tag_text.push(account_tag_list[i].text) - } - - account_tag_res.value = account_tag_text - account_tag_res.innerHTML=account_tag_res.value; - } - } - if (account_tag_list.length == 0){ - account_tag_res.value = "" - account_tag_res.innerHTML=""; - - } - output.account_tag_ids = account_tag_ids - - - - var analytic_ids = []; - var analytic_text = []; - var span_res = document.getElementById("analic_res") - var analytic_list = $(".analytic").select2('data') - for (var i = 0; i < analytic_list.length; i++) { - if(analytic_list[i].element[0].selected === true){ - - analytic_ids.push(parseInt(analytic_list[i].id)) - if(analytic_text.includes(analytic_list[i].text) === false){ - analytic_text.push(analytic_list[i].text) - - } - - span_res.value = analytic_text - span_res.innerHTML=span_res.value; - } - } - if (analytic_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; - - } - output.analytic_ids = analytic_ids - - output.analytic_tag_ids = analytic_tag_ids - - var analytic_tag_ids = []; - var analytic_tag_text = []; - var analytic_tag_res = document.getElementById("analic_tag_res") - var analytic_tag_list = $(".analytic-tag").select2('data') - for (var i = 0; i < analytic_tag_list.length; i++) { - if(analytic_tag_list[i].element[0].selected === true){ - - analytic_tag_ids.push(parseInt(analytic_tag_list[i].id)) - if(analytic_tag_text.includes(analytic_tag_list[i].text) === false){ - analytic_tag_text.push(analytic_tag_list[i].text) - - } - - analytic_tag_res.value = analytic_tag_text - analytic_tag_res.innerHTML=analytic_tag_res.value; - } - } - if (analytic_tag_list.length == 0){ - analytic_tag_res.value = "" - analytic_tag_res.innerHTML=""; - - } - output.analytic_tag_ids = analytic_tag_ids - - - - - if ($("#date_from").val()) { - var dateObject = $("#date_from").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_from = dateString; - } - if ($("#date_to").val()) { - var dateObject = $("#date_to").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_to = dateString; - } - - if ($(".entries").length) { - var post_res = document.getElementById("post_res") - - output.entries = $(".entries")[1].value - post_res.value = $(".entries")[1].value - post_res.innerHTML=post_res.value; - if ($(".entries")[1].value == "") { - post_res.innerHTML="all"; - - } - } - - output.include_details = true; - - - rpc.query({ - model: 'dynamic.balance.sheet', - method: 'write', - args: [ - [self.wizard], output - ], - }).then(function(res) { - self.sheet_view(self.initial_render); - - }); - }, - - get_gl: function(e) { - var self = this; - var account_id = $(e.target).attr('data-account-id'); - var options = { - account_ids: [account_id], - } - var action = { - type: 'ir.actions.client', - name: 'GL View', - tag: 'dynamic.gl', - target: 'new', - - domain: [['account_ids','=', account_id]], - - - } - return this.do_action(action); - - }, - - print_pdf: function(e) { - e.preventDefault(); - var self = this; - var action_title = self._title - - self._rpc({ - model: 'dynamic.balance.sheet', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(data) { - - var action = { - 'type': 'ir.actions.report', - 'report_type': 'qweb-pdf', - 'report_name': 'dynamic_financial_report.balance_sheet', - 'report_file': 'dynamic_financial_report.balance_sheet', - 'data': { - 'report_data': data, - 'report_name': 'Balance Sheet' - }, - 'context': { - 'active_model': 'dynamic.balance.sheet', - 'landscape': 1, - 'js_report': true - }, - 'display_name': 'Balance Sheet', - }; - return self.do_action(action); - }); - }, - print_xlsx: function() { - var self = this; - var action_title = self._title - self._rpc({ - model: 'dynamic.balance.sheet', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(data) { - - var action = { - 'type': 'ir_actions_xlsx_download', - 'data': { - 'model': 'dynamic.balance.sheet', - 'options': 'Balance Sheet', - 'output_format': 'xlsx', - 'report_data': JSON.stringify(data[0]), - 'report_name': 'Balance Sheet', - 'dfr_data':JSON.stringify(data[2]), - }, - }; - - return self.do_action(action); - }); - }, - - - sheet_view: function(initial_render = true) { - var self = this; - var action_title = self._title - var node = self.$('.container-bs-main'); - var last; - while (last = node.lastChild) node.removeChild(last); - rpc.query({ - model: 'dynamic.balance.sheet', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(datas) { - self.filter_data = datas[0] - - self.account_data = datas[1] - - _.each(self.account_data, function(account) { - var currency_format = { - currency_id: account.company_currency_id, - position: account.company_currency_position, - symbol: account.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = currency_format.symbol + ' ' + account.debit.toFixed(2) + ' '; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = currency_format.symbol + ' ' + account.credit.toFixed(2) + ' '; - - } - if (account.balance == 0) { - account.balance = ' - ' - - } else { - account.balance = currency_format.symbol + ' ' + account.balance.toFixed(2) + ' '; - - } - } else { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = account.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = account.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.balance == 0) { - account.balance = ' - ' - } else { - account.balance = account.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - } - }); - - if (initial_render) { - self.$('.bs-filter').html(QWeb.render('FilterSectionBS', { - filter_data: datas[0], - })); - - self.$el.find('.journal').select2({ - placeholder: 'Select Journal...', - }); - self.$el.find('.account').select2({ - placeholder: 'Select Account...', - }); - self.$el.find('.account-tag').select2({ - placeholder: 'Select Account Tag...', - }); - self.$el.find('.analytic-tag').select2({ - placeholder: 'Select Analytic Tag...', - }); - self.$el.find('.analytic').select2({ - placeholder: 'Select Analytic...', - }); - - self.$el.find('#date_from').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('#date_to').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('.entries').select2({ - placeholder: 'Select Moves', - }); - } - self.$('.container-bs-main').html(QWeb.render('BalanceSheetData', { - account_data: datas[1], - report_lines: datas[2] - })); - }); - }, - bs_lines_by_page: function(offset, account_id) { - var self = this; - return rpc.query({ - model: 'dynamic.balance.sheet', - method: 'bs_move_lines', - args: [self.wizard, offset, account_id], - }) - }, - get_move_lines: function(event) { - event.preventDefault(); - var self = this; - var account_id = $(event.currentTarget).data('account-id'); - var offset = 0; - var td = $(event.currentTarget).next('tr').find('td'); - if (td.length == 1) { - self.bs_lines_by_page(offset, account_id).then(function(datas) { - _.each(datas[2], function(data) { - var currency_format = { - currency_id: data.company_currency_id, - position: data.company_currency_position, - symbol: data.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = currency_format.symbol + ' ' + data.debit.toFixed(2) + ' '; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = currency_format.symbol + ' ' + data.credit.toFixed(2) + ' '; - - } - if (data.balance == 0) { - data.balance = ' - ' - - } else { - data.balance = currency_format.symbol + ' ' + data.balance.toFixed(2) + ' '; - - } - } else { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = data.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = data.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.balance == 0) { - data.balance = ' - ' - } else { - data.balance = data.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - - } - - - }); - $(event.currentTarget).next('tr').find('td .bs-table-div').remove(); - $(event.currentTarget).next('tr').find('td ul').after( - QWeb.render('SubSectionBS', { - count: datas[0], - offset: datas[1], - account_data: datas[2], - })) - $(event.currentTarget).next('tr').find('td ul li:first a').css({ - 'background-color': '#00ede8', - 'font-weight': 'bold', - }); - }) - } - }, - view_move: function(event) { - event.preventDefault(); - var self = this; - var context = {}; - var redirect_to_document = function(res_model, res_id, view_id) { - var action = { - type: 'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: res_model, - views: [ - [view_id || false, 'form'] - ], - res_id: res_id, - target: 'current', - context: context, - }; - return self.do_action(action); - }; - rpc.query({ - model: 'account.move', - method: 'search_read', - domain: [ - ['id', '=', $(event.currentTarget).data('move-id')] - ], - fields: ['id'], - limit: 1, - }) - .then(function(record) { - if (record.length > 0) { - redirect_to_document('account.move', record[0].id); - } else { - redirect_to_document('account.move', $(event.currentTarget).data('move-id')); - } - }); - }, - - }); - core.action_registry.add('dynamic.bs', BalanceSheet); - -}); \ No newline at end of file diff --git a/dynamic_financial_report/static/src/js/bank_book.js b/dynamic_financial_report/static/src/js/bank_book.js deleted file mode 100644 index 5cdf15850..000000000 --- a/dynamic_financial_report/static/src/js/bank_book.js +++ /dev/null @@ -1,995 +0,0 @@ -odoo.define('dynamic_financial_report.bank_book', function(require) { - 'use strict'; - var AbstractAction = require('web.AbstractAction'); - var core = require('web.core'); - var field_utils = require('web.field_utils'); - var rpc = require('web.rpc'); - var session = require('web.session'); - var utils = require('web.utils'); - var QWeb = core.qweb; - var _t = core._t; - - var BankBook = AbstractAction.extend({ - template: 'BankBook', - events: { - 'click .bb-line': 'get_move_lines', - 'click .view-move': 'view_move', - 'click #filter_apply_button': 'apply_filter', - 'click #pdf': 'print_pdf', - 'click #xlsx': 'print_xlsx', - }, - init: function(view, code) { - this._super(view, code); - this.wizard = code.context.wizard | null; - this.session = session; - }, - start: function() { - var self = this; - self.initial_render = true; - - rpc.query({ - model: 'dynamic.bank.book', - method: 'create', - args: [{ - - }] - }).then(function(res) { - self.wizard = res; - self.bank_view(self.initial_render); - }) - - }, - apply_filter: function(event) { - - event.preventDefault(); - var self = this; - - self.initial_render = false; - var output = {}; - - - var account_ids = []; - var account_text = []; - - - var account_res = document.getElementById("acc_res") - var account_list = $(".account").select2('data') - for (var i = 0; i < account_list.length; i++) { - - if(account_list[i].element[0].selected === true){ - - account_ids.push(parseInt(account_list[i].id)) - if(account_text.includes(account_list[i].text) === false){ - account_text.push(account_list[i].text) - - } - - - account_res.value = account_text - account_res.innerHTML=account_res.value; - } - } - if (account_list.length == 0){ - account_res.value = "" - account_res.innerHTML=""; - - } - output.account_ids = account_ids - - - var journal_ids = []; - var journal_text = []; - var journal_res = document.getElementById("journal_res") - var journal_list = $(".journal").select2('data') - for (var i = 0; i < journal_list.length; i++) { - - if(journal_list[i].element[0].selected === true){ - - journal_ids.push(parseInt(journal_list[i].id)) - if(journal_text.includes(journal_list[i].text) === false){ - journal_text.push(journal_list[i].text) - - } - - - journal_res.value = journal_text - journal_res.innerHTML=journal_res.value; - } - } - if (journal_list.length == 0){ - journal_res.value = "" - journal_res.innerHTML=""; - - } - output.journal_ids = journal_ids - - - var account_tag_ids = []; - var account_tag_text = []; - var account_tag_res = document.getElementById("acc_tag_res") - var account_tag_list = $(".account-tag").select2('data') - for (var i = 0; i < account_tag_list.length; i++) { - if(account_tag_list[i].element[0].selected === true){ - - account_tag_ids.push(parseInt(account_tag_list[i].id)) - if(account_tag_text.includes(account_tag_list[i].text) === false){ - account_tag_text.push(account_tag_list[i].text) - } - - account_tag_res.value = account_tag_text - account_tag_res.innerHTML=account_tag_res.value; - } - } - if (account_tag_list.length == 0){ - account_tag_res.value = "" - account_tag_res.innerHTML=""; - - } - output.account_tag_ids = account_tag_ids - - - - var analytic_ids = []; - var analytic_text = []; - var span_res = document.getElementById("analic_res") - var analytic_list = $(".analytic").select2('data') - for (var i = 0; i < analytic_list.length; i++) { - if(analytic_list[i].element[0].selected === true){ - - analytic_ids.push(parseInt(analytic_list[i].id)) - if(analytic_text.includes(analytic_list[i].text) === false){ - analytic_text.push(analytic_list[i].text) - } - - - span_res.value = analytic_text - span_res.innerHTML=span_res.value; - } - } - if (analytic_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; - - } - output.analytic_ids = analytic_ids - - - output.analytic_tag_ids = analytic_tag_ids - - var analytic_tag_ids = []; - var analytic_tag_text = []; - var analytic_tag_res = document.getElementById("analic_tag_res") - var analytic_tag_list = $(".analytic-tag").select2('data') - for (var i = 0; i < analytic_tag_list.length; i++) { - if(analytic_tag_list[i].element[0].selected === true){ - - analytic_tag_ids.push(parseInt(analytic_tag_list[i].id)) - if(analytic_tag_text.includes(analytic_tag_list[i].text) === false){ - analytic_tag_text.push(analytic_tag_list[i].text) - } - analytic_tag_res.value = analytic_tag_text - analytic_tag_res.innerHTML=analytic_tag_res.value; - } - } - if (analytic_tag_list.length == 0){ - analytic_tag_res.value = "" - analytic_tag_res.innerHTML=""; - - } - output.analytic_tag_ids = analytic_tag_ids - - - - - if ($("#date_from").val()) { - var dateObject = $("#date_from").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_from = dateString; - } - if ($("#date_to").val()) { - var dateObject = $("#date_to").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_to = dateString; - } - - if ($(".entries").length) { - var post_res = document.getElementById("post_res") - output.entries = $(".entries")[1].value - post_res.value = $(".entries")[1].value - post_res.innerHTML=post_res.value; - if ($(".entries")[1].value == "") { - post_res.innerHTML="all"; - - } - } - output.include_details = true; - - - - rpc.query({ - model: 'dynamic.bank.book', - method: 'write', - args: [ - [self.wizard], output - ], - }).then(function(res) { - self.bank_view(self.initial_render); - }); - }, - - print_pdf: function(e) { - e.preventDefault(); - var self = this; - var action_title = self._title - - self._rpc({ - model: 'dynamic.bank.book', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(data) { - var action = { - 'type': 'ir.actions.report', - 'report_type': 'qweb-pdf', - 'report_name': 'dynamic_financial_report.bank_book', - 'report_file': 'dynamic_financial_report.bank_book', - 'data': { - 'report_data': data - }, - 'context': { - 'active_model': 'dynamic.bank.book', - 'landscape': 1, - 'js_report': true - }, - 'display_name': 'Bank Book', - }; - return self.do_action(action); - }); - }, - print_xlsx: function() { - var self = this; - var action_title = self._title - self._rpc({ - model: 'dynamic.bank.book', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(data) { - var action = { - 'type': 'ir_actions_xlsx_download', - 'data': { - 'model': 'dynamic.bank.book', - 'options': JSON.stringify(data[1]), - 'output_format': 'xlsx', - 'report_data': JSON.stringify(data[0]), - 'report_name': 'Bank Book', - 'dfr_data': 'Bank Book', - }, - }; - return self.do_action(action); - }); - }, - - bank_view: function(initial_render = true) { - var self = this; - var node = self.$('.container-bb-main'); - var action_title = self._title - var last; - while (last = node.lastChild) node.removeChild(last); - rpc.query({ - model: 'dynamic.bank.book', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(datas) { - self.filter_data = datas[0] - - self.account_data = datas[1] - - _.each(self.account_data, function(account) { - var currency_format = { - currency_id: account.company_currency_id, - position: account.company_currency_position, - symbol: account.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = currency_format.symbol + ' ' + account.debit.toFixed(2) + ' '; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = currency_format.symbol + ' ' + account.credit.toFixed(2) + ' '; - - } - if (account.balance == 0) { - account.balance = ' - ' - - } else { - account.balance = currency_format.symbol + ' ' + account.balance.toFixed(2) + ' '; - - } - } else { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = account.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = account.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.balance == 0) { - account.balance = ' - ' - } else { - account.balance = account.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - } - }); - if (initial_render) { - self.$('.bb-filter').html(QWeb.render('FilterSectionBB', { - filter_data: datas[0], - })); - - self.$el.find('.journal').select2({ - placeholder: 'Select Journal...', - }); - self.$el.find('.account').select2({ - placeholder: 'Select Account...', - }); - self.$el.find('.account-tag').select2({ - placeholder: 'Select Account Tag...', - }); - self.$el.find('.analytic-tag').select2({ - placeholder: 'Select Analytic Tag...', - }); - self.$el.find('.analytic').select2({ - placeholder: 'Select Analytic...', - }); - - self.$el.find('#date_from').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('#date_to').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('.entries').select2({ - placeholder: 'Select Moves', - }); - } - self.$('.container-bb-main').html(QWeb.render('BankBookData', { - account_data: datas[1] - })); - }); - }, - bb_lines_by_page: function(offset, account_id) { - var self = this; - return rpc.query({ - model: 'dynamic.bank.book', - method: 'bb_move_lines', - args: [self.wizard, offset, account_id], - }) - }, - get_move_lines: function(event) { - event.preventDefault(); - var self = this; - var account_id = $(event.currentTarget).data('account-id'); - var offset = 0; - var td = $(event.currentTarget).next('tr').find('td'); - if (td.length == 1) { - self.bb_lines_by_page(offset, account_id).then(function(datas) { - _.each(datas[2], function(data) { - var currency_format = { - currency_id: data.company_currency_id, - position: data.company_currency_position, - symbol: data.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = currency_format.symbol + ' ' + data.debit.toFixed(2) + ' '; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = currency_format.symbol + ' ' + data.credit.toFixed(2) + ' '; - - } - if (data.balance == 0) { - data.balance = ' - ' - - } else { - data.balance = currency_format.symbol + ' ' + data.balance.toFixed(2) + ' '; - - } - } else { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = data.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = data.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.balance == 0) { - data.balance = ' - ' - } else { - data.balance = data.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - - } - - - }); - $(event.currentTarget).next('tr').find('td .bb-table-div').remove(); - $(event.currentTarget).next('tr').find('td ul').after( - QWeb.render('SubSectionBB', { - count: datas[0], - offset: datas[1], - account_data: datas[2], - })) - $(event.currentTarget).next('tr').find('td ul li:first a').css({ - 'background-color': '#00ede8', - 'font-weight': 'bold', - }); - }) - } - }, - view_move: function(event) { - event.preventDefault(); - var self = this; - var context = {}; - var redirect_to_document = function(res_model, res_id, view_id) { - var action = { - type: 'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: res_model, - views: [ - [view_id || false, 'form'] - ], - res_id: res_id, - target: 'current', - context: context, - }; - return self.do_action(action); - }; - rpc.query({ - model: 'account.move', - method: 'search_read', - domain: [ - ['id', '=', $(event.currentTarget).data('move-id')] - ], - fields: ['id'], - limit: 1, - }) - .then(function(record) { - if (record.length > 0) { - redirect_to_document('account.move', record[0].id); - } else { - redirect_to_document('account.move', $(event.currentTarget).data('move-id')); - } - }); - }, - - }); - - - var CashBook = AbstractAction.extend({ - template: 'CashBook', - events: { - 'click .cb-line': 'get_move_lines', - 'click .view-move': 'view_move', - 'click #filter_apply_button': 'apply_filter', - 'click #pdf': 'print_pdf', - 'click #xlsx': 'print_xlsx', - }, - init: function(view, code) { - this._super(view, code); - this.wizard = code.context.wizard | null; - this.session = session; - }, - start: function() { - var self = this; - self.initial_render = true; - rpc.query({ - model: 'dynamic.bank.book', - method: 'create', - args: [{ - - }] - }).then(function(res) { - self.wizard = res; - self.cash_view(self.initial_render); - }) - - }, - apply_filter: function(event) { - - event.preventDefault(); - var self = this; - - self.initial_render = false; - var output = {}; - - - var account_ids = []; - var account_text = []; - - var account_res = document.getElementById("acc_res") - var account_list = $(".account").select2('data') - for (var i = 0; i < account_list.length; i++) { - - if(account_list[i].element[0].selected === true){ - - account_ids.push(parseInt(account_list[i].id)) - if(account_text.includes(account_list[i].text) === false){ - account_text.push(account_list[i].text) - - } - - account_res.value = account_text - account_res.innerHTML=account_res.value; - } - } - if (account_list.length == 0){ - account_res.value = "" - account_res.innerHTML=""; - - } - output.account_ids = account_ids - - - var journal_ids = []; - var journal_text = []; - var journal_res = document.getElementById("journal_res") - var journal_list = $(".journal").select2('data') - for (var i = 0; i < journal_list.length; i++) { - - - if(journal_list[i].element[0].selected === true){ - - journal_ids.push(parseInt(journal_list[i].id)) - if(journal_text.includes(journal_list[i].text) === false){ - journal_text.push(journal_list[i].text) - } - - journal_res.value = journal_text - journal_res.innerHTML=journal_res.value; - } - } - if (journal_list.length == 0){ - journal_res.value = "" - journal_res.innerHTML=""; - - } - output.journal_ids = journal_ids - - - var account_tag_ids = []; - var account_tag_text = []; - var account_tag_res = document.getElementById("acc_tag_res") - var account_tag_list = $(".account-tag").select2('data') - for (var i = 0; i < account_tag_list.length; i++) { - if(account_tag_list[i].element[0].selected === true){ - - account_tag_ids.push(parseInt(account_tag_list[i].id)) - if(account_tag_text.includes(account_tag_list[i].text) === false){ - account_tag_text.push(account_tag_list[i].text) - } - account_tag_res.value = account_tag_text - account_tag_res.innerHTML=account_tag_res.value; - } - } - if (account_tag_list.length == 0){ - account_tag_res.value = "" - account_tag_res.innerHTML=""; - - } - output.account_tag_ids = account_tag_ids - - - - var analytic_ids = []; - var analytic_text = []; - var span_res = document.getElementById("analic_res") - var analytic_list = $(".analytic").select2('data') - for (var i = 0; i < analytic_list.length; i++) { - if(analytic_list[i].element[0].selected === true){ - - analytic_ids.push(parseInt(analytic_list[i].id)) - if(analytic_text.includes(analytic_list[i].text) === false){ - analytic_text.push(analytic_list[i].text) - - } - - - span_res.value = analytic_text - span_res.innerHTML=span_res.value; - } - } - if (analytic_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; - - } - output.analytic_ids = analytic_ids - - output.analytic_tag_ids = analytic_tag_ids - - var analytic_tag_ids = []; - var analytic_tag_text = []; - var analytic_tag_res = document.getElementById("analic_tag_res") - var analytic_tag_list = $(".analytic-tag").select2('data') - for (var i = 0; i < analytic_tag_list.length; i++) { - if(analytic_tag_list[i].element[0].selected === true){ - - analytic_tag_ids.push(parseInt(analytic_tag_list[i].id)) - if(analytic_tag_text.includes(analytic_tag_list[i].text) === false){ - analytic_tag_text.push(analytic_tag_list[i].text) - - } - - - analytic_tag_res.value = analytic_tag_text - analytic_tag_res.innerHTML=analytic_tag_res.value; - } - } - if (analytic_tag_list.length == 0){ - analytic_tag_res.value = "" - analytic_tag_res.innerHTML=""; - - } - output.analytic_tag_ids = analytic_tag_ids - - - - - if ($("#date_from").val()) { - var dateObject = $("#date_from").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_from = dateString; - } - if ($("#date_to").val()) { - var dateObject = $("#date_to").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_to = dateString; - } - - if ($(".entries").length) { - var post_res = document.getElementById("post_res") - output.entries = $(".entries")[1].value - post_res.value = $(".entries")[1].value - post_res.innerHTML=post_res.value; - if ($(".entries")[1].value == "") { - post_res.innerHTML="all"; - - } - } - - output.include_details = true; - - rpc.query({ - model: 'dynamic.bank.book', - method: 'write', - args: [ - [self.wizard], output - ], - }).then(function(res) { - self.cash_view(self.initial_render); - }); - }, - - print_pdf: function(e) { - e.preventDefault(); - var self = this; - var action_title = self._title - self._rpc({ - model: 'dynamic.bank.book', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(data) { - var action = { - 'type': 'ir.actions.report', - 'report_type': 'qweb-pdf', - 'report_name': 'dynamic_financial_report.cash_book', - 'report_file': 'dynamic_financial_report.cash_book', - 'data': { - 'report_data': data - }, - 'context': { - 'active_model': 'dynamic.bank.book', - 'landscape': 1, - 'js_report': true - }, - 'display_name': 'Cash Book', - }; - return self.do_action(action); - }); - }, - print_xlsx: function() { - var self = this; - var action_title = self._title - - self._rpc({ - model: 'dynamic.bank.book', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(data) { - var action = { - 'type': 'ir_actions_xlsx_download', - 'data': { - 'model': 'dynamic.bank.book', - 'options': JSON.stringify(data[1]), - 'output_format': 'xlsx', - 'report_data': JSON.stringify(data[0]), - 'report_name': 'Cash Book', - 'dfr_data': 'Cash Book', - }, - }; - return self.do_action(action); - }); - }, - - cash_view: function(initial_render = true) { - var self = this; - var action_title = self._title - console.log("djhhdbkjd", action_title) - - var node = self.$('.container-cb-main'); - var last; - while (last = node.lastChild) node.removeChild(last); - rpc.query({ - model: 'dynamic.bank.book', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(datas) { - self.filter_data = datas[0] - - self.account_data = datas[1] - - _.each(self.account_data, function(account) { - var currency_format = { - currency_id: account.company_currency_id, - position: account.company_currency_position, - symbol: account.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = currency_format.symbol + ' ' + account.debit.toFixed(2) + ' '; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = currency_format.symbol + ' ' + account.credit.toFixed(2) + ' '; - - } - if (account.balance == 0) { - account.balance = ' - ' - - } else { - account.balance = currency_format.symbol + ' ' + account.balance.toFixed(2) + ' '; - - } - } else { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = account.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = account.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.balance == 0) { - account.balance = ' - ' - } else { - account.balance = account.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - } - }); - if (initial_render) { - self.$('.cb-filter').html(QWeb.render('FilterSectionCB', { - filter_data: datas[0], - })); - - self.$el.find('.journal').select2({ - placeholder: 'Select Journal...', - }); - self.$el.find('.account').select2({ - placeholder: 'Select Account...', - }); - self.$el.find('.account-tag').select2({ - placeholder: 'Select Account Tag...', - }); - self.$el.find('.analytic-tag').select2({ - placeholder: 'Select Analytic Tag...', - }); - self.$el.find('.analytic').select2({ - placeholder: 'Select Analytic...', - }); - - self.$el.find('#date_from').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('#date_to').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('.entries').select2({ - placeholder: 'Select Moves', - }); - } - self.$('.container-cb-main').html(QWeb.render('CashBookData', { - account_data: datas[1] - })); - }); - }, - cb_lines_by_page: function(offset, account_id) { - var self = this; - return rpc.query({ - model: 'dynamic.bank.book', - method: 'bb_move_lines', - args: [self.wizard, offset, account_id], - }) - }, - get_move_lines: function(event) { - event.preventDefault(); - var self = this; - var account_id = $(event.currentTarget).data('account-id'); - var offset = 0; - var td = $(event.currentTarget).next('tr').find('td'); - if (td.length == 1) { - self.cb_lines_by_page(offset, account_id).then(function(datas) { - _.each(datas[2], function(data) { - var currency_format = { - currency_id: data.company_currency_id, - position: data.company_currency_position, - symbol: data.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = currency_format.symbol + ' ' + data.debit.toFixed(2) + ' '; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = currency_format.symbol + ' ' + data.credit.toFixed(2) + ' '; - - } - if (data.balance == 0) { - data.balance = ' - ' - - } else { - data.balance = currency_format.symbol + ' ' + data.balance.toFixed(2) + ' '; - - } - } else { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = data.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = data.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.balance == 0) { - data.balance = ' - ' - } else { - data.balance = data.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - - } - - - }); - $(event.currentTarget).next('tr').find('td .cb-table-div').remove(); - $(event.currentTarget).next('tr').find('td ul').after( - QWeb.render('SubSectionCB', { - count: datas[0], - offset: datas[1], - account_data: datas[2], - })) - $(event.currentTarget).next('tr').find('td ul li:first a').css({ - 'background-color': '#00ede8', - 'font-weight': 'bold', - }); - }) - } - }, - view_move: function(event) { - event.preventDefault(); - var self = this; - var context = {}; - var redirect_to_document = function(res_model, res_id, view_id) { - var action = { - type: 'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: res_model, - views: [ - [view_id || false, 'form'] - ], - res_id: res_id, - target: 'current', - context: context, - }; - return self.do_action(action); - }; - rpc.query({ - model: 'account.move', - method: 'search_read', - domain: [ - ['id', '=', $(event.currentTarget).data('move-id')] - ], - fields: ['id'], - limit: 1, - }) - .then(function(record) { - if (record.length > 0) { - redirect_to_document('account.move', record[0].id); - } else { - redirect_to_document('account.move', $(event.currentTarget).data('move-id')); - } - }); - }, - - }); - - core.action_registry.add('dynamic.bb', BankBook); - core.action_registry.add('dynamic.cb', CashBook); - -}); \ No newline at end of file diff --git a/dynamic_financial_report/static/src/js/cash_flow.js b/dynamic_financial_report/static/src/js/cash_flow.js deleted file mode 100644 index 88e3ec21e..000000000 --- a/dynamic_financial_report/static/src/js/cash_flow.js +++ /dev/null @@ -1,368 +0,0 @@ -odoo.define('dynamic_financial_report.DynamicReports', function(require) { - 'use strict'; - var AbstractAction = require('web.AbstractAction'); - var core = require('web.core'); - var Dialog = require('web.Dialog'); - var field_utils = require('web.field_utils'); - var rpc = require('web.rpc'); - var session = require('web.session'); - var utils = require('web.utils'); - var QWeb = core.qweb; - var _t = core._t; - var CashFlow = AbstractAction.extend({ - template: 'CashFlow', - events: { - 'click .cf-line': 'get_move_lines', - 'click .view-move': 'view_move', - 'click #filter_apply_button': 'apply_filter', - 'click #pdf': 'print_pdf', - 'click #xlsx': 'print_xlsx', - }, - init: function(view, code) { - this._super(view, code); - this.wizard = code.context.wizard | null; - this.session = session; - - }, - start: function() { - var self = this; - self.initial_render = true; - rpc.query({ - model: 'dynamic.cash.flow', - method: 'create', - args: [{ - res_model: this.res_model - }] - }).then(function(res) { - self.wizard = res; - self.ledger_view(self.initial_render); - }) - }, - apply_filter: function(event) { - event.preventDefault(); - var self = this; - - self.initial_render = false; - var output = {}; - output.reconciled=false; - output.type=false; - output.date_from=false; - output.date_to=false; - - if ($(".level").length){ - var level_res = document.getElementById("level_res") - output.level = $(".level")[1].value - level_res.value = $(".level")[1].value - level_res.innerHTML=level_res.value; - if ($(".level").value==""){ - type_res.innerHTML="summary"; - output.type = "Summary" - } - } - - - var journal_ids = []; - var journal_list = $(".journal").select2('data') - for (var i = 0; i < journal_list.length; i++) { - journal_ids.push(parseInt(journal_list[i].id)) - } - output.journal_ids = journal_ids - var analytic_ids = []; - var analytic_list = $(".analytic").select2('data') - for (var i = 0; i < analytic_list.length; i++) { - analytic_ids.push(parseInt(analytic_list[i].id)) - } - output.analytic_ids = analytic_ids - var analytic_tag_ids = []; - var analytic_tag_list = $(".analytic-tag").select2('data') - for (var i = 0; i < analytic_tag_list.length; i++) { - analytic_tag_ids.push(parseInt(analytic_tag_list[i].id)) - } - output.analytic_tag_ids = analytic_tag_ids - if ($(".target-moves").length){ - var target_res = document.getElementById("target_res") - output.target_moves = $(".target-moves")[1].value - target_res.value = $(".target-moves")[1].value - target_res.innerHTML=target_res.value; - if ($(".target-moves").value==""){ - target_res.innerHTML="all"; - output.target_moves = "all" - } - } - - if ($("#date_from").val()) { - var dateObject = $("#date_from").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_from = dateString; - } - - if ($("#date_to").val()) { - var dateObject = $("#date_to").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_to = dateString; - } - output.include_details = true; - - rpc.query({ - model: 'dynamic.cash.flow', - method: 'write', - args: [ - [self.wizard], output - ], - }).then(function(res) { - self.ledger_view(self.initial_render); - }); - }, - - print_pdf: function(e) { - e.preventDefault(); - var self = this; - self._rpc({ - model: 'dynamic.cash.flow', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - var action = { - 'type': 'ir.actions.report', - 'report_type': 'qweb-pdf', - 'report_name': 'dynamic_financial_report.cash_flow', - 'report_file': 'dynamic_financial_report.cash_flow', - 'data': { - 'report_data': data - }, - 'context': { - 'active_model': 'dynamic.cash.flow', - 'landscape': 1, - 'js_report': true - }, - 'display_name': 'Cash Flow', - }; - return self.do_action(action); - }); - }, - - print_xlsx: function() { - var self = this; - self._rpc({ - model: 'dynamic.cash.flow', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - var action = { - 'type': 'ir_actions_xlsx_download', - 'data': { - 'model': 'dynamic.cash.flow', - 'options': JSON.stringify(data[1]), - 'output_format': 'xlsx', - 'report_data': JSON.stringify(data[0]), - 'report_name': 'Cash Flow', - 'dfr_data': JSON.stringify(data), - }, - }; - return self.do_action(action); - }); - }, - - ledger_view: function(initial_render = true) { - var self = this; - var node = self.$('.container-cf-main'); - var last; - while (last = node.lastChild) node.removeChild(last); - rpc.query({ - model: 'dynamic.cash.flow', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(datas) { - self.filter_data = datas[0] - self.account_data = datas[1] - _.each(self.account_data.fetched_data, function(account) { - var currency_format = { - currency_id: datas[1].company_currency_id, - position: datas[1].company_currency_position, - symbol: datas[1].company_currency_symbol, - - noSymbol: true, - }; - if (currency_format.position == "before") { - - if (account.total_credit == 0) { - account.total_credit = ' - ' - } else { - account.total_credit = currency_format.symbol + ' ' + account.total_credit.toFixed(2) + ' '; - - } - if (account.total_debit == 0) { - account.total_debit = ' - ' - - } else { - account.total_debit = currency_format.symbol + ' ' + account.total_debit.toFixed(2) + ' '; - - } - if (account.total_balance == 0) { - account.total_balance = ' - ' - - } else { - account.total_balance = currency_format.symbol + ' ' + account.total_balance.toFixed(2) + ' '; - - } - - - - } else {if (account.total_credit == 0) { - account.total_credit = ' - ' - } else { - account.total_credit = account.total_credit.toFixed(2) + ' ' + currency_format.symbol; -// - } - if (account.total_debit == 0) { - account.total_debit = ' - ' - - } else { - account.total_debit = account.total_debit.toFixed(2) + ' ' + currency_format.symbol; - - } - if (account.total_balance == 0) { - account.total_balance = ' - ' - } else { - account.total_balance = account.total_balance.toFixed(2) + ' ' + currency_format.symbol; - - } -// - } - }); - if (initial_render) { - self.$('.cf-filter').html(QWeb.render('FilterSectionCF', { - filter_data: datas[0], - })); - - self.$el.find('.journal').select2({ - placeholder: 'Select Journal...', - }); - self.$el.find('.level').select2({ - placeholder: 'Select Level...', - }); - - self.$el.find('.analytic-tag').select2({ - placeholder: 'Select Analytic Tag...', - }); - self.$el.find('.analytic').select2({ - placeholder: 'Select Analytic...', - }); - - self.$el.find('#date_from').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('#date_to').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('.target-moves').select2({ - placeholder: 'Posted or All Entries...', - }); - } - - self.$('.container-cf-main').html(QWeb.render('CashFlowData', { - account_data: datas[1].fetched_data, - level:datas[1].levels, - })); - - }); - }, - - - - - get_move_lines: function(event) { - event.preventDefault(); - var self = this; - var account_id = $(event.currentTarget).data('account-id'); - var offset = 0; - var td = $(event.currentTarget).next('tr').find('td'); - if (td.length == 1) { - rpc.query({ - model: 'dynamic.cash.flow', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(datas) { - - if(datas[1].levels== 'detailed'){ - $(event.currentTarget).next('tr').find('td ul').after( - QWeb.render('SubSectionCF', { - count: 3, - offset: 0, - account_data: datas[1].journal_res, - level:datas[1].levels, - data_currency: datas[1], - line_id:parseInt(event.currentTarget.attributes[3].value), - })) - }else if(datas[1].levels== 'very' || datas[1].levels== false){ - $(event.currentTarget).next('tr').find('td ul').after( - QWeb.render('ChildSubSectionCF', { - count: 3, - offset: 0, - account_data: datas[1].account_res, - level:datas[1].levels, - data_currency: datas[1], - line_id:parseInt(event.currentTarget.attributes[3].value), - })) - } - - $(event.currentTarget).next('tr').find('td ul li:first a').css({ - 'background-color': '#00ede8', - 'font-weight': 'bold', - }); - }) - } - }, - view_move: function(event) { - event.preventDefault(); - var self = this; - var context = {}; - var redirect_to_document = function(res_model, res_id, view_id) { - - var action = { - type: 'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: res_model, - views: [ - [view_id || false, 'form'] - ], - res_id: res_id, - target: 'current', - context: context, - }; - return self.do_action(action); - }; - rpc.query({ - model: 'account.move', - method: 'search_read', - domain: [ - ['id', '=', $(event.currentTarget).data('move-id')] - ], - fields: ['id'], - limit: 1, - }) - .then(function(record) { - if (record.length > 0) { - redirect_to_document('account.move', record[0].id); - } else { - redirect_to_document('account.move', $(event.currentTarget).data('move-id')); - } - }); - }, - - }); - - core.action_registry.add('dynamic.cf', CashFlow); - return CashFlow; - - -}); \ No newline at end of file diff --git a/dynamic_financial_report/static/src/js/daybook.js b/dynamic_financial_report/static/src/js/daybook.js deleted file mode 100644 index 1107b4136..000000000 --- a/dynamic_financial_report/static/src/js/daybook.js +++ /dev/null @@ -1,414 +0,0 @@ -odoo.define('dynamic_financial_report.daybook', function(require) { - 'use strict'; - var AbstractAction = require('web.AbstractAction'); - var core = require('web.core'); - var field_utils = require('web.field_utils'); - var rpc = require('web.rpc'); - var session = require('web.session'); - var utils = require('web.utils'); - var QWeb = core.qweb; - var _t = core._t; - - var DayBook = AbstractAction.extend({ - template: 'DayBook', - events: { - 'click .db-line': 'get_move_lines', - 'click .view-move': 'view_move', - 'click #filter_apply_button': 'apply_filter', - 'click #pdf': 'print_pdf', - 'click #xlsx': 'print_xlsx', - }, - init: function(view, code) { - this._super(view, code); - this.wizard = code.context.wizard | null; - this.session = session; - }, - start: function() { - var self = this; - self.initial_render = true; - rpc.query({ - model: 'dynamic.day.book', - method: 'create', - args: [{ - res_model: this.res_model - }] - }).then(function(res) { - self.wizard = res; - self.ledger_view(self.initial_render); - }) - }, - apply_filter: function(event) { - - event.preventDefault(); - var self = this; - self.initial_render = false; - var output = {}; - output.date_from=false; - output.date_to=false; - - - var journal_ids = []; - var journal_text = []; - var span_res = document.getElementById("journal_res") - - var journal_list = $(".journal").select2('data') - for (var i = 0; i < journal_list.length; i++) { - - if(journal_list[i].element[0].selected === true) - {journal_ids.push(parseInt(journal_list[i].id)) - if(journal_text.includes(journal_list[i].text) === false) - {journal_text.push(journal_list[i].text) - - } - - span_res.value = journal_text - span_res.innerHTML=span_res.value; - } - } - if (journal_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; } - output.journal_ids = journal_ids - - - var account_ids = []; - var account_text = []; - var span_res = document.getElementById("account_res") - - var account_list = $(".account").select2('data') - for (var i = 0; i < account_list.length; i++) { - - if(account_list[i].element[0].selected === true) - {account_ids.push(parseInt(account_list[i].id)) - if(account_text.includes(account_list[i].text) === false) - {account_text.push(account_list[i].text) - - } - - span_res.value = account_text - span_res.innerHTML=span_res.value; - } - } - if (account_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; } - output.account_ids = account_ids - - - - if ($(".entries").length){ - var target_res = document.getElementById("target_res") - output.entries = $(".entries")[1].value - target_res.value = $(".entries")[1].value - target_res.innerHTML=target_res.value; - if ($(".entries").value==""){ - target_res.innerHTML="all"; - output.entries = "all" - } - } - - - if ($("#date_from").val()) { - var dateObject = $("#date_from").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_from = dateString; - } - if ($("#date_to").val()) { - var dateObject = $("#date_to").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_to = dateString; - } - output.include_details = true; - - rpc.query({ - model: 'dynamic.day.book', - method: 'write', - args: [ - [self.wizard], output - ], - }).then(function(res) { - self.ledger_view(self.initial_render); - }); - }, - - print_pdf: function(e) { - e.preventDefault(); - var self = this; - self._rpc({ - model: 'dynamic.day.book', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - var action = { - 'type': 'ir.actions.report', - 'report_type': 'qweb-pdf', - 'report_name': 'dynamic_financial_report.dynamic_day_book', - 'report_file': 'dynamic_financial_report.dynamic_day_book', - 'data': { - 'report_data': data - }, - 'context': { - 'active_model': 'dynamic.day.book', - 'landscape': 1, - 'js_report': true - }, - 'display_name': 'Day Book', - }; - return self.do_action(action); - }); - }, - print_xlsx: function() { - var self = this; - self._rpc({ - model: 'dynamic.day.book', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - - var action = { - 'type': 'ir_actions_xlsx_download', - 'data': { - 'model': 'dynamic.day.book', - 'options': JSON.stringify(data[1]), - 'output_format': 'xlsx', - 'report_data': JSON.stringify((data[2][2])), - 'report_name': 'Day Book', - 'dfr_data':JSON.stringify(data[0]), - - }, - - }; - - return self.do_action(action); - }); - }, - - ledger_view: function(initial_render = true) { - - var self = this; - var node = self.$('.container-db-main'); - var last; - while (last = node.lastChild) node.removeChild(last); - rpc.query({ - model: 'dynamic.day.book', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(datas) { - - self.filter_data = datas[0] - self.account_data = datas[1] - - - _.each(self.account_data, function(account) { - - var currency_format = { - currency_id: account.company_currency_id, - position: account.company_currency_position, - symbol: account.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = currency_format.symbol + ' ' + account.debit.toFixed(2) + ' '; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = currency_format.symbol + ' ' + account.credit.toFixed(2) + ' '; - - } - if (account.balance == 0) { - account.balance = ' - ' - - } else { - account.balance = currency_format.symbol + ' ' + account.balance.toFixed(2) + ' '; - - } - } else { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = account.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = account.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.balance == 0) { - account.balance = ' - ' - } else { - account.balance = account.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - } - }); - if (initial_render) { - self.$('.db-filter').html(QWeb.render('FilterSectiondb', { - filter_data: datas[0], - })); - - self.$el.find('.journal').select2({ - placeholder: 'Select Journal...', - }); - self.$el.find('.account').select2({ - placeholder: 'Select Account...', - }); - self.$el.find('.entries').select2({ - placeholder: 'Select Moves', - }); - - self.$el.find('#date_from').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('#date_to').datepicker({ - dateFormat: 'dd-mm-yy' - }); - } - self.$('.container-db-main').html(QWeb.render('DayBookData', { - account_data: datas[1] - })); - - }); - }, - db_lines_by_page: function(offset, account_id) { - var self = this; - return rpc.query({ - model: 'dynamic.day.book', - method: 'db_move_lines', - args: [self.wizard, offset, account_id], - }) - }, - get_move_lines: function(event) { - event.preventDefault(); - var self = this; - var account_id = $(event.currentTarget).data('account-id'); - var date_id = $(event.currentTarget)[0].cells[0].innerText; - var offset = 0; - var td = $(event.currentTarget).next('tr').find('td'); - if (td.length == 1) { - self.db_lines_by_page(offset, account_id).then(function(datas) { - _.each(datas[2], function(data) { - - var currency_format = { - currency_id: data.company_currency_id, - position: data.company_currency_position, - symbol: data.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = currency_format.symbol + ' ' + data.debit.toFixed(2) + ' '; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = currency_format.symbol + ' ' + data.credit.toFixed(2) + ' '; - - } - if (data.balance == 0) { - data.balance = ' - ' - - } else { - data.balance = currency_format.symbol + ' ' + data.balance.toFixed(2) + ' '; - - } - } else { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = data.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = data.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.balance == 0) { - data.balance = ' - ' - } else { - data.balance = data.balance.toFixed(2) + ' ' + currency_id.symbol; - } - } - }); - $(event.currentTarget).next('tr').find('td .db-table-div').remove(); - $(event.currentTarget).next('tr').find('td ul').after( - QWeb.render('SubSectiondb', { - count: datas[0], - offset: datas[1], - account_data: datas[2], - date_id: date_id.trim() - })); - - $(event.currentTarget).next('tr').find('td ul li:first a').css({ - 'background-color': '#00ede8', - 'font-weight': 'bold', - }); - }) - } - }, - view_move: function(event) { - event.preventDefault(); - var self = this; - var context = {}; - var redirect_to_document = function(res_model, res_id, view_id) { - - var action = { - type: 'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: res_model, - views: [ - [view_id || false, 'form'] - ], - res_id: res_id, - target: 'current', - context: context, - }; - return self.do_action(action); - }; - rpc.query({ - model: 'account.move', - method: 'search_read', - domain: [ - ['id', '=', $(event.currentTarget).data('move-id')] - ], - fields: ['id'], - limit: 1, - }) - .then(function(record) { - if (record.length > 0) { - redirect_to_document('account.move', record[0].id); - } else { - redirect_to_document('account.move', $(event.currentTarget).data('move-id')); - } - }); - }, - - }); - - core.action_registry.add('dynamic.db', DayBook); - -}); \ No newline at end of file diff --git a/dynamic_financial_report/static/src/js/gl_tb.js b/dynamic_financial_report/static/src/js/gl_tb.js deleted file mode 100644 index 5cbc2a62c..000000000 --- a/dynamic_financial_report/static/src/js/gl_tb.js +++ /dev/null @@ -1,876 +0,0 @@ -odoo.define('dynamic_financial_report.DynamicReport', function(require) { - 'use strict'; - var AbstractAction = require('web.AbstractAction'); - var core = require('web.core'); - var field_utils = require('web.field_utils'); - var rpc = require('web.rpc'); - var session = require('web.session'); - var utils = require('web.utils'); - var QWeb = core.qweb; - var _t = core._t; - - var GeneralLedger = AbstractAction.extend({ - template: 'GeneralLedger', - events: { - 'click .gl-line': 'get_move_lines', - 'click .view-move': 'view_move', - 'click #filter_apply_button': 'apply_filter', - 'click #pdf': 'print_pdf', - 'click #xlsx': 'print_xlsx', - }, - init: function(view, code) { - this._super(view, code); - this.wizard = code.context.wizard | null; - this.session = session; - }, - start: function() { - var self = this; - self.initial_render = true; - if (this.searchModel.config.domain.length != 0) { - - rpc.query({ - model: 'dynamic.general.ledger', - method: 'create', - args: [{ - account_ids: [this.searchModel.config.domain[0][2]] - }] - }).then(function(res) { - self.wizard = res; - self.ledger_view(self.initial_render); - }) - }else{ - - rpc.query({ - model: 'dynamic.general.ledger', - method: 'create', - args: [{ - - }] - }).then(function(res) { - self.wizard = res; - self.ledger_view(self.initial_render); - }) - - - - } - }, - apply_filter: function(event) { - - event.preventDefault(); - var self = this; - - self.initial_render = false; - var output = {}; - - - var account_ids = []; - var account_text = []; - - var account_res = document.getElementById("acc_res") - var account_list = $(".account").select2('data') - for (var i = 0; i < account_list.length; i++) { - if(account_list[i].element[0].selected === true){ - - account_ids.push(parseInt(account_list[i].id)) - if(account_text.includes(account_list[i].text) === false){ - account_text.push(account_list[i].text) - } - account_res.value = account_text - account_res.innerHTML=account_res.value; - } - } - if (account_list.length == 0){ - account_res.value = "" - account_res.innerHTML=""; - - } - output.account_ids = account_ids - - - var journal_ids = []; - var journal_text = []; - var journal_res = document.getElementById("journal_res") - var journal_list = $(".journal").select2('data') - for (var i = 0; i < journal_list.length; i++) { - if(journal_list[i].element[0].selected === true){ - - journal_ids.push(parseInt(journal_list[i].id)) - if(journal_text.includes(journal_list[i].text) === false){ - journal_text.push(journal_list[i].text) - } - journal_res.value = journal_text - journal_res.innerHTML=journal_res.value; - } - } - if (journal_list.length == 0){ - journal_res.value = "" - journal_res.innerHTML=""; - - } - output.journal_ids = journal_ids - - - var account_tag_ids = []; - var account_tag_text = []; - var account_tag_res = document.getElementById("acc_tag_res") - var account_tag_list = $(".account-tag").select2('data') - for (var i = 0; i < account_tag_list.length; i++) { - if(account_tag_list[i].element[0].selected === true){ - - account_tag_ids.push(parseInt(account_tag_list[i].id)) - if(account_tag_text.includes(account_tag_list[i].text) === false){ - account_tag_text.push(account_tag_list[i].text) - } - account_tag_res.value = account_tag_text - account_tag_res.innerHTML=account_tag_res.value; - } - } - if (account_tag_list.length == 0){ - account_tag_res.value = "" - account_tag_res.innerHTML=""; - - } - output.account_tag_ids = account_tag_ids - - - - var analytic_ids = []; - var analytic_text = []; - var span_res = document.getElementById("analic_res") - var analytic_list = $(".analytic").select2('data') - for (var i = 0; i < analytic_list.length; i++) { - if(analytic_list[i].element[0].selected === true){ - - analytic_ids.push(parseInt(analytic_list[i].id)) - if(analytic_text.includes(analytic_list[i].text) === false){ - analytic_text.push(analytic_list[i].text) - } - span_res.value = analytic_text - span_res.innerHTML=span_res.value; - } - } - if (analytic_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; - - } - output.analytic_ids = analytic_ids - - output.analytic_tag_ids = analytic_tag_ids - - var analytic_tag_ids = []; - var analytic_tag_text = []; - var analytic_tag_res = document.getElementById("analic_tag_res") - var analytic_tag_list = $(".analytic-tag").select2('data') - for (var i = 0; i < analytic_tag_list.length; i++) { - if(analytic_tag_list[i].element[0].selected === true){ - - analytic_tag_ids.push(parseInt(analytic_tag_list[i].id)) - if(analytic_tag_text.includes(analytic_tag_list[i].text) === false){ - analytic_tag_text.push(analytic_tag_list[i].text) - } - analytic_tag_res.value = analytic_tag_text - analytic_tag_res.innerHTML=analytic_tag_res.value; - } - } - if (analytic_tag_list.length == 0){ - analytic_tag_res.value = "" - analytic_tag_res.innerHTML=""; - - } - output.analytic_tag_ids = analytic_tag_ids - - - - - if ($("#date_from").val()) { - var dateObject = $("#date_from").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_from = dateString; - } - if ($("#date_to").val()) { - var dateObject = $("#date_to").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_to = dateString; - } - - if ($(".entries").length) { - var post_res = document.getElementById("post_res") - output.entries = $(".entries")[1].value - post_res.value = $(".entries")[1].value - post_res.innerHTML=post_res.value; - if ($(".entries")[1].value == "") { - post_res.innerHTML="all"; - - } - } - output.include_details = true; - rpc.query({ - model: 'dynamic.general.ledger', - method: 'write', - args: [ - [self.wizard], output - ], - }).then(function(res) { - self.ledger_view(self.initial_render); - }); - }, - - print_pdf: function(e) { - e.preventDefault(); - var self = this; - self._rpc({ - model: 'dynamic.general.ledger', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - var action = { - 'type': 'ir.actions.report', - 'report_type': 'qweb-pdf', - 'report_name': 'dynamic_financial_report.general_ledger', - 'report_file': 'dynamic_financial_report.general_ledger', - 'data': { - 'report_data': data - }, - 'context': { - 'active_model': 'dynamic.general.ledger', - 'landscape': 1, - 'js_report': true - }, - 'display_name': 'General Ledger', - }; - return self.do_action(action); - }); - }, - print_xlsx: function() { - var self = this; - self._rpc({ - model: 'dynamic.general.ledger', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - var action = { - 'type': 'ir_actions_xlsx_download', - 'data': { - 'model': 'dynamic.general.ledger', - 'options': JSON.stringify(data[1]), - 'output_format': 'xlsx', - 'report_data': JSON.stringify(data[0]), - 'report_name': 'General Ledger', - 'dfr_data': JSON.stringify(data), - }, - }; - return self.do_action(action); - }); - }, - - ledger_view: function(initial_render = true) { - var self = this; - var node = self.$('.container-gl-main'); - var last; - while (last = node.lastChild) node.removeChild(last); - rpc.query({ - model: 'dynamic.general.ledger', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(datas) { - self.filter_data = datas[0] - - self.account_data = datas[1] - - _.each(self.account_data, function(account) { - var currency_format = { - currency_id: account.company_currency_id, - position: account.company_currency_position, - symbol: account.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = currency_format.symbol + ' ' + account.debit.toFixed(2) + ' '; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = currency_format.symbol + ' ' + account.credit.toFixed(2) + ' '; - - } - if (account.balance == 0) { - account.balance = ' - ' - - } else { - account.balance = currency_format.symbol + ' ' + account.balance.toFixed(2) + ' '; - - } - } else { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = account.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = account.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.balance == 0) { - account.balance = ' - ' - } else { - account.balance = account.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - } - }); - if (initial_render) { - self.$('.gl-filter').html(QWeb.render('FilterSection', { - filter_data: datas[0], - })); - - self.$el.find('.journal').select2({ - placeholder: 'Select Journal...', - }); - self.$el.find('.account').select2({ - placeholder: 'Select Account...', - }); - self.$el.find('.account-tag').select2({ - placeholder: 'Select Account Tag...', - }); - self.$el.find('.analytic-tag').select2({ - placeholder: 'Select Analytic Tag...', - }); - self.$el.find('.analytic').select2({ - placeholder: 'Select Analytic...', - }); - - self.$el.find('#date_from').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('#date_to').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('.entries').select2({ - placeholder: 'Select Moves', - }); - } - self.$('.container-gl-main').html(QWeb.render('GeneralLedgerData', { - account_data: datas[1] - })); - }); - }, - gl_lines_by_page: function(offset, account_id) { - var self = this; - return rpc.query({ - model: 'dynamic.general.ledger', - method: 'gl_move_lines', - args: [self.wizard, offset, account_id], - }) - }, - get_move_lines: function(event) { - event.preventDefault(); - var self = this; - var account_id = $(event.currentTarget).data('account-id'); - var offset = 0; - var td = $(event.currentTarget).next('tr').find('td'); - if (td.length == 1) { - self.gl_lines_by_page(offset, account_id).then(function(datas) { - _.each(datas[2], function(data) { - var currency_format = { - currency_id: data.company_currency_id, - position: data.company_currency_position, - symbol: data.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = currency_format.symbol + ' ' + data.debit.toFixed(2) + ' '; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = currency_format.symbol + ' ' + data.credit.toFixed(2) + ' '; - - } - if (data.balance == 0) { - data.balance = ' - ' - - } else { - data.balance = currency_format.symbol + ' ' + data.balance.toFixed(2) + ' '; - - } - } else { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = data.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = data.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.balance == 0) { - data.balance = ' - ' - } else { - data.balance = data.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - - } - - - }); - $(event.currentTarget).next('tr').find('td .gl-table-div').remove(); - $(event.currentTarget).next('tr').find('td ul').after( - QWeb.render('SubSection', { - count: datas[0], - offset: datas[1], - account_data: datas[2], - })) - $(event.currentTarget).next('tr').find('td ul li:first a').css({ - 'background-color': '#00ede8', - 'font-weight': 'bold', - }); - }) - } - }, - view_move: function(event) { - event.preventDefault(); - var self = this; - var context = {}; - var redirect_to_document = function(res_model, res_id, view_id) { - var action = { - type: 'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: res_model, - views: [ - [view_id || false, 'form'] - ], - res_id: res_id, - target: 'current', - context: context, - }; - return self.do_action(action); - }; - rpc.query({ - model: 'account.move', - method: 'search_read', - domain: [ - ['id', '=', $(event.currentTarget).data('move-id')] - ], - fields: ['id'], - limit: 1, - }) - .then(function(record) { - if (record.length > 0) { - redirect_to_document('account.move', record[0].id); - } else { - redirect_to_document('account.move', $(event.currentTarget).data('move-id')); - } - }); - }, - - }); - - var TrialBalance = AbstractAction.extend({ - template: 'TrialBalance', - events: { - 'click #filter_apply_button': 'apply_filter', - 'click .open-gl': 'get_gl', - 'click #pdf': 'print_pdf', - 'click #xlsx': 'print_xlsx', - }, - init: function(view, code) { - this._super(view, code); - this.wizard = code.context.wizard | null; - this.session = session; - }, - start: function() { - var self = this; - self.initial_render = true; - rpc.query({ - model: 'dynamic.trial.balance', - method: 'create', - args: [{ - - }] - }).then(function(res) { - self.wizard = res; - self.ledger_view(self.initial_render); - }) - }, - apply_filter: function(event) { - event.preventDefault(); - var self = this; - - self.initial_render = false; - var output = {}; - var account_ids = []; - var journal_ids = []; - var journal_text = []; - var journal_res = document.getElementById("journal_res") - var journal_list = $(".journal").select2('data') - for (var i = 0; i < journal_list.length; i++) { - if(journal_list[i].element[0].selected === true){ - - journal_ids.push(parseInt(journal_list[i].id)) - if(journal_text.includes(journal_list[i].text) === false){ - journal_text.push(journal_list[i].text) - } - journal_res.value = journal_text - journal_res.innerHTML=journal_res.value; - } - } - if (journal_list.length == 0){ - journal_res.value = "" - journal_res.innerHTML=""; - - } - output.journal_ids = journal_ids - - - - var analytic_ids = []; - var analytic_text = []; - var span_res = document.getElementById("analic_res") - var analytic_list = $(".analytic").select2('data') - for (var i = 0; i < analytic_list.length; i++) { - if(analytic_list[i].element[0].selected === true){ - - analytic_ids.push(parseInt(analytic_list[i].id)) - if(analytic_text.includes(analytic_list[i].text) === false){ - analytic_text.push(analytic_list[i].text) - } - span_res.value = analytic_text - span_res.innerHTML=span_res.value; - } - } - if (analytic_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; - - } - output.analytic_ids = analytic_ids - - - if ($("#date_from").val()) { - var dateObject = $("#date_from").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_from = dateString; - } - if ($("#date_to").val()) { - var dateObject = $("#date_to").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_to = dateString; - } - - if ($(".entries").length) { - var post_res = document.getElementById("post_res") - output.entries = $(".entries")[1].value - post_res.value = $(".entries")[1].value - post_res.innerHTML=post_res.value; - if ($(".entries")[1].value == "") { - post_res.innerHTML="all"; - output.entries = "all" - - } - } - output.include_details = true; - - rpc.query({ - model: 'dynamic.trial.balance', - method: 'write', - args: [ - self.wizard, output - ], - }).then(function(res) { - self.ledger_view(self.initial_render); - }); - - var dropDown = document.getElementById("entries"); - dropDown.value = ""; - - }, - - get_gl: function(e) { - var self = this; - var account_id = $(e.target).attr('data-account-id'); - var options = { - account_ids: [account_id], - } - - var action = { - type: 'ir.actions.client', - name: 'GL View', - tag: 'dynamic.gl', - target: 'new', - - domain: [['account_ids','=', account_id]], - - - } - return this.do_action(action); - - }, - - print_pdf: function(e) { - e.preventDefault(); - var self = this; - self._rpc({ - model: 'dynamic.trial.balance', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - var action = { - 'type': 'ir.actions.report', - 'report_type': 'qweb-pdf', - 'report_name': 'dynamic_financial_report.trial_balance', - 'report_file': 'dynamic_financial_report.trial_balance', - 'data': { - 'report_data': data - }, - 'context': { - 'active_model': 'dynamic.trial.balance', - 'landscape': 1, - 'js_report': true - }, - 'display_name': 'Trial Balance', - }; - return self.do_action(action); - }); - }, - - print_xlsx: function() { - var self = this; - self._rpc({ - model: 'dynamic.trial.balance', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - var action = { - 'type': 'ir_actions_xlsx_download', - 'data': { - 'model': 'dynamic.trial.balance', - 'options': JSON.stringify(data[1]), - 'output_format': 'xlsx', - 'report_data': JSON.stringify({"d1":JSON.stringify(data[2]) , "d2":JSON.stringify(data[0])}) , - 'report_name': 'Trial Balance', - 'dfr_data': JSON.stringify(data), - }, - }; - return self.do_action(action); - }); - }, - - ledger_view: function(initial_render = true) { - var self = this; - var node = self.$('.container-tb-main'); - var last; - while (last = node.lastChild) node.removeChild(last); - rpc.query({ - model: 'dynamic.trial.balance', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(datas) { - self.filter_data = datas[0] - self.account_data = datas[1] - if (datas[2].currency_details.length > 0){ - - var currency_format = { - currency_id: datas[2].currency_details[0].currency, - position: datas[2].currency_details[0].position, - symbol: datas[2].currency_details[0].symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - if (datas[2].debit == 0) { - datas[2].debit = ' - ' - } else { - datas[2].debit = currency_format.symbol + datas[2].debit.toFixed(2) ; - - } - if (datas[2].credit == 0) { - datas[2].credit = ' - ' - } else { - datas[2].credit = currency_format.symbol + datas[2].credit.toFixed(2) ; - - } - - }else{ - - if (datas[2].debit == 0) { - datas[2].debit = ' - ' - } else { - datas[2].debit = datas[2].debit.toFixed(2) + currency_id.symbol; - - } - if (datas[2].credit == 0) { - datas[2].credit = ' - ' - } else { - datas[2].credit = datas[2].credit.toFixed(2) + currency_id.symbol; - - } - - - } - - - } - - _.each(self.account_data, function(account) { - var currency_format = { - currency_id: account.company_currency_id, - position: account.company_currency_position, - symbol: account.company_currency_symbol, - noSymbol: true, - }; - for (var i = 0; i < account.lines.length; i++) { - if (account.lines[i].initial_bal == true){ - if (currency_format.position == "before") { - if (account.lines[i].debit == 0) { - account.lines[i].debit = ' - ' - } else { - account.lines[i].debit = currency_format.symbol + ' ' + account.lines[i].debit .toFixed(2) + ' '; - - } - if (account.lines[i].credit == 0) { - account.lines[i].credit = ' - ' - } else { - account.lines[i].credit = currency_format.symbol + ' ' + account.lines[i].credit .toFixed(2) + ' '; - - } - - }else{ - - if (account.lines[i].debit == 0) { - account.lines[i].debit = ' - ' - } else { - account.lines[i].debit = account.lines[i].debit.toFixed(2) + ' ' + currency_format.symbol; - - } - if (account.lines[i].credit == 0) { - account.lines[i].credit = ' - ' - } else { - account.lines[i].credit = account.lines[i].credit.toFixed(2) + ' ' + currency_format.symbol; - - } - - - } - - - } - } - if (currency_format.position == "before") { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = currency_format.symbol + ' ' + account.debit.toFixed(2) + ' '; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = currency_format.symbol + ' ' + account.credit.toFixed(2) + ' '; - - } - if (account.balance == 0) { - account.balance = ' - ' - - } else { - account.balance = currency_format.symbol + ' ' + account.balance.toFixed(2) + ' '; - - } - } else { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = account.debit.toFixed(2) + ' ' + currency_format.symbol; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = account.credit.toFixed(2) + ' ' + currency_format.symbol; - - } - if (account.balance == 0) { - account.balance = ' - ' - } else { - account.balance = account.balance.toFixed(2) + ' ' + currency_format.symbol; - - } - } - }); - if (initial_render) { - self.$('.tb-filter').html(QWeb.render('FilterSectionTB', { - filter_data: datas[0], - })); - - self.$el.find('.journal').select2({ - placeholder: 'Select Journal...', - }); - - self.$el.find('.analytic').select2({ - placeholder: 'Select Analytic...', - }); - self.$el.find('.entries').select2({ - placeholder: 'Select Moves', - }).val('all').trigger('change'); - - self.$el.find('#date_from').datepicker({ - dateFormat: 'dd-mm-yy' - }); - - self.$el.find('#date_to').datepicker({ - dateFormat: 'dd-mm-yy' - }); - } - self.$('.container-tb-main').html(QWeb.render('TrialBalanceData', { - - account_data: datas[1], - filter : datas[0], - total_b : datas[2], - })); - }); - }, - - }); - - core.action_registry.add('dynamic.gl', GeneralLedger); - core.action_registry.add('dynamic.tb', TrialBalance); - -}); \ No newline at end of file diff --git a/dynamic_financial_report/static/src/js/partner_ledger.js b/dynamic_financial_report/static/src/js/partner_ledger.js deleted file mode 100644 index 4e317d6ac..000000000 --- a/dynamic_financial_report/static/src/js/partner_ledger.js +++ /dev/null @@ -1,476 +0,0 @@ -odoo.define('dynamic_financial_report.partner_ledger', function(require) { - 'use strict'; - var AbstractAction = require('web.AbstractAction'); - var core = require('web.core'); - var field_utils = require('web.field_utils'); - var rpc = require('web.rpc'); - var session = require('web.session'); - var utils = require('web.utils'); - var QWeb = core.qweb; - var _t = core._t; - - var PartnerLedger = AbstractAction.extend({ - template: 'PartnerLedger', - events: { - 'click .pl-line': 'get_move_lines', - 'click .view-move': 'view_move', - 'click #filter_apply_button': 'apply_filter', - 'click #pdf': 'print_pdf', - 'click #xlsx': 'print_xlsx', - }, - init: function(view, code) { - this._super(view, code); - this.wizard = code.context.wizard | null; - this.session = session; - }, - start: function() { - var self = this; - self.initial_render = true; - rpc.query({ - model: 'dynamic.partner.ledger', - method: 'create', - args: [{ - res_model: this.res_model - }] - }).then(function(res) { - self.wizard = res; - self.ledger_view(self.initial_render); - }) - }, - apply_filter: function(event) { - event.preventDefault(); - var self = this; - - self.initial_render = false; - var output = {}; - output.reconciled=false; - output.type=false; - output.date_from=false; - output.date_to=false; - var journal_ids = []; - var journal_text = []; - var span_res = document.getElementById("journal_res") - var journal_list = $(".journal").select2('data') - for (var i = 0; i < journal_list.length; i++) { - if(journal_list[i].element[0].selected === true){ journal_ids.push(parseInt(journal_list[i].id)) - if(journal_text.includes(journal_list[i].text) === false){ - journal_text.push(journal_list[i].text) - } - span_res.value = journal_text - span_res.innerHTML=span_res.value; - } - } - if (journal_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; } - output.journal_ids = journal_ids - - - var partner_ids = []; - var partner_text = []; - var span_res = document.getElementById("partner_res") - var partner_list = $(".partner").select2('data') - for (var i = 0; i < partner_list.length; i++) { - if(partner_list[i].element[0].selected === true) - {partner_ids.push(parseInt(partner_list[i].id)) - if(partner_text.includes(partner_list[i].text) === false) - {partner_text.push(partner_list[i].text) - } - span_res.value = partner_text - span_res.innerHTML=span_res.value; - } - } - if (partner_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; } - output.partner_ids = partner_ids - - - var account_ids = []; - var account_text = []; - var span_res = document.getElementById("account_res") - var account_list = $(".account").select2('data') - for (var i = 0; i < account_list.length; i++) { - if(account_list[i].element[0].selected === true) - {account_ids.push(parseInt(account_list[i].id)) - if(account_text.includes(account_list[i].text) === false) - {account_text.push(account_list[i].text) - } - span_res.value = account_text - span_res.innerHTML=span_res.value; - } - } - if (account_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; } - output.account_ids = account_ids - - - var partner_category_ids = []; - var partner_category_text = []; - var span_res = document.getElementById("category_res") - var category_list = $(".category").select2('data') - for (var i = 0; i < category_list.length; i++) { - if(category_list[i].element[0].selected === true) - {partner_category_ids.push(parseInt(category_list[i].id)) - if(partner_category_text.includes(category_list[i].text) === false) - {partner_category_text.push(category_list[i].text) - } - span_res.value = partner_category_text - span_res.innerHTML=span_res.value; - } - } - if (category_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; } - output.partner_category_ids = partner_category_ids - - - - - if ($(".reconcile").length){ - var reconciled_res = document.getElementById("reconciled_res") - output.reconciled = $(".reconcile")[1].value - reconciled_res.value = $(".reconcile")[1].value - reconciled_res.innerHTML=reconciled_res.value; - if ($(".reconcile").value==""){ - reconciled_res.innerHTML="unreconciled"; - output.reconciled = "unreconciled" - } - } - - - if ($(".type").length){ - var type_res = document.getElementById("type_res") - output.type = $(".type")[1].value - type_res.value = $(".type")[1].value - type_res.innerHTML=type_res.value; - if ($(".type").value==""){ - type_res.innerHTML="receivable"; - output.type = "Receivable" - } - } - - if ($(".target-moves").length){ - var target_res = document.getElementById("target_res") - output.target_moves = $(".target-moves")[1].value - target_res.value = $(".target-moves")[1].value - target_res.innerHTML=target_res.value; - if ($(".target-moves").value==""){ - target_res.innerHTML="all_entries"; - output.target_moves = "all_entries" - } - } - - - - if ($("#date_from").val()) { - var dateObject = $("#date_from").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_from = dateString; - } - if ($("#date_to").val()) { - var dateObject = $("#date_to").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_to = dateString; - } - output.include_details = true; - - rpc.query({ - model: 'dynamic.partner.ledger', - method: 'write', - args: [ - [self.wizard], output - ], - }).then(function(res) { - self.ledger_view(self.initial_render); - }); - }, - - print_pdf: function(e) { - e.preventDefault(); - var self = this; - self._rpc({ - model: 'dynamic.partner.ledger', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - var action = { - 'type': 'ir.actions.report', - 'report_type': 'qweb-pdf', - 'report_name': 'dynamic_financial_report.partner_ledger', - 'report_file': 'dynamic_financial_report.partner_ledger', - 'data': { - 'report_data': data - }, - 'context': { - 'active_model': 'dynamic.partner.ledger', - 'landscape': 1, - 'js_report': true - }, - 'display_name': 'Partner Ledger', - }; - return self.do_action(action); - }); - }, - print_xlsx: function() { - var self = this; - self._rpc({ - model: 'dynamic.partner.ledger', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(data) { - var action = { - 'type': 'ir_actions_xlsx_download', - 'data': { - 'model': 'dynamic.partner.ledger', - 'options': JSON.stringify(data[1]), - 'output_format': 'xlsx', - 'report_data': JSON.stringify(data[0]), - 'report_name': 'Partner Ledger', - 'dfr_data': JSON.stringify(data), - }, - - }; - - return self.do_action(action); - }); - }, - - ledger_view: function(initial_render = true) { - var self = this; - var node = self.$('.container-pl-main'); - var last; - while (last = node.lastChild) node.removeChild(last); - rpc.query({ - model: 'dynamic.partner.ledger', - method: 'get_data', - args: [ - [self.wizard] - ], - }).then(function(datas) { - self.filter_data = datas[0] - self.account_data = datas[1] - - _.each(self.account_data, function(account) { - var currency_format = { - currency_id: account.company_currency_id, - position: account.company_currency_position, - symbol: account.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = currency_format.symbol + ' ' + account.debit.toFixed(2) + ' '; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = currency_format.symbol + ' ' + account.credit.toFixed(2) + ' '; - - } - if (account.balance == 0) { - account.balance = ' - ' - - } else { - account.balance = currency_format.symbol + ' ' + account.balance.toFixed(2) + ' '; - - } - } else { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = account.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = account.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.balance == 0) { - account.balance = ' - ' - } else { - account.balance = account.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - } - }); - if (initial_render) { - self.$('.pl-filter').html(QWeb.render('FilterSectionPl', { - filter_data: datas[0], - })); - - self.$el.find('.journal').select2({ - placeholder: 'Select Journal...', - }); - self.$el.find('.account').select2({ - placeholder: 'Select Account...', - }); - self.$el.find('.partner').select2({ - placeholder: 'Select Partner...', - }); - self.$el.find('.reconcile').select2({ - placeholder: 'Select Reconciled status...', - }); - self.$el.find('.target-moves').select2({ - placeholder: 'Posted or All Entries...', - }); - self.$el.find('.type').select2({ - placeholder: 'Select Account...', - }); - self.$el.find('.category').select2({ - placeholder: 'Select Category...', - }); - self.$el.find('#date_from').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('#date_to').datepicker({ - dateFormat: 'dd-mm-yy' - }); - } - - self.$('.container-pl-main').html(QWeb.render('PartnerLedgerData', { - account_data: datas[1] - })); - - }); - }, - pl_lines_by_page: function(offset, account_id) { - var self = this; - return rpc.query({ - model: 'dynamic.partner.ledger', - method: 'pl_move_lines', - args: [self.wizard, offset, account_id], - }) - }, - get_move_lines: function(event) { - event.preventDefault(); - var self = this; - var account_id = $(event.currentTarget).data('account-id'); - var offset = 0; - var td = $(event.currentTarget).next('tr').find('td'); - if (td.length == 1) { - self.pl_lines_by_page(offset, account_id).then(function(datas) { - _.each(datas[2], function(data) { - var currency_format = { - currency_id: data.company_currency_id, - position: data.company_currency_position, - symbol: data.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = currency_format.symbol + ' ' + data.debit.toFixed(2) + ' '; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = currency_format.symbol + ' ' + data.credit.toFixed(2) + ' '; - - } - if (data.balance == 0) { - data.balance = ' - ' - - } else { - data.balance = currency_format.symbol + ' ' + data.balance.toFixed(2) + ' '; - - } - } else { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = data.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = data.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.balance == 0) { - data.balance = ' - ' - } else { - data.balance = data.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - - } - - - }); - $(event.currentTarget).next('tr').find('td .pl-table-div').remove(); - $(event.currentTarget).next('tr').find('td ul').after( - QWeb.render('SubSectionPl', { - count: datas[0], - offset: datas[1], - account_data: datas[2], - })) - $(event.currentTarget).next('tr').find('td ul li:first a').css({ - 'background-color': '#00ede8', - 'font-weight': 'bold', - }); - }) - } - }, - view_move: function(event) { - event.preventDefault(); - var self = this; - var context = {}; - var redirect_to_document = function(res_model, res_id, view_id) { - - var action = { - type: 'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: res_model, - views: [ - [view_id || false, 'form'] - ], - res_id: res_id, - target: 'current', - context: context, - }; - return self.do_action(action); - }; - rpc.query({ - model: 'account.move', - method: 'search_read', - domain: [ - ['id', '=', $(event.currentTarget).data('move-id')] - ], - fields: ['id'], - limit: 1, - }) - .then(function(record) { - if (record.length > 0) { - redirect_to_document('account.move', record[0].id); - } else { - redirect_to_document('account.move', $(event.currentTarget).data('move-id')); - } - }); - }, - - }); - - core.action_registry.add('dynamic.pl', PartnerLedger); - -}); \ No newline at end of file diff --git a/dynamic_financial_report/static/src/js/profit_loss.js b/dynamic_financial_report/static/src/js/profit_loss.js deleted file mode 100644 index 3f6cbbd40..000000000 --- a/dynamic_financial_report/static/src/js/profit_loss.js +++ /dev/null @@ -1,526 +0,0 @@ -odoo.define('dynamic_financial_report.profit_loss', function(require) { - 'use strict'; - var AbstractAction = require('web.AbstractAction'); - var core = require('web.core'); - var field_utils = require('web.field_utils'); - var rpc = require('web.rpc'); - var session = require('web.session'); - var utils = require('web.utils'); - var QWeb = core.qweb; - var _t = core._t; - - var ProfitAndLoss = AbstractAction.extend({ - template: 'ProfitAndLoss', - events: { - 'click .pal-line': 'get_move_lines', - 'click .view-move': 'view_move', - 'click #filter_apply_button': 'apply_filter', - 'click #pdf': 'print_pdf', - 'click #xlsx': 'print_xlsx', - 'click .open-gl': 'get_gl', - }, - init: function(view, code) { - this._super(view, code); - this.wizard = code.context.wizard | null; - this.session = session; - }, - start: function() { - var self = this; - self.initial_render = true; - rpc.query({ - model: 'dynamic.balance.sheet', - method: 'create', - args: [{ - - }] - }).then(function(res) { - self.wizard = res; - self.sheet_view(self.initial_render); - }) - }, - apply_filter: function(event) { - - event.preventDefault(); - var self = this; - - self.initial_render = false; - var output = {}; - - - var account_ids = []; - var account_text = []; - var account_res = document.getElementById("acc_res") - var account_list = $(".account").select2('data') - for (var i = 0; i < account_list.length; i++) { - - if(account_list[i].element[0].selected === true){ - - account_ids.push(parseInt(account_list[i].id)) - if(account_text.includes(account_list[i].text) === false){ - account_text.push(account_list[i].text) - - } - account_res.value = account_text - account_res.innerHTML=account_res.value; - } - } - if (account_list.length == 0){ - account_res.value = "" - account_res.innerHTML=""; - - } - output.account_ids = account_ids - - - var journal_ids = []; - var journal_text = []; - var journal_res = document.getElementById("journal_res") - var journal_list = $(".journal").select2('data') - for (var i = 0; i < journal_list.length; i++) { - - if(journal_list[i].element[0].selected === true){ - - journal_ids.push(parseInt(journal_list[i].id)) - if(journal_text.includes(journal_list[i].text) === false){ - journal_text.push(journal_list[i].text) - - } - - journal_res.value = journal_text - journal_res.innerHTML=journal_res.value; - } - } - if (journal_list.length == 0){ - journal_res.value = "" - journal_res.innerHTML=""; - - } - output.journal_ids = journal_ids - - - var account_tag_ids = []; - var account_tag_text = []; - var account_tag_res = document.getElementById("acc_tag_res") - var account_tag_list = $(".account-tag").select2('data') - for (var i = 0; i < account_tag_list.length; i++) { - if(account_tag_list[i].element[0].selected === true){ - - account_tag_ids.push(parseInt(account_tag_list[i].id)) - if(account_tag_text.includes(account_tag_list[i].text) === false){ - account_tag_text.push(account_tag_list[i].text) - } - - account_tag_res.value = account_tag_text - account_tag_res.innerHTML=account_tag_res.value; - } - } - if (account_tag_list.length == 0){ - account_tag_res.value = "" - account_tag_res.innerHTML=""; - - } - output.account_tag_ids = account_tag_ids - - - - var analytic_ids = []; - var analytic_text = []; - var span_res = document.getElementById("analic_res") - var analytic_list = $(".analytic").select2('data') - for (var i = 0; i < analytic_list.length; i++) { - if(analytic_list[i].element[0].selected === true){ - - analytic_ids.push(parseInt(analytic_list[i].id)) - if(analytic_text.includes(analytic_list[i].text) === false){ - analytic_text.push(analytic_list[i].text) - - } - - span_res.value = analytic_text - span_res.innerHTML=span_res.value; - } - } - if (analytic_list.length == 0){ - span_res.value = "" - span_res.innerHTML=""; - - } - output.analytic_ids = analytic_ids - - output.analytic_tag_ids = analytic_tag_ids - - var analytic_tag_ids = []; - var analytic_tag_text = []; - var analytic_tag_res = document.getElementById("analic_tag_res") - var analytic_tag_list = $(".analytic-tag").select2('data') - for (var i = 0; i < analytic_tag_list.length; i++) { - if(analytic_tag_list[i].element[0].selected === true){ - - analytic_tag_ids.push(parseInt(analytic_tag_list[i].id)) - if(analytic_tag_text.includes(analytic_tag_list[i].text) === false){ - analytic_tag_text.push(analytic_tag_list[i].text) - - } - - analytic_tag_res.value = analytic_tag_text - analytic_tag_res.innerHTML=analytic_tag_res.value; - } - } - if (analytic_tag_list.length == 0){ - analytic_tag_res.value = "" - analytic_tag_res.innerHTML=""; - - } - output.analytic_tag_ids = analytic_tag_ids - - - - - if ($("#date_from").val()) { - var dateObject = $("#date_from").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_from = dateString; - } - if ($("#date_to").val()) { - var dateObject = $("#date_to").datepicker("getDate"); - var dateString = $.datepicker.formatDate("yy-mm-dd", dateObject); - output.date_to = dateString; - } - - if ($(".entries").length) { - var post_res = document.getElementById("post_res") - - output.entries = $(".entries")[1].value - post_res.value = $(".entries")[1].value - post_res.innerHTML=post_res.value; - if ($(".entries")[1].value == "") { - post_res.innerHTML="all"; - - } - } - - output.include_details = true; - - - rpc.query({ - model: 'dynamic.balance.sheet', - method: 'write', - args: [ - [self.wizard], output - ], - }).then(function(res) { - self.sheet_view(self.initial_render); - - }); - }, - - get_gl: function(e) { - var self = this; - var account_id = $(e.target).attr('data-account-id'); - var options = { - account_ids: [account_id], - } - var action = { - type: 'ir.actions.client', - name: 'GL View', - tag: 'dynamic.gl', - target: 'new', - - domain: [['account_ids','=', account_id]], - - - } - return this.do_action(action); - - }, - - print_pdf: function(e) { - e.preventDefault(); - var self = this; - var action_title = self._title - self._rpc({ - model: 'dynamic.balance.sheet', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(data) { - - var action = { - 'type': 'ir.actions.report', - 'report_type': 'qweb-pdf', - 'report_name': 'dynamic_financial_report.balance_sheet', - 'report_file': 'dynamic_financial_report.balance_sheet', - 'data': { - 'report_data': data, - 'report_name': 'Profit and Loss' - }, - 'context': { - 'active_model': 'dynamic.balance.sheet', - 'landscape': 1, - 'js_report': true - }, - 'display_name': 'Profit and Loss', - }; - return self.do_action(action); - }); - }, - print_xlsx: function() { - var self = this; - var action_title = self._title - self._rpc({ - model: 'dynamic.balance.sheet', - method: 'get_data', - args: [ - [self.wizard],action_title - ], - }).then(function(data) { - - var action = { - 'type': 'ir_actions_xlsx_download', - 'data': { - 'model': 'dynamic.balance.sheet', - 'options': 'Profit and Loss', - 'output_format': 'xlsx', - 'report_data': JSON.stringify(data[0]), - 'report_name': 'Profit and Loss', - 'dfr_data':JSON.stringify(data[2]), - }, - }; - - return self.do_action(action); - }); - }, - - - sheet_view: function(initial_render = true) { - var self = this; - var action_title = self._title - var node = self.$('.container-pal-main'); - var last; - while (last = node.lastChild) node.removeChild(last); - rpc.query({ - model: 'dynamic.balance.sheet', - method: 'get_data', - args: [ - [self.wizard], action_title - ], - }).then(function(datas) { - self.filter_data = datas[0] - - self.account_data = datas[1] - - _.each(self.account_data, function(account) { - var currency_format = { - currency_id: account.company_currency_id, - position: account.company_currency_position, - symbol: account.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = currency_format.symbol + ' ' + account.debit.toFixed(2) + ' '; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = currency_format.symbol + ' ' + account.credit.toFixed(2) + ' '; - - } - if (account.balance == 0) { - account.balance = ' - ' - - } else { - account.balance = currency_format.symbol + ' ' + account.balance.toFixed(2) + ' '; - - } - } else { - - if (account.debit == 0) { - account.debit = ' - ' - } else { - account.debit = account.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.credit == 0) { - account.credit = ' - ' - - } else { - account.credit = account.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (account.balance == 0) { - account.balance = ' - ' - } else { - account.balance = account.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - } - }); - - if (initial_render) { - self.$('.pal-filter').html(QWeb.render('FilterSectionPAL', { - filter_data: datas[0], - })); - - self.$el.find('.journal').select2({ - placeholder: 'Select Journal...', - }); - self.$el.find('.account').select2({ - placeholder: 'Select Account...', - }); - self.$el.find('.account-tag').select2({ - placeholder: 'Select Account Tag...', - }); - self.$el.find('.analytic-tag').select2({ - placeholder: 'Select Analytic Tag...', - }); - self.$el.find('.analytic').select2({ - placeholder: 'Select Analytic...', - }); - - self.$el.find('#date_from').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('#date_to').datepicker({ - dateFormat: 'dd-mm-yy' - }); - self.$el.find('.entries').select2({ - placeholder: 'Select Moves', - }); - } - self.$('.container-pal-main').html(QWeb.render('ProfitAndLossData', { - account_data: datas[1], - report_lines: datas[2] - })); - }); - }, - pal_lines_by_page: function(offset, account_id) { - var self = this; - return rpc.query({ - model: 'dynamic.balance.sheet', - method: 'bs_move_lines', - args: [self.wizard, offset, account_id], - }) - }, - get_move_lines: function(event) { - event.preventDefault(); - var self = this; - var account_id = $(event.currentTarget).data('account-id'); - var offset = 0; - var td = $(event.currentTarget).next('tr').find('td'); - if (td.length == 1) { - self.pal_lines_by_page(offset, account_id).then(function(datas) { - _.each(datas[2], function(data) { - var currency_format = { - currency_id: data.company_currency_id, - position: data.company_currency_position, - symbol: data.company_currency_symbol, - noSymbol: true, - }; - if (currency_format.position == "before") { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = currency_format.symbol + ' ' + data.debit.toFixed(2) + ' '; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = currency_format.symbol + ' ' + data.credit.toFixed(2) + ' '; - - } - if (data.balance == 0) { - data.balance = ' - ' - - } else { - data.balance = currency_format.symbol + ' ' + data.balance.toFixed(2) + ' '; - - } - } else { - if (data.debit == 0) { - data.debit = ' - ' - } else { - data.debit = data.debit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.credit == 0) { - data.credit = ' - ' - - } else { - data.credit = data.credit.toFixed(2) + ' ' + currency_id.symbol; - - } - if (data.balance == 0) { - data.balance = ' - ' - } else { - data.balance = data.balance.toFixed(2) + ' ' + currency_id.symbol; - - } - - } - - - }); - $(event.currentTarget).next('tr').find('td .pal-table-div').remove(); - $(event.currentTarget).next('tr').find('td ul').after( - QWeb.render('SubSectionPAL', { - count: datas[0], - offset: datas[1], - account_data: datas[2], - })) - $(event.currentTarget).next('tr').find('td ul li:first a').css({ - 'background-color': '#00ede8', - 'font-weight': 'bold', - }); - }) - } - }, - view_move: function(event) { - event.preventDefault(); - var self = this; - var context = {}; - var redirect_to_document = function(res_model, res_id, view_id) { - var action = { - type: 'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: res_model, - views: [ - [view_id || false, 'form'] - ], - res_id: res_id, - target: 'current', - context: context, - }; - return self.do_action(action); - }; - rpc.query({ - model: 'account.move', - method: 'search_read', - domain: [ - ['id', '=', $(event.currentTarget).data('move-id')] - ], - fields: ['id'], - limit: 1, - }) - .then(function(record) { - if (record.length > 0) { - redirect_to_document('account.move', record[0].id); - } else { - redirect_to_document('account.move', $(event.currentTarget).data('move-id')); - } - }); - }, - - }); - core.action_registry.add('dynamic.pal', ProfitAndLoss); - -}); \ No newline at end of file diff --git a/dynamic_financial_report/static/src/scss/dynamic_common_style.scss b/dynamic_financial_report/static/src/scss/dynamic_common_style.scss deleted file mode 100644 index 3d8c62fe1..000000000 --- a/dynamic_financial_report/static/src/scss/dynamic_common_style.scss +++ /dev/null @@ -1,377 +0,0 @@ - -.gl-breadcrumb { - font-size: 18px; -} -.amt{ -text-align: right; - -} - -.amd{ -text-align: right; -width: 400px !important; - -} - -.py_cntrl_right{ - max-width: 50%; - max-height: 50px; - -} - -.gl-breadcrumb li { - display: inline-block; - max-width: 100%; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - vertical-align: top; -} - -.py-control-div { - display: flex; - justify-content: space-between; - min-height: 30px; -} - -.py-btn-primary{ - color: #FFFFFF; - background-color: #00A09D; - border-color: #00A09D; - border-radius: 0px; -} - -.py-btn-secondary{ - color: #FFFFFF; - background-color: #00A0AD; - border-color: #00A09D; - border-radius: 3px; -} - -.py-search-buttons{ - display: block; - margin: auto 0px; -} - -.py-search-btn-date, -.py-search-date-filter, -.py-search-journals, -.py-search-partners, -.py-search-entries, -.py-search-accounts, -.py-search-accounts-tag, -.py-search-analytics, -.py-search-analytic-tag, -.py-search-extra{ - white-space: nowrap; - display: inline-block; - cursor: pointer; - user-select: none; - position: relative; -} - -.dropdown-item{ - display: block; - width: 100%; - clear: both; - font-weight: 400; - color: rgb(102, 102, 102); - text-align: inherit; - white-space: nowrap; - background-color: transparent; - padding: 0.25rem 1.5rem; - border-width: 0px; - border-style: initial; - border-color: initial; - border-image: initial; - position: relative; -} - -.tl-breadcrumb { - font-size: 18px; -} - -.tl-breadcrumb li { - display: inline-block; - max-width: 100%; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - vertical-align: top; -} - -.py-search-btn-date, -.py-search-date-filter, -.py-search-journals, -.py-search-partners, -.py-search-accounts, -.py-search-entries, -.py-search-accounts-tag, -.py-search-analytics, -.py-search-analytic-tag, -.py-search-extra{ - white-space: nowrap; - display: inline-block; - cursor: pointer; - user-select: none; - position: relative; -} -.bs-section-first{ - padding: 5px; - padding-top: 5px; - padding-left: 15px; -} - -.bs-section{ - padding: 5px; - padding-top: 25px; - padding-left: 15px; -} - -.bs-sub-section{ - padding-top: 25px; -} -.pl-breadcrumb { - font-size: 18px; -} - -.pl-breadcrumb li { - display: inline-block; - max-width: 100%; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - vertical-align: top; -} - -.py-search-btn-date, -.py-search-date-filter, -.py-search-journals, -.py-search-partners, -.py-search-categories, -.py-search-reconciled, -.py-search-accounts, -.py-search-entries, -.py-search-accounts-tag, -.py-search-analytics, -.py-search-analytic-tag, -.py-search-extra{ - white-space: nowrap; - display: inline-block; - cursor: pointer; - user-select: none; - position: relative; -} - -.al-breadcrumb { - font-size: 18px; -} - -.al-breadcrumb li { - display: inline-block; - max-width: 100%; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - vertical-align: top; -} - -.py-search-btn-date, -.py-search-date-filter, -.py-search-journals, -.py-search-partners, -.py-search-accounts, -.py-search-partner-type, -.py-search-analytics, -.py-search-partner-tag, -.py-search-entries, -.py-search-extra{ - white-space: nowrap; - display: inline-block; - cursor: pointer; - user-select: none; - position: relative; -} - -.cf-breadcrumb { - font-size: 18px; -} - -.cf-breadcrumb li { - display: inline-block; - max-width: 100%; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - vertical-align: top; -} - -.py-search-btn-date, -.py-search-date-filter, -.py-search-journals, -.py-search-partners, -.py-search-categories, -.py-search-reconciled, -.py-search-accounts, -.py-search-accounts-tag, -.py-search-analytics, -.py-search-analytic-tag, -.py-search-extra{ - white-space: nowrap; - display: inline-block; - cursor: pointer; - user-select: none; - position: relative; -} - -.main { - border: 1px solid #efefef; - margin: 50px; - border-radius: 17px; - background: #fff; - padding: 2% 0 5%; -} - -.thead { - border-bottom: 2px solid #bfbfbf; - background: #e8e8e8; -} - -.thead tr { - height: 38px; - width: 100%; -} - -.thead tr th { - border-bottom: 1px solid #e6e6e6; - font-weight:bold; - font-size:15px; -} - -.header { - margin-bottom: 50px; - text-align: center; -} - -.child_col1 { - width: 8%; -} - -.parent-highlight { - background: #f5f5f5; -} - -.parent-line { - background-image: linear-gradient(to bottom, #fcfcfc, #dedede); - cursor: pointer; -} - -.parent-line:hover { - background-image: linear-gradient(to bottom, #fcfcfc, #cacaca); -} - -.child_col2 { - width: 10%; -} - -.child_col3 { - width: 10%; -} - -.child_col4 { - width: 10%; -} - -.categ td { - padding: 7px !important; -} - -.filter_options { - border-bottom: 1px solid; - border-radius: 10px; -} - -.entry_type { - margin: 20px; -} - -.report_header { - text-align: center; - border-bottom: 1px solid #efefef; -} - -.row_color { - background-color: #e4e4e4; -} - -.main_report { - border: 1px solid #efefef; - margin: 50px; - border-radius: 17px; - background: #fff; - padding: 2% 0 5%; -} - -.child-class td { - font-size: 12px !important; - cursor: pointer; -} - -.child-row { - border-bottom: 1px solid #cacaca; -} - -.child-row:hover { - background-color: #f5f5f5; -} - -.bs-breadcrumb { - font-size: 18px; -} - -.bs-breadcrumb li { - display: inline-block; - max-width: 100%; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - vertical-align: top; -} - -.pal-breadcrumb { - font-size: 18px; -} - -.pal-breadcrumb li { - display: inline-block; - max-width: 100%; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - vertical-align: top; -} -.db-breadcrumb { - font-size: 18px; -} - -.db-breadcrumb li { - display: inline-block; - max-width: 100%; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - vertical-align: top; -} - -.py-search-btn-date, -.py-search-date-filter, -.py-search-journals, -.py-search-entries, -.py-search-accounts, -.py-search-extra{ - white-space: nowrap; - display: inline-block; - cursor: pointer; - user-select: none; - position: relative; -} diff --git a/dynamic_financial_report/static/src/xml/al_views.xml b/dynamic_financial_report/static/src/xml/al_views.xml deleted file mode 100644 index 69a6a1d00..000000000 --- a/dynamic_financial_report/static/src/xml/al_views.xml +++ /dev/null @@ -1,292 +0,0 @@ - - -
-
-
-
-
-
-
-
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AccountNot Due0-2021-4041-6061-8081-100100+Total
- - - - - - - - - - - - - - - - - - - - -
- - -
-
-
- -
-
    -
  1. Partner Ageing
  2. -
-
-
-
-
- - -
-
-
-
- -
- - -
-
- - -Account Type: - - - -
-
- - -Partner Type: - - - -
-
- - -Partners: - - - -
-
- - -Partner Tag: - - - -
-
- - -Target Moves: - - - -
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Entry LabelDue DateJournalAccountNot Due0-2021-4041-6061-8081-100100+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- diff --git a/dynamic_financial_report/static/src/xml/bank_book_view.xml b/dynamic_financial_report/static/src/xml/bank_book_view.xml deleted file mode 100644 index 49c3fc0a1..000000000 --- a/dynamic_financial_report/static/src/xml/bank_book_view.xml +++ /dev/null @@ -1,282 +0,0 @@ - - - -
-
-
-
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AccountDebitCreditBalance
- - - - - - - - - - - - - - - - -
- -
-
-
- -
-
    -
  1. Bank Book
  2. -
-
-
-
-
- - -
-
-
-
- -
- - -
-
- - -Journals: - - - -
-
- - -Accounts: - - - -
-
- - -Account Tags: - - - -
-
- - -Analytic: - - - -
-
- - -Analytic Tags: - - - -
-
- - -Options: - - - -
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DateJRNLPartnerMoveEntry LabelDebitCreditBalance
- - - - - - - - - - - - - - - - - -
-
-
-
\ No newline at end of file diff --git a/dynamic_financial_report/static/src/xml/bs_template_views.xml b/dynamic_financial_report/static/src/xml/bs_template_views.xml deleted file mode 100644 index ab4d32fd3..000000000 --- a/dynamic_financial_report/static/src/xml/bs_template_views.xml +++ /dev/null @@ -1,246 +0,0 @@ - - - -
-
-
-
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DebitCreditBalance
- - - - - - -
- - -
- -
- - - - - -
- -
- - -
-
- -
-
    -
  1. Balance Sheet
  2. -
-
-
-
-
- - -
-
-
-
- -
- - -
-
- - -Journals: - - - -
-
- - -Accounts: - - - -
-
- - -Account Tags: - - - -
-
- - -Analytic: - - - -
-
- - -Analytic Tags: - - - -
-
- - -Options: - - - -
-
-
-
-
-
diff --git a/dynamic_financial_report/static/src/xml/cash_book_view.xml b/dynamic_financial_report/static/src/xml/cash_book_view.xml deleted file mode 100644 index b0b2b161c..000000000 --- a/dynamic_financial_report/static/src/xml/cash_book_view.xml +++ /dev/null @@ -1,282 +0,0 @@ - - - -
-
-
-
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AccountDebitCreditBalance
- - - - - - - - - - - - - - - - -
- -
-
-
- -
-
    -
  1. Cash Book
  2. -
-
-
-
-
- - -
-
-
-
- -
- - -
-
- - -Journals: - - - -
-
- - -Accounts: - - - -
-
- - -Account Tags: - - - -
-
- - -Analytic: - - - -
-
- - -Analytic Tags: - - - -
-
- - -Options: - - - -
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DateJRNLPartnerMoveEntry LabelDebitCreditBalance
- - - - - - - - - - - - - - - - - -
-
-
-
\ No newline at end of file diff --git a/dynamic_financial_report/static/src/xml/cash_flow.xml b/dynamic_financial_report/static/src/xml/cash_flow.xml deleted file mode 100644 index 2d1ffad25..000000000 --- a/dynamic_financial_report/static/src/xml/cash_flow.xml +++ /dev/null @@ -1,306 +0,0 @@ - - - -
-
-
-
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameCash InCash OutBalance
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
-
    - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameCash InCash OutBalance
- - - - - - - - - - - - - -
- - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
-
-
- - - - -
- -
  • Cash Flow Statement
  • -
    -
    -
    -
    -
    - - -
    -
    -
    -
    - -
    - - -
    -
    - - - -Target Moves: - - - -
    -
    - - -Level: - - - -
    - -
    -
    -
    -
    -
    diff --git a/dynamic_financial_report/static/src/xml/db_lines.xml b/dynamic_financial_report/static/src/xml/db_lines.xml deleted file mode 100644 index a8ac1387e..000000000 --- a/dynamic_financial_report/static/src/xml/db_lines.xml +++ /dev/null @@ -1,239 +0,0 @@ - - - -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    DateDebitCreditBalance
    - - - - - - - - - - -
    - -
    -
    -
    - -
    -
      -
    1. Day Book
    2. -
    -
    -
    -
    -
    - - -
    -
    -
    -
    - -
    - - -
    -
    - - - Journals: - - - -
    -
    - - - Accounts: - - - -
    -
    - - - Target Moves: - - -
    -
    -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    DateJRNLPartnerMoveEntry LabelDebitCreditBalance
    - - - - - - - - - - - - - - - - - -
    -
    -
    -
    \ No newline at end of file diff --git a/dynamic_financial_report/static/src/xml/partner_ledger_views.xml b/dynamic_financial_report/static/src/xml/partner_ledger_views.xml deleted file mode 100644 index f8fe2ed43..000000000 --- a/dynamic_financial_report/static/src/xml/partner_ledger_views.xml +++ /dev/null @@ -1,287 +0,0 @@ - - - -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    PartnerDebitCreditBalance
    - - - - - - - - - - -
    - -
    -
    -
    - -
    -
      -
    1. Partner Ledger
    2. -
    -
    -
    -
    -
    - - -
    -
    -
    -
    - -
    - - -
    - -
    - - -Journals: - - - -
    - -
    - - -Partners: - - - - -
    -
    - - -Reconciliation Status: - - - - -
    -
    - - -Acccount Type - - - - -
    -
    - - -Partner tag: - - - - -
    -
    - - -Accounts: - - - - - -
    -
    - - -Target Moves: - - - -
    -
    -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    DateJRNLAccountMoveEntry LabelDebitCreditBalance
    - - - - - - - () - - - - - - - - - - -
    -
    -
    -
    \ No newline at end of file diff --git a/dynamic_financial_report/static/src/xml/profit_loss_template_views.xml b/dynamic_financial_report/static/src/xml/profit_loss_template_views.xml deleted file mode 100644 index c940474e1..000000000 --- a/dynamic_financial_report/static/src/xml/profit_loss_template_views.xml +++ /dev/null @@ -1,246 +0,0 @@ - - - -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    DebitCreditBalance
    - - - - - - -
    - - -
    - -
    - - - - - -
    - -
    - - -
    -
    - -
    -
      -
    1. Profit and Loss Report
    2. -
    -
    -
    -
    -
    - - -
    -
    -
    -
    - -
    - - -
    -
    - - -Journals: - - - -
    -
    - - -Accounts: - - - -
    -
    - - -Account Tags: - - - -
    -
    - - -Analytic: - - - -
    -
    - - -Analytic Tags: - - - -
    -
    - - -Options: - - - -
    -
    -
    -
    -
    -
    diff --git a/dynamic_financial_report/static/src/xml/tb_view.xml b/dynamic_financial_report/static/src/xml/tb_view.xml deleted file mode 100644 index ba4b67282..000000000 --- a/dynamic_financial_report/static/src/xml/tb_view.xml +++ /dev/null @@ -1,190 +0,0 @@ - - - -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    AccountInitial DebitInitial CreditDebitCredit
    - - - - - - -
    - - -
    -
    - - - - - - - -
    Total
    -
    -
    - -
    -
      -
    1. Trial Balance
    2. -
    -
    -
    -
    -
    - - -
    -
    -
    -
    - -
    - - -
    -
    - - -Journals: - - - -
    - - -
    - - -Analytic: - - - -
    - - - -
    - - -Options: - - - -
    - -
    -
    -
    -
    -
    \ No newline at end of file diff --git a/dynamic_financial_report/static/src/xml/views.xml b/dynamic_financial_report/static/src/xml/views.xml deleted file mode 100644 index 5b0a5cf1b..000000000 --- a/dynamic_financial_report/static/src/xml/views.xml +++ /dev/null @@ -1,282 +0,0 @@ - - - -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    AccountDebitCreditBalance
    - - - - - - - - - - - - - - - - -
    - -
    -
    -
    - -
    -
      -
    1. General Ledger
    2. -
    -
    -
    -
    -
    - - -
    -
    -
    -
    - -
    - - -
    -
    - - -Journals: - - - -
    -
    - - -Accounts: - - - -
    -
    - - -Account Tags: - - - -
    -
    - - -Analytic: - - - -
    -
    - - -Analytic Tags: - - - -
    -
    - - -Options: - - - -
    -
    -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    DateJRNLPartnerMoveEntry LabelDebitCreditBalance
    - - - - - - - - - - - - - - - - - -
    -
    -
    -
    \ No newline at end of file diff --git a/dynamic_financial_report/views/al_template.xml b/dynamic_financial_report/views/al_template.xml deleted file mode 100644 index 599df375b..000000000 --- a/dynamic_financial_report/views/al_template.xml +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - diff --git a/dynamic_financial_report/views/bank_book_pdf_template.xml b/dynamic_financial_report/views/bank_book_pdf_template.xml deleted file mode 100644 index dd3dd3339..000000000 --- a/dynamic_financial_report/views/bank_book_pdf_template.xml +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - diff --git a/dynamic_financial_report/views/cash_book_pdf_template.xml b/dynamic_financial_report/views/cash_book_pdf_template.xml deleted file mode 100644 index 7f6103058..000000000 --- a/dynamic_financial_report/views/cash_book_pdf_template.xml +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - - diff --git a/dynamic_financial_report/views/cashfl.xml b/dynamic_financial_report/views/cashfl.xml deleted file mode 100644 index 86781bd1a..000000000 --- a/dynamic_financial_report/views/cashfl.xml +++ /dev/null @@ -1,254 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/dynamic_financial_report/views/db_templates.xml b/dynamic_financial_report/views/db_templates.xml deleted file mode 100644 index 28088224a..000000000 --- a/dynamic_financial_report/views/db_templates.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - diff --git a/dynamic_financial_report/views/financial_report_qweb_pdf_template.xml b/dynamic_financial_report/views/financial_report_qweb_pdf_template.xml deleted file mode 100644 index 66706e496..000000000 --- a/dynamic_financial_report/views/financial_report_qweb_pdf_template.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - Financial Report - dynamic.balance.sheet - qweb-pdf - dynamic_financial_report.balance_sheet - dynamic_financial_report.balance_sheet - - - diff --git a/dynamic_financial_report/views/general_ledger_view.xml b/dynamic_financial_report/views/general_ledger_view.xml deleted file mode 100644 index 97bb2e1b9..000000000 --- a/dynamic_financial_report/views/general_ledger_view.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - dynamic.general.ledger.view - dynamic.general.ledger - -
    - - - - - - - - - - - - - - -
    -
    -
    - - - - dynamic.trial.balance.view - dynamic.trial.balance - -
    - - - - - - - - - -
    -
    -
    - - -
    diff --git a/dynamic_financial_report/views/gl_template.xml b/dynamic_financial_report/views/gl_template.xml deleted file mode 100644 index d07be541c..000000000 --- a/dynamic_financial_report/views/gl_template.xml +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - General Ledger - dynamic.general.ledger - qweb-pdf - dynamic_financial_report.general_ledger - dynamic_financial_report.general_ledger - - - - - - Trial Balance - dynamic.trial.balance - qweb-pdf - dynamic_financial_report.trial_balance - dynamic_financial_report.trial_balance - - - diff --git a/dynamic_financial_report/views/kit_menus.xml b/dynamic_financial_report/views/kit_menus.xml deleted file mode 100644 index eb920142c..000000000 --- a/dynamic_financial_report/views/kit_menus.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - Day Book - dynamic.db - - - - - - - Cash Flow Statement Reports - dynamic.cf - - - - - - - Bank Book - dynamic.bb - - - - - - - - Cash Book - dynamic.cb - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dynamic_financial_report/views/menu_dynamic_financial_reports.xml b/dynamic_financial_report/views/menu_dynamic_financial_reports.xml deleted file mode 100644 index 309ce55aa..000000000 --- a/dynamic_financial_report/views/menu_dynamic_financial_reports.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - Balance Sheet Report - dynamic.bs - - - - Profit and Loss Report - dynamic.pal - - - - - - - - - - diff --git a/dynamic_financial_report/views/pl_template.xml b/dynamic_financial_report/views/pl_template.xml deleted file mode 100644 index de5112dea..000000000 --- a/dynamic_financial_report/views/pl_template.xml +++ /dev/null @@ -1,203 +0,0 @@ - - - - - \ No newline at end of file diff --git a/dynamic_financial_report/views/templates.xml b/dynamic_financial_report/views/templates.xml deleted file mode 100644 index e621d7d96..000000000 --- a/dynamic_financial_report/views/templates.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - diff --git a/dynamic_financial_report/wizard/__init__.py b/dynamic_financial_report/wizard/__init__.py deleted file mode 100644 index dba9744c1..000000000 --- a/dynamic_financial_report/wizard/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -from . import general_ledger -from . import trial_balance -from . import balance_sheet -from . import partner_ledger -from . import ageing_partner -from . import balance_sheet_config -from . import bankbook -from . import cash_flow_report -from . import day_book diff --git a/dynamic_financial_report/wizard/ageing_partner.py b/dynamic_financial_report/wizard/ageing_partner.py deleted file mode 100644 index 5a5bd5f81..000000000 --- a/dynamic_financial_report/wizard/ageing_partner.py +++ /dev/null @@ -1,705 +0,0 @@ -"""Partner Ageing""" -import io -import json -import xlsxwriter -from odoo import api, fields, models, _ -from odoo.exceptions import ValidationError, UserError -from dateutil.relativedelta import relativedelta - -FETCH_RANGE = 2500 - - -class PartnerAgeing(models.TransientModel): - """ Transient class For Ageing partner""" - _name = "dynamic.ageing.partner" - - @api.onchange('partner_type') - def onchange_partner_type(self): - self.partner_ids = [(5,)] - if self.partner_type: - company_id = self.env.user.company_id - if self.partner_type == 'customer': - partner_company_domain = [('parent_id', '=', False), - ('customer', '=', True), - '|', - ('company_id', '=', company_id.id), - ('company_id', '=', False)] - - self.partner_ids |= self.env['res.partner'].search \ - (partner_company_domain) - if self.partner_type == 'supplier': - partner_company_domain = [('parent_id', '=', False), - ('supplier', '=', True), - '|', - ('company_id', '=', company_id.id), - ('company_id', '=', False)] - - self.partner_ids |= self.env['res.partner'].search \ - (partner_company_domain) - - def name_get(self): - res = [] - for record in self: - res.append((record.id, 'Ageing')) - return res - - as_on_date = fields.Date(string='As on date', required=True, - default=fields.Date.today()) - bucket_1 = fields.Integer(string='Bucket 1', required=True, default=20) - bucket_2 = fields.Integer(string='Bucket 2', required=True, default=40) - bucket_3 = fields.Integer(string='Bucket 3', required=True, default=60) - bucket_4 = fields.Integer(string='Bucket 4', required=True, default=80) - bucket_5 = fields.Integer(string='Bucket 5', required=True, default=100) - include_details = fields.Boolean(string='Include Details', default=True) - type = fields.Selection([('receivable', 'Receivable Accounts Only'), - ('payable', 'Payable Accounts Only')], - string='Type') - partner_type = fields.Selection([('customer', 'Customer Only'), - ('supplier', 'Supplier Only')], - string='Partner Type') - - partner_ids = fields.Many2many( - 'res.partner', required=False - ) - partner_category_ids = fields.Many2many( - 'res.partner.category', string='Partner Tag', - ) - target_moves = fields.Selection( - [('draft', 'Draft'), - ('posted', 'Posted')], default='draft', string='Target Moves' - - ) - company_id = fields.Many2one( - 'res.company', string='Company', - - ) - - def write(self, vals): - - if not vals.get('partner_ids'): - vals.update({ - 'partner_ids': [(5, 0, 0)] - }) - - if vals.get('partner_category_ids'): - vals.update({'partner_category_ids': [(4, j) for j in vals.get( - 'partner_category_ids')]}) - if vals.get('partner_category_ids') == []: - vals.update({'partner_category_ids': [(5,)]}) - ret = super(PartnerAgeing, self).write(vals) - - return ret - - def validate_data(self): - if not (self.bucket_1 < self.bucket_2 and - self.bucket_2 < self.bucket_3 and - self.bucket_3 < self.bucket_4 and - self.bucket_4 < self.bucket_5): - raise ValidationError(_('"Bucket order must be ascending"')) - return True - - def get_filters(self, default_filters={}): - """ shows filters """ - company_id = self.env.user.company_id - partner_company_domain = [('parent_id', '=', False), - # '|', - # ('customer_rank', '=', True), - # ('supplier_rank', '=', True), - '|', - ('company_id', '=', company_id.id), - ('company_id', '=', False)] - - partners = self.partner_ids if self.partner_ids else self.env[ - 'res.partner'].search(partner_company_domain) - categories = self.partner_category_ids if self.partner_category_ids else \ - self.env['res.partner.category'].search([]) - - filter_dict = { - 'partner_ids': self.partner_ids.ids, - 'partner_category_ids': self.partner_category_ids.ids, - 'company_id': self.company_id and self.company_id.id or False, - 'as_on_date': self.as_on_date, - 'type': self.type, - 'target_moves': self.target_moves, - 'partner_type': self.partner_type, - 'bucket_1': self.bucket_1, - 'bucket_2': self.bucket_2, - 'bucket_3': self.bucket_3, - 'bucket_4': self.bucket_4, - 'bucket_5': self.bucket_5, - 'include_details': self.include_details, - - 'partners_list': [(p.id, p.name) for p in partners], - 'category_list': [(c.id, c.name) for c in categories], - 'company_name': self.company_id and self.company_id.name, - } - filter_dict.update(default_filters) - return filter_dict - - def process_filters(self): - ''' To show on report headers''' - - data = self.get_filters(default_filters={}) - filters = {} - filters['bucket_1'] = data.get('bucket_1') - filters['bucket_2'] = data.get('bucket_2') - filters['bucket_3'] = data.get('bucket_3') - filters['bucket_4'] = data.get('bucket_4') - filters['bucket_5'] = data.get('bucket_5') - - if data.get('partner_ids', []): - filters['partners'] = self.env['res.partner'].browse( - data.get('partner_ids', [])).mapped('name') - else: - filters['partners'] = ['All'] - - if data.get('as_on_date', False): - filters['as_on_date'] = data.get('as_on_date') - - if data.get('company_id'): - filters['company_id'] = data.get('company_id') - else: - filters['company_id'] = '' - - if data.get('target_moves') == 'draft': - - filters['target_moves'] = 'All Entries' - else: - filters['target_moves'] = 'Posted Only' - - if data.get('type') == 'receivable': - filters['type'] = 'Receivable' - elif data.get('type') == 'payable': - filters['type'] = 'Payable' - else: - filters['type'] = 'Receivable and Payable' - - if data.get('partner_type') == 'customer': - filters['partner_type'] = 'Customer Only' - elif data.get('partner_type') == 'supplier': - filters['partner_type'] = 'Supplier Only' - else: - filters['partner_type'] = 'Customer And Supplier ' - - if data.get('partner_category_ids', []): - filters['categories'] = self.env['res.partner.category'].browse( - data.get('partner_category_ids', [])).mapped('name') - else: - filters['categories'] = ['All'] - - if data.get('include_details'): - filters['include_details'] = True - else: - filters['include_details'] = False - - filters['partners_list'] = data.get('partners_list') - filters['category_list'] = data.get('category_list') - filters['company_name'] = data.get('company_name') - - return filters - - def prepare_bucket_list(self): - """ prepare bucket values for partner ageing report""" - periods = {} - date_from = self.as_on_date - date_from = fields.Date.from_string(date_from) - bucket_list = [self.bucket_1, self.bucket_2, self.bucket_3, - self.bucket_4, self.bucket_5] - start = False - stop = date_from - name = 'Not' - periods[0] = { - 'bucket': 'As on', - 'name': name, - 'start': '', - 'stop': stop.strftime('%Y-%m-%d'), - } - - stop = date_from - final_date = False - for i in range(5): - start = stop - relativedelta(days=1) - stop = start - relativedelta(days=bucket_list[i]) - name = 'value_' + str(bucket_list[0]) if i == 0 else str( - str(bucket_list[i - 1] + 1)) + str(bucket_list[i]) - - final_date = stop - periods[i + 1] = { - 'bucket': bucket_list[i], - 'name': name, - 'start': start.strftime('%Y-%m-%d'), - 'stop': stop.strftime('%Y-%m-%d'), - } - - start = final_date - relativedelta(days=1) - stop = '' - name = str(self.bucket_5) - - periods[6] = { - 'bucket': 'Above', - 'name': name, - 'start': start.strftime('%Y-%m-%d'), - 'stop': '', - } - return periods - - def al_move_lines(self, offset=0, partner=0, fetch_range=FETCH_RANGE): - """ shows detailed move lines""" - - as_on_date = self.as_on_date - period_dict = self.prepare_bucket_list() - period_list = [period_dict[a]['name'] for a in period_dict] - company_id = self.env.user.company_id - type = ('receivable', 'payable') - if self.type: - type = tuple([self.type, 'none']) - arg_list = ('draft', 'posted') - if self.target_moves == 'posted': - arg_list = tuple([self.target_moves, 'none']) - offset = offset * fetch_range - count = 0 - move_lines = [] - if partner: - sql = """ - SELECT COUNT(*) - FROM - account_move_line AS l - LEFT JOIN - account_move AS m ON m.id = l.move_id - LEFT JOIN - account_account AS a ON a.id = l.account_id - LEFT JOIN - account_account_type AS ty ON a.user_type_id = ty.id - LEFT JOIN - account_journal AS j ON l.journal_id = j.id - WHERE - l.balance <> 0 - AND m.state IN %s - AND ty.type IN %s - AND l.partner_id = %s - AND l.date <= '%s' - AND l.company_id = %s - """ % (arg_list, type, partner, as_on_date, company_id.id) - self.env.cr.execute(sql) - count = self.env.cr.fetchone()[0] - - SELECT = """SELECT m.name AS move_name, - m.id AS move_id, - l.date AS date, - l.date_maturity AS date_maturity, - j.name AS journal_name, - cc.id AS company_currency_id, - a.name AS account_name, - a.code AS account_code, - c.symbol AS currency_symbol, - c.position AS currency_position, - c.rounding AS currency_precision, - cc.id AS company_currency_id, - cc.symbol AS company_currency_symbol, - cc.rounding AS company_currency_precision, - cc.position AS company_currency_position,""" - - for period in period_dict: - if period_dict[period].get('start') and period_dict[period].get( - 'stop'): - SELECT += """ CASE - WHEN - COALESCE(l.date_maturity,l.date) >= '%s' AND - COALESCE(l.date_maturity,l.date) <= '%s' - THEN - sum(l.balance) + - sum( - COALESCE( - (SELECT - SUM(amount) - FROM account_partial_reconcile - WHERE credit_move_id = l.id AND max_date <= '%s'), 0 - ) - ) - - sum( - COALESCE( - (SELECT - SUM(amount) - FROM account_partial_reconcile - WHERE debit_move_id = l.id AND max_date <= '%s'), 0 - ) - ) - ELSE - 0 - END AS %s,""" % ( - period_dict[period].get('stop'), - period_dict[period].get('start'), - as_on_date, - as_on_date, - 'range_' + str(period), - ) - elif not period_dict[period].get('start'): - SELECT += """ CASE - WHEN - COALESCE(l.date_maturity,l.date) >= '%s' - THEN - sum( - l.balance - ) + - sum( - COALESCE( - (SELECT - SUM(amount) - FROM account_partial_reconcile - WHERE credit_move_id = l.id AND max_date <= '%s'), 0 - ) - ) - - sum( - COALESCE( - (SELECT - SUM(amount) - FROM account_partial_reconcile - WHERE debit_move_id = l.id AND max_date <= '%s'), 0 - ) - ) - ELSE - 0 - END AS %s,""" % ( - period_dict[period].get('stop'), as_on_date, as_on_date, - 'range_' + str(period)) - else: - SELECT += """ CASE - WHEN - COALESCE(l.date_maturity,l.date) <= '%s' - THEN - sum( - l.balance - ) + - sum( - COALESCE( - (SELECT - SUM(amount) - FROM account_partial_reconcile - WHERE credit_move_id = l.id AND max_date <= '%s'), 0 - ) - ) - - sum( - COALESCE( - (SELECT - SUM(amount) - FROM account_partial_reconcile - WHERE debit_move_id = l.id AND max_date <= '%s'), 0 - ) - ) - ELSE - 0 - END AS %s """ % ( - period_dict[period].get('start'), as_on_date, - as_on_date, - 'range_' + str(period)) - - sql = """ - - FROM - account_move_line AS l - LEFT JOIN - account_move AS m ON m.id = l.move_id - LEFT JOIN - account_account AS a ON a.id = l.account_id - LEFT JOIN - account_account_type AS ty ON a.user_type_id = ty.id - LEFT JOIN - account_journal AS j ON l.journal_id = j.id - LEFT JOIN - res_currency AS c ON l.currency_id = c.id - LEFT JOIN - res_currency AS cc ON l.company_currency_id = cc.id - WHERE - l.balance <> 0 - AND m.state IN %s - AND ty.type IN %s - AND l.partner_id = %s - AND l.date <= '%s' - AND l.company_id = %s - GROUP BY - l.date, l.date_maturity,l.currency_id, m.id, m.name, j.name, a.name,a.code, c.rounding, cc.id, cc.rounding, cc.position, c.position, c.symbol, cc.symbol - OFFSET %s ROWS - FETCH FIRST %s ROWS ONLY - """ % ( - arg_list, type, partner, as_on_date, company_id.id, offset, fetch_range) - self.env.cr.execute(SELECT + sql) - final_list = self.env.cr.dictfetchall() or 0.0 - - for m_list in final_list: - if (m_list['range_0'] or m_list['range_1'] or m_list['range_2'] or - m_list['range_3'] or m_list['range_4'] or m_list['range_5']): - move_lines.append(m_list) - return count, offset, move_lines, period_list - - def report_data(self): - """ fetch values from query to get report, prepare bucket values """ - data = self.get_filters(default_filters={}) - - period_dict = self.prepare_bucket_list() - company_id = self.env.user.company_id - domain = ['|', ('company_id', '=', company_id.id), - ('company_id', '=', False)] - if self.partner_type == 'customer': - domain.append(('customer_rank', '=', True)) - if self.partner_type == 'supplier': - domain.append(('supplier_rank', '=', True)) - - if self.partner_category_ids: - domain.append(('category_id', 'in', self.partner_category_ids.ids)) - - partner_ids = self.partner_ids or self.env['res.partner'].search(domain) - as_on_date = self.as_on_date - company_currency_id = company_id.currency_id.id - company_currency_symbol = company_id.currency_id.symbol - company_currency_position = company_id.currency_id.position - company_currency_precision = company_id.currency_id.rounding - - type = ('receivable', 'payable') - if self.type: - type = tuple([self.type, 'none']) - arg_list = ('draft', 'posted') - if self.target_moves == 'posted': - arg_list = tuple([self.target_moves, 'none']) - - partner_dict = {} - for partner in partner_ids: - partner_dict.update({partner.id: {}}) - - for partner in partner_ids: - partner_dict[partner.id].update( - {'id': partner.id, 'partner_name': partner.name}) - - total_balance = 0.0 - sql = """ - SELECT - - COUNT(*) AS count - FROM - account_move_line AS l - LEFT JOIN - account_move AS m ON m.id = l.move_id - LEFT JOIN - account_account AS a ON a.id = l.account_id - LEFT JOIN - account_account_type AS ty ON a.user_type_id = ty.id - WHERE - l.balance <> 0 - AND m.state IN %s - AND ty.type IN %s - AND l.partner_id = %s - AND l.date <= '%s' - AND l.company_id = %s - """ % (arg_list, type, partner.id, as_on_date, company_id.id) - self.env.cr.execute(sql) - - fetch_dict = self.env.cr.dictfetchone() or 0.0 - - count = fetch_dict.get('count') or 0.0 - - if count: - for period in period_dict: - - where = " AND l.date <= '%s' AND l.partner_id = %s " \ - "AND COALESCE(l.date_maturity,l.date) " % ( - as_on_date, partner.id) - if period_dict[period].get('start') and period_dict[ - period].get('stop'): - where += " BETWEEN '%s' AND '%s'" % ( - period_dict[period].get('stop'), - period_dict[period].get('start')) - elif not period_dict[period].get('start'): # ie just - where += " >= '%s'" % (period_dict[period].get('stop')) - else: - where += " <= '%s'" % (period_dict[period].get('start')) - - sql = """ - SELECT - sum(l.balance) AS balance, - sum(COALESCE((SELECT SUM(amount)FROM account_partial_reconcile - WHERE credit_move_id = l.id AND max_date <= '%s'), 0)) AS sum_debit, - sum(COALESCE((SELECT SUM(amount) FROM account_partial_reconcile - WHERE debit_move_id = l.id AND max_date <= '%s'), 0)) AS sum_credit - FROM - account_move_line AS l - LEFT JOIN - account_move AS m ON m.id = l.move_id - LEFT JOIN - account_account AS a ON a.id = l.account_id - LEFT JOIN - account_account_type AS ty ON a.user_type_id = ty.id - WHERE - l.balance <> 0 - - AND ty.type IN %s - AND m.state IN %s - AND l.company_id = %s - """ % (as_on_date, as_on_date, type, arg_list, company_id.id) - amount = 0.0 - self.env.cr.execute(sql + where) - - fetch_dict = self.env.cr.dictfetchall() or 0.0 - - if not fetch_dict[0].get('balance'): - amount = 0.0 - else: - amount = fetch_dict[0]['balance'] + fetch_dict[0][ - 'sum_debit'] - fetch_dict[0]['sum_credit'] - total_balance += amount - - partner_dict[partner.id].update( - {period_dict[period]['name']: amount}) - - partner_dict[partner.id].update({'count': count}) - - partner_dict[partner.id].update( - {'pages': self.get_page_list(count)}) - partner_dict[partner.id].update( - {'single_page': True if count <= FETCH_RANGE else False}) - partner_dict[partner.id].update({'total': total_balance}) - partner_dict[partner.id].update( - {'company_currency_id': company_currency_id}) - partner_dict[partner.id].update( - {'company_currency_symbol': company_currency_symbol}) - partner_dict[partner.id].update( - {'company_currency_position': company_currency_position}) - partner_dict[partner.id].update( - {'company_currency_precision': company_currency_precision}) - partner_dict[partner.id].update( - {'partner_move_lines': self.al_move_lines(0, partner.id, - 2500)}) - - else: - partner_dict.pop(partner.id, None) - - return period_dict, partner_dict - - def get_page_list(self, total_count): - ''' - Helper function to get list of pages from total_count - :param total_count: integer - :return: list(pages) eg. [1,2,3,4,5,6,7 ....] - ''' - page_count = int(total_count / FETCH_RANGE) - if total_count % FETCH_RANGE: - page_count += 1 - return [i + 1 for i in range(0, int(page_count))] or [] - - def get_data(self, default_filters={}, data=None): - """ return period list and filters""" - filters = self.process_filters() - period_dict, partner_lines = self.report_data() - period_list = [period_dict[a]['name'] for a in period_dict] - return filters, partner_lines, period_dict, period_list - - def get_xlsx_report(self, data, response, report_data, dfr_data): - """ xlsx report of Partner Ageing""" - - i_data = str(data) - n_data = json.loads(i_data) - filters = json.loads(report_data) - output = io.BytesIO() - workbook = xlsxwriter.Workbook(output, {'in_memory': True}) - cell_format = workbook.add_format( - {'align': 'center', 'bold': True, 'bg_color': '#d3d3d3;', - 'border': 1}) - sheet = workbook.add_worksheet() - head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '20px'}) - txt = workbook.add_format({'font_size': '10px', 'border': 1}) - sub_heading_sub = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '10px', - 'border': 2, - 'border_color': 'black'}) - sheet.merge_range('E1:I2', - self.env.user.company_id.name + ':' + ' Partner Ageing', - head) - date_head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '10px'}) - sheet.merge_range('A3:C3', 'As On Date: ' + filters.get('as_on_date'), - date_head) - sheet.merge_range('D3:F3', 'Account Type: ' + filters.get('type'), date_head) - sheet.merge_range('G3:H3', 'Target Moves: ' + filters.get('target_moves'), - date_head) - sheet.merge_range('I3:J3', - 'Partner Type: ' + filters.get('partner_type'), - date_head) - sheet.merge_range('D4:F4', ' Partners: ' + ', '.join( - [lt or '' for lt in - filters['partners']]), date_head) - sheet.merge_range('G4:H4', ' Partner Type: ' + ', '.join( - [lt or '' for lt in - filters['categories']]), - date_head) - sheet.merge_range('A5:C5', 'Partner', cell_format) - sheet.write('D5', 'Total', cell_format) - sheet.write('E5', 'Not Due', cell_format) - sheet.write('F5', '0-20', cell_format) - sheet.write('G5', '21-40', cell_format) - sheet.write('H5', '41-60', cell_format) - sheet.write('I5', '61-80', cell_format) - sheet.write('J5', '81-100', cell_format) - sheet.write('K5', '100+', cell_format) - - lst = [] - for rec in n_data: - lst.append(rec) - row = 4 - col = 0 - sheet.set_column(5, 5, 15) - sheet.set_column(6, 6, 15) - sheet.set_column(7, 7, 26) - sheet.set_column(8, 8, 15) - sheet.set_column(9, 9, 15) - sheet.set_column(6, 6, 15) - sheet.set_column(7, 7, 26) - sheet.set_column(8, 8, 15) - sheet.set_column(9, 9, 15) - - for l_rec in lst: - one_lst = [] - two_lst = [] - - if n_data[l_rec]['count']: - one_lst.append(n_data[l_rec]) - two_lst = (n_data[l_rec]['partner_move_lines'][2]) - sheet.merge_range(row + 1, col, row + 1, col + 2, - n_data[l_rec]['partner_name'], sub_heading_sub) - sheet.write(row + 1, col + 3, n_data[l_rec]['total'], sub_heading_sub) - sheet.write(row + 1, col + 4, n_data[l_rec]['Not'], sub_heading_sub) - sheet.write(row + 1, col + 5, n_data[l_rec]['value_20'], sub_heading_sub) - sheet.write(row + 1, col + 6, n_data[l_rec]['2140'], sub_heading_sub) - sheet.write(row + 1, col + 7, n_data[l_rec]['4160'], sub_heading_sub) - sheet.write(row + 1, col + 8, n_data[l_rec]['6180'], sub_heading_sub) - sheet.write(row + 1, col + 9, n_data[l_rec]['81100'], sub_heading_sub) - sheet.write(row + 1, col + 10, n_data[l_rec]['100'], sub_heading_sub) - - row += 2 - sheet.write(row, col, 'Entry Label', cell_format) - sheet.write(row, col + 1, 'Due Date', cell_format) - sheet.write(row, col + 2, 'Journal', cell_format) - sheet.write(row, col + 3, 'Account', cell_format) - sheet.write(row, col + 4, 'Not Due', cell_format) - sheet.write(row, col + 5, '0 - 20', cell_format) - sheet.write(row, col + 6, '21 - 40', cell_format) - sheet.write(row, col + 7, '41 - 60', cell_format) - sheet.write(row, col + 8, '61 - 80', cell_format) - sheet.write(row, col + 9, '81 - 100', cell_format) - sheet.write(row, col + 10, '100 +', cell_format) - for r_rec in two_lst: - row += 1 - sheet.write(row, col, r_rec['move_name'], txt) - sheet.write(row, col + 1, r_rec['date_maturity'], txt) - sheet.write(row, col + 2, r_rec['journal_name'], txt) - sheet.write(row, col + 3, r_rec['account_code'], txt) - sheet.write(row, col + 4, r_rec['range_0'], txt) - sheet.write(row, col + 5, r_rec['range_1'], txt) - sheet.write(row, col + 6, r_rec['range_2'], txt) - sheet.write(row, col + 7, r_rec['range_3'], txt) - sheet.write(row, col + 8, r_rec['range_4'], txt) - sheet.write(row, col + 9, r_rec['range_5'], txt) - sheet.write(row, col + 10, r_rec['range_6'], txt) - - workbook.close() - output.seek(0) - response.stream.write(output.read()) - output.close() diff --git a/dynamic_financial_report/wizard/balance_sheet.py b/dynamic_financial_report/wizard/balance_sheet.py deleted file mode 100644 index 2e8c1101d..000000000 --- a/dynamic_financial_report/wizard/balance_sheet.py +++ /dev/null @@ -1,670 +0,0 @@ -from odoo import models, fields, api -import io -import json -try: - from odoo.tools.misc import xlsxwriter -except ImportError: - import xlsxwriter -FETCH_RANGE = 2000 - - -class BalanceSheetModel(models.TransientModel): - _name = "dynamic.balance.sheet" - - journal_ids = fields.Many2many( - "account.journal", - string="Journals", - ) - account_ids = fields.Many2many( - "account.account", - string="Accounts", - ) - account_tag_ids = fields.Many2many("account.account.tag", - string="Account Tags") - analytic_ids = fields.Many2many( - "account.analytic.account", string="Analytic Accounts" - ) - analytic_tag_ids = fields.Many2many("account.analytic.tag", - string="Analytic Tags") - company_id = fields.Many2one( - "res.company", - string="Company", - ) - date_from = fields.Date( - string="Start date", - ) - date_to = fields.Date( - string="End date", - ) - include_details = fields.Boolean(string="Include Details", default=True) - - entries = fields.Selection([('posted', 'All Posted Entries'), - ('all', 'All Entries')], string='Target Moves', - default='all') - - def report_data(self, tag): - cr = self.env.cr - - data = self.get_filters(default_filters={}) - WHERE = '(1=1)' - company_id = self.env.user.company_id - company_domain = [('company_id', '=', company_id.id)] - if data.get('account_tag_ids', []): - company_domain.append( - ('tag_ids', 'in', data.get('account_tag_ids', []))) - if data.get('account_ids', []): - company_domain.append(('id', 'in', data.get('account_ids', []))) - account_ids = self.env['account.account'].search(company_domain) - - if data.get('journal_ids'): - WHERE += ' AND j.id IN %s' % str( - tuple(data.get('journal_ids')) + tuple([0])) - - if data.get('analytic_ids'): - WHERE += ' AND anl.id IN %s' % str( - tuple(data.get('analytic_ids')) + tuple([0])) - - if data.get('entries') == 'posted': - WHERE += " AND m.state = 'posted'" - - if data.get('analytic_tag_ids'): - WHERE += ' AND analtag.account_analytic_tag_id IN %s' % str( - tuple(data.get('analytic_tag_ids')) + tuple([0])) - - move_lines = { - x.code: { - 'name': x.name, - 'code': x.code, - 'id': x.id, - 'lines': [], - 'type': x.user_type_id.internal_group, - 'type_id': x.user_type_id - } for x in sorted(account_ids, key=lambda a: a.code) - } - - for account in account_ids: - company_id = self.env.user.company_id - currency = account.company_id.currency_id or company_id.currency_id - symbol = currency.symbol - rounding = currency.rounding - position = currency.position - - opening_balance = 0 - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account.id - elif data.get('date_from'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') - WHERE_CURRENT += " AND a.id = %s" % account.id - elif data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account.id - else: - WHERE_CURRENT = WHERE + " AND a.id = %s" % account.id - ORDER_BY_CURRENT = 'l.date' - sql = (''' - SELECT - l.date AS ldate, - l.id AS lid, - j.code AS lcode, - p.name AS partner_name, - m.name AS move_name, - l.name AS lname, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.debit - l.credit,0) AS balance, - COALESCE(l.amount_currency,0) AS amount_currency - FROM account_move_line l - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON (analtag.account_move_line_id=l.id) - LEFT JOIN account_move m ON (l.move_id=m.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - LEFT JOIN account_move i ON (m.id =i.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - --GROUP BY l.id, l.account_id, j.code, l.currency_id, l.date,l.debit_currency, l.credit_currency, l.ref, l.name, m.id, m.name, c.rounding, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ORDER BY %s - ''') % (WHERE_CURRENT, ORDER_BY_CURRENT) - cr.execute(sql) - current_lines = cr.dictfetchall() - for row in current_lines: - row['initial_bal'] = False - row['ending_bal'] = False - - current_balance = row['balance'] - row['balance'] = opening_balance + current_balance - opening_balance += current_balance - row['initial_bal'] = False - - move_lines[account.code]['lines'].append(row) - WHERE_FULL = WHERE + " AND a.id = %s" % account.id - sql = (''' - SELECT - COALESCE(SUM(l.debit),0) AS debit, - COALESCE(SUM(l.credit),0) AS credit, - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - ''') % WHERE_FULL - cr.execute(sql) - for row in cr.dictfetchall(): - row['ending_bal'] = True - row['initial_bal'] = False - move_lines[account.code]['lines'].append(row) - move_lines[account.code]['debit'] = row['debit'] - move_lines[account.code]['credit'] = row['credit'] - move_lines[account.code]['balance'] = row['balance'] - move_lines[account.code]['company_currency_id'] = currency.id - move_lines[account.code]['company_currency_symbol'] = symbol - move_lines[account.code][ - 'company_currency_precision'] = rounding - move_lines[account.code]['company_currency_position'] = position - move_lines[account.code]['count'] = len(current_lines) - move_lines[account.code]['pages'] = self.get_page_list( - len(current_lines)) - move_lines[account.code]['single_page'] = True if len( - current_lines) <= FETCH_RANGE else False - if tag == 'Balance Sheet Report': - account_report_id = self.env['account.financial.report'].search([ - ('name', 'ilike', 'Balance Sheet')]) - if tag == 'Profit and Loss Report': - account_report_id = self.env['account.financial.report'].search([ - ('name', 'ilike', 'Profit and Loss')]) - - new_data = {'id': self.id, 'date_from': self.date_from, - 'enable_filter': True, - 'debit_credit': True, 'date_to': self.date_to, - 'account_report_id': account_report_id, - 'target_move': self.entries, - 'view_format': 'vertical', - 'company_id': self.company_id, - 'used_context': {'journal_ids': False, - 'state': self.entries, - 'date_from': self.date_from, - 'date_to': self.date_to, - 'strict_range': False, - 'company_id': self.company_id, - 'lang': 'en_US'}} - - account_lines = self.get_account_lines(new_data) - - report_lines = self.view_report_pdf(account_lines, new_data)[ - 'report_lines'] - - move_line_accounts = [] - move_line_counts = [] - - for rec in move_lines: - - if move_lines[rec]['count'] != 0: - move_line_accounts.append(move_lines[rec]['code']) - move_line_counts.append(move_lines[rec]['count']) - - report_lines_move = [] - parent_list = [] - - def filter_movelines_parents(obj): - for each in obj: - if each['report_type'] == 'accounts': - if each['code'] in move_line_accounts: - report_lines_move.append(each) - parent_list.append(each['p_id']) - elif each['report_type'] == 'account_report': - report_lines_move.append(each) - else: - report_lines_move.append(each) - - filter_movelines_parents(report_lines) - - parent_list = list(set(parent_list)) - - max_level = 0 - for rep in report_lines_move: - if rep['level'] > max_level: - max_level = rep['level'] - - def get_parents(obj): - for item in report_lines_move: - for each in obj: - if item['report_type'] != 'account_type' and each in item['c_ids']: - obj.append(item['r_id']) - - if item['report_type'] == 'account_report': - obj.append(item['r_id']) - break - - get_parents(parent_list) - - for i in range(max_level): - get_parents(parent_list) - - parent_list = list(set(parent_list)) - - final_report_lines = [] - - for rec in report_lines_move: - if rec['report_type'] != 'accounts': - if rec['r_id'] in parent_list: - final_report_lines.append(rec) - else: - final_report_lines.append(rec) - - def filter_sum(obj): - sum_list = {} - for pl in parent_list: - sum_list[pl] = {} - sum_list[pl]['s_debit'] = 0 - sum_list[pl]['s_credit'] = 0 - sum_list[pl]['s_balance'] = 0 - - for each in obj: - if each['p_id'] and each['p_id'] in parent_list: - sum_list[each['p_id']]['s_debit'] += each['debit'] - sum_list[each['p_id']]['s_credit'] += each['credit'] - sum_list[each['p_id']]['s_balance'] += each['balance'] - return sum_list - - def assign_sum(obj): - for each in obj: - if each['r_id'] in parent_list and each['report_type'] != 'account_report': - each['debit'] = sum_list_new[each['r_id']]['s_debit'] - each['credit'] = sum_list_new[each['r_id']]['s_credit'] - - for p in range(max_level): - sum_list_new = filter_sum(final_report_lines) - assign_sum(final_report_lines) - - company_id = self.env.user.company_id - currency = company_id.currency_id - symbol = currency.symbol - rounding = currency.rounding - position = currency.position - - for rec in final_report_lines: - rec['debit'] = round(rec['debit'], 2) - rec['credit'] = round(rec['credit'], 2) - rec['balance'] = rec['debit'] - rec['credit'] - rec['balance'] = round(rec['balance'], 2) - if position == "before": - rec['m_debit'] = symbol + " " + str(rec['debit']) - rec['m_credit'] = symbol + " " + str(rec['credit']) - rec['m_balance'] = symbol + " " + str(rec['balance']) - - else: - rec['m_debit'] = str(rec['debit']) + " " + symbol - rec['m_credit'] = str(rec['credit']) + " " + symbol - rec['m_balance'] = str(rec['balance']) + " " + symbol - - return move_lines, final_report_lines - - - def get_filters(self, default_filters={}): - company_id = self.env.user.company_id - company_domain = [('company_id', '=', company_id.id)] - journals = self.journal_ids if self.journal_ids else self.env[ - 'account.journal'].search(company_domain) - accounts = self.account_ids if self.account_ids else self.env[ - 'account.account'].search(company_domain) - account_tags = self.account_tag_ids if self.account_tag_ids else \ - self.env['account.account.tag'].search([]) - analytics = self.analytic_ids if self.analytic_ids else self.env[ - 'account.analytic.account'].search( - company_domain) - analytic_tags = self.analytic_tag_ids if self.analytic_tag_ids else \ - self.env[ - 'account.analytic.tag'].sudo().search( - ['|', ('company_id', '=', company_id.id), - ('company_id', '=', False)]) - filter_dict = { - 'journal_ids': self.journal_ids.ids, - 'account_ids': self.account_ids.ids, - 'account_tag_ids': self.account_tag_ids.ids, - 'analytic_ids': self.analytic_ids.ids, - 'analytic_tag_ids': self.analytic_tag_ids.ids, - 'company_id': self.company_id.id, - 'date_from': self.date_from, - 'date_to': self.date_to, - 'entries': self.entries, - 'journals_list': [(j.id, j.name) for j in journals], - 'accounts_list': [(a.id, a.name) for a in accounts], - 'account_tag_list': [(a.id, a.name) for a in account_tags], - 'analytics_list': [(anl.id, anl.name) for anl in analytics], - 'analytic_tag_list': [(anltag.id, anltag.name) for anltag in - analytic_tags], - 'company_name': company_id and company_id.name, - } - filter_dict.update(default_filters) - return filter_dict - - def process_filters(self): - ''' To show on report headers''' - - data = self.get_filters(default_filters={}) - filters = {} - - if data.get('journal_ids'): - filters['journals'] = self.env['account.journal'].browse( - data.get('journal_ids')).mapped('code') - else: - filters['journals'] = ['All'] - - if data.get('account_ids', []): - filters['accounts'] = self.env['account.account'].browse( - data.get('account_ids', [])).mapped('code') - else: - filters['accounts'] = ['All'] - if data.get('include_details'): - filters['include_details'] = True - else: - filters['include_details'] = False - - if data.get('entries'): - filters['entries'] = data.get('entries') - if data.get('date_from', False): - filters['date_from'] = data.get('date_from') - if data.get('date_to', False): - filters['date_to'] = data.get('date_to') - if data.get('company_id'): - filters['company_id'] = data.get('company_id') - else: - filters['company_id'] = '' - filters['account_tags'] = ['All'] - filters['analytics'] = ['All'] - filters['analytic_tags'] = ['All'] - filters['journals_list'] = data.get('journals_list') - filters['accounts_list'] = data.get('accounts_list') - filters['account_tag_list'] = data.get('account_tag_list') - filters['analytics_list'] = data.get('analytics_list') - filters['analytic_tag_list'] = data.get('analytic_tag_list') - filters['company_name'] = data.get('company_name') - - return filters - - def bs_move_lines(self, offset=0, account=0, fetch_range=FETCH_RANGE): - cr = self.env.cr - offset_count = offset * fetch_range - opening_balance = 0 - data = self.get_filters(default_filters={}) - - company_id = self.env.user.company_id - - WHERE = '(1=1)' - - WHERE_CURRENT = WHERE - WHERE_CURRENT += " AND a.id = %s" % account - if data.get('entries') == 'posted': - WHERE += " AND m.state = 'posted'" - - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account - elif data.get('date_from'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') - WHERE_CURRENT += " AND a.id = %s" % account - elif data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account - - - else: - WHERE_CURRENT = WHERE + " AND a.id = %s" % account - - ORDER_BY_CURRENT = 'j.code, p.name, l.move_id, l.date' - move_lines = [] - sql = (''' - SELECT - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - GROUP BY j.code, p.name, l.move_id, l.date - ORDER BY %s - OFFSET %s ROWS - FETCH FIRST %s ROWS ONLY - ''') % (WHERE_CURRENT, ORDER_BY_CURRENT, 0, offset_count) - cr.execute(sql) - running_balance_list = cr.fetchall() - for running_balance in running_balance_list: - opening_balance += running_balance[0] - - sql = (''' - SELECT COUNT(*) - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - ''') % (WHERE_CURRENT) - cr.execute(sql) - count = cr.fetchone()[0] - - sql = (''' - SELECT - l.date AS ldate, - l.id AS lid, - l.account_id AS account_id, - j.code AS lcode, - l.currency_id, - --l.ref AS lref, - l.name AS lname, - m.id AS move_id, - m.name AS move_name, - c.symbol AS currency_symbol, - c.position AS currency_position, - c.rounding AS currency_precision, - cc.id AS company_currency_id, - cc.symbol AS company_currency_symbol, - cc.rounding AS company_currency_precision, - cc.position AS company_currency_position, - p.name AS partner_name, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.debit - l.credit,0) AS balance, - COALESCE(l.amount_currency,0) AS amount_currency - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - GROUP BY l.id, l.account_id, j.code, l.currency_id, l.amount_currency, l.name, m.id, m.name, c.rounding, cc.id, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ORDER BY %s - OFFSET %s ROWS - FETCH FIRST %s ROWS ONLY - ''') % (WHERE_CURRENT, ORDER_BY_CURRENT, offset_count, fetch_range) - - cr.execute(sql) - for row in cr.dictfetchall(): - current_balance = row['balance'] - row['balance'] = opening_balance + current_balance - opening_balance += current_balance - row['initial_bal'] = False - move_lines.append(row) - - return count, offset_count, move_lines - - def get_data(self, tag): - filters = self.process_filters() - account_lines = self.report_data(tag)[0] - report_lines = self.report_data(tag)[1] - - return filters, account_lines, report_lines - - def get_page_list(self, total_count): - - page_count = int(total_count / FETCH_RANGE) - if total_count % FETCH_RANGE: - page_count += 1 - return [i + 1 for i in range(0, int(page_count))] or [] - - def write(self, vals): - - if vals.get('journal_ids'): - vals.update( - {'journal_ids': [(4, j) for j in vals.get('journal_ids')]}) - if vals.get('journal_ids') == []: - vals.update({'journal_ids': [(5,)]}) - if vals.get('account_ids'): - vals.update( - {'account_ids': [(4, j) for j in vals.get('account_ids')]}) - if vals.get('account_ids') == []: - vals.update({'account_ids': [(5,)]}) - - if vals.get('account_tag_ids'): - vals.update({'account_tag_ids': [(4, j) for j in - vals.get('account_tag_ids')]}) - if vals.get('account_tag_ids') == []: - vals.update({'account_tag_ids': [(5,)]}) - - if vals.get('analytic_ids'): - vals.update( - {'analytic_ids': [(4, j) for j in vals.get('analytic_ids')]}) - if vals.get('analytic_ids') == []: - vals.update({'analytic_ids': [(5,)]}) - - if vals.get('analytic_tag_ids'): - vals.update({'analytic_tag_ids': [(4, j) for j in - vals.get('analytic_tag_ids')]}) - if vals.get('analytic_tag_ids') == []: - vals.update({'analytic_tag_ids': [(5,)]}) - - return super(BalanceSheetModel, self).write(vals) - - @api.model - def create(self, vals): - res = super(BalanceSheetModel, self).create(vals) - return res - - def get_xlsx_report(self, data, response, report_data, dfr_data): - - i_data = str(data) - filters = json.loads(report_data) - j_data = dfr_data - rl_data = json.loads(j_data) - output = io.BytesIO() - workbook = xlsxwriter.Workbook(output, {'in_memory': True}) - sheet = workbook.add_worksheet() - head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '20px'}) - sub_heading = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '10px', - 'border': 1, - 'border_color': 'black'}) - side_heading_main = workbook.add_format( - {'align': 'left', 'bold': True, 'font_size': '10px', - 'border': 1, - 'border_color': 'black'}) - - side_heading_sub = workbook.add_format( - {'align': 'left', 'bold': True, 'font_size': '10px', - 'border': 1, - 'border_color': 'black'}) - - side_heading_sub.set_indent(1) - txt = workbook.add_format({'font_size': '10px', 'border': 1}) - txt_name = workbook.add_format({'font_size': '10px', 'border': 1}) - txt_name_bold = workbook.add_format({'font_size': '10px', 'border': 1, - 'bold': True}) - txt_name.set_indent(2) - txt_name_bold.set_indent(2) - - txt = workbook.add_format({'font_size': '10px', 'border': 1}) - - sheet.merge_range('A2:D3', - self.env.user.company_id.name + ' : ' + i_data, - head) - date_head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '10px'}) - - date_head_left = workbook.add_format({'align': 'left', 'bold': True, - 'font_size': '10px'}) - - date_head_right = workbook.add_format({'align': 'right', 'bold': True, - 'font_size': '10px'}) - - date_head_left.set_indent(1) - date_head_right.set_indent(1) - - if filters.get('date_from'): - sheet.merge_range('A4:B4', 'From: ' + filters.get('date_from'), - date_head_left) - if filters.get('date_to'): - sheet.merge_range('C4:D4', 'To: ' + filters.get('date_to'), - date_head_right) - sheet.merge_range('A5:D6', ' Accounts: ' + ', '.join( - [lt or '' for lt in - filters['accounts']]) + ' Journals: ' + ', '.join( - [lt or '' for lt in - filters['journals']]) + ' Account Tags: ' + ', '.join( - [lt or '' for lt in - filters['account_tags']]) + ' Analytic Tags: ' + ', '.join( - [lt or '' for lt in - filters['analytic_tags']]) + ' Analytic: ' + ', '.join( - [at or '' for at in - filters['analytics']]) + ' Entries: ' + filters.get( - 'entries'), date_head) - - sheet.set_column(0, 0, 30) - sheet.set_column(1, 1, 20) - sheet.set_column(2, 2, 15) - sheet.set_column(3, 3, 15) - - row = 5 - col = 0 - - row += 2 - sheet.write(row, col, '', sub_heading) - sheet.write(row, col + 1, 'Debit', sub_heading) - sheet.write(row, col + 2, 'Credit', sub_heading) - sheet.write(row, col + 3, 'Balance', sub_heading) - - if rl_data: - for fr in rl_data: - - row += 1 - if fr['level'] == 1: - sheet.write(row, col, fr['name'], side_heading_main) - elif fr['level'] == 2: - sheet.write(row, col, fr['name'], side_heading_sub) - else: - sheet.write(row, col, fr['name'], txt_name) - sheet.write(row, col + 1, fr['debit'], txt) - sheet.write(row, col + 2, fr['credit'], txt) - sheet.write(row, col + 3, fr['balance'], txt) - - workbook.close() - output.seek(0) - response.stream.write(output.read()) - output.close() diff --git a/dynamic_financial_report/wizard/balance_sheet_config.py b/dynamic_financial_report/wizard/balance_sheet_config.py deleted file mode 100644 index 048f55893..000000000 --- a/dynamic_financial_report/wizard/balance_sheet_config.py +++ /dev/null @@ -1,306 +0,0 @@ -import re -from odoo import models, fields, api - - -class BalanceSheet(models.TransientModel): - _inherit = "dynamic.balance.sheet" - - def view_report_pdf(self, acc, form): - """This function will be executed when we click the view button - from the wizard. Based on the values provided in the wizard, this - function will print pdf report""" - - self.ensure_one() - data = dict() - report_lines = acc - data['form'] = form - - # find the journal items of these accounts - journal_items = self.find_journal_items(report_lines, data['form']) - - def set_report_level(rec): - """This function is used to set the level of each item. - This level will be used to set the alignment in the dynamic reports.""" - - level = 1 - if not rec['parent']: - return level - else: - for line in report_lines: - key = 'a_id' if line['type'] == 'account' else 'id' - if line[key] == rec['parent']: - return level + set_report_level(line) - - # finding the root - for item in report_lines: - item['balance'] = round(item['balance'], 2) - if not item['parent']: - item['level'] = 1 - parent = item - report_name = item['name'] - item_id = item['id'] - report_id = item['r_id'] - else: - item['level'] = set_report_level(item) - data['journal_items'] = journal_items - data['report_lines'] = report_lines - - return data - - def _compute_account_balance(self, accounts): - """ compute the balance, debit - and credit for the provided accounts - """ - - mapping = { - 'balance': - "COALESCE(SUM(debit),0) - COALESCE(SUM(credit), 0)" - " as balance", - 'debit': "COALESCE(SUM(debit), 0) as debit", - 'credit': "COALESCE(SUM(credit), 0) as credit", - } - - res = {} - for account in accounts: - res[account.id] = dict((fn, 0.0) - for fn in mapping.keys()) - if accounts: - tables, where_clause, where_params = ( - self.env['account.move.line']._query_get()) - tables = tables.replace( - '"', '') if tables else "account_move_line" - wheres = [""] - if where_clause.strip(): - wheres.append(where_clause.strip()) - filters = " AND ".join(wheres) - request = ("SELECT account_id as id, " + - ', '.join(mapping.values()) + - " FROM " + tables + - " WHERE account_id IN %s " + - filters + - " GROUP BY account_id") - params = (tuple(accounts._ids),) + tuple(where_params) - - self.env.cr.execute(request, params) - for row in self.env.cr.dictfetchall(): - res[row['id']] = row - - return res - - def _compute_report_balance(self, reports): - """returns a dictionary with key=the ID of a record and - value=the credit, debit and balance amount - computed for this record. If the record is of type : - 'accounts' : it's the sum of the linked accounts - 'account_type' : it's the sum of leaf accounts with - such an account_type - 'account_report' : it's the amount of the related report - 'sum' : it's the sum of the children of this record - (aka a 'view' record)""" - - - res = {} - fields = ['credit', 'debit', 'balance'] - for report in reports: - if report.id in res: - continue - res[report.id] = dict((fn, 0.0) for fn in fields) - if report.type == 'accounts': - # it's the sum of the linked accounts - res[report.id]['account'] = self._compute_account_balance( - report.account_ids - ) - for value in \ - res[report.id]['account'].values(): - for field in fields: - res[report.id][field] += value.get(field) - elif report.type == 'account_type': - # it's the sum the leaf accounts - # with such an account type - accounts = self.env['account.account'].search([ - ('user_type_id', 'in', report.account_type_ids.ids) - ]) - res[report.id]['account'] = self._compute_account_balance( - accounts) - for value in res[report.id]['account'].values(): - for field in fields: - res[report.id][field] += value.get(field) - elif report.type == 'account_report' and report.account_report_id: - # it's the amount of the linked report - res2 = self._compute_report_balance(report.account_report_id) - for key, value in res2.items(): - for field in fields: - res[report.id][field] += value[field] - elif report.type == 'sum': - # it's the sum of the children of this account.report - res2 = self._compute_report_balance(report.children_ids) - for key, value in res2.items(): - for field in fields: - res[report.id][field] += value[field] - return res - - def get_account_lines(self, data): - - lines = [] - account_report = data['account_report_id'] - child_reports = account_report._get_children_by_order() - res = self.with_context( - data.get('used_context'))._compute_report_balance(child_reports) - if data['enable_filter']: - comparison_res = self._compute_report_balance(child_reports) - for report_id, value in comparison_res.items(): - res[report_id]['comp_bal'] = value['balance'] - report_acc = res[report_id].get('account') - if report_acc: - for account_id, val in \ - comparison_res[report_id].get('account').items(): - report_acc[account_id]['comp_bal'] = val['balance'] - - for report in child_reports: - r_name = str(report.name) - # r_name = r_name.replace(" ", "-") + "-" - r_name = re.sub('[^0-9a-zA-Z]+', '', r_name) - if report.parent_id: - p_name = str(report.parent_id.name) - p_name = re.sub('[^0-9a-zA-Z]+', '', p_name) + str( - report.parent_id.id) - else: - p_name = False - - child_ids = [] - for chd in report.children_ids: - child_ids.append(chd.id) - - vals = { - 'r_id': report.id, - 'p_id': report.parent_id.id, - 'report_type': report.type, - 'c_ids': child_ids, - 'id': r_name + str(report.id), - 'sequence': report.sequence, - 'parent': p_name, - 'name': report.name, - 'balance': res[report.id]['balance'] * int(report.sign), - 'type': 'report', - 'level': bool( - report.style_overwrite) and report.style_overwrite or - report.level, - 'account_type': report.type or False, - 'is_present': False, - # used to underline the financial report balances - } - if data['debit_credit']: - vals['debit'] = res[report.id]['debit'] - vals['credit'] = res[report.id]['credit'] - - if data['enable_filter']: - vals['balance_cmp'] = res[report.id]['comp_bal'] * int( - report.sign) - - lines.append(vals) - if report.display_detail == 'no_detail': - # the rest of the loop is - # used to display the details of the - # financial report, so it's not needed here. - continue - - if res[report.id].get('account'): - sub_lines = [] - for account_id, value \ - in res[report.id]['account'].items(): - # if there are accounts to display, - # we add them to the lines with a level equals - # to their level in - # the COA + 1 (to avoid having them with a too low level - # that would conflicts with the level of data - # financial reports for Assets, liabilities...) - flag = False - account = self.env['account.account'].browse(account_id) - # new_r_name = str(report.name) - # new_r_name = new_r_name.replace(" ", "-") + "-" - vals = { - 'r_id': False, - 'p_id': report.id, - 'report_type': 'accounts', - 'c_ids': [], - 'account': account.id, - 'code': account.code, - 'a_id': account.code + re.sub('[^0-9a-zA-Z]+', 'acnt', - account.name) + str( - account.id), - 'name': account.code + '-' + account.name, - 'balance': value['balance'] * int(report.sign) or 0.0, - 'type': 'account', - 'parent': r_name + str(report.id), - 'level': ( - report.display_detail == 'detail_with_hierarchy' and - 4), - 'account_type': account.internal_type, - } - if data['debit_credit']: - vals['debit'] = value['debit'] - vals['credit'] = value['credit'] - if not account.company_id.currency_id.is_zero( - vals['debit']) or \ - not account.company_id.currency_id.is_zero( - vals['credit']): - flag = True - if not account.company_id.currency_id.is_zero( - vals['balance']): - flag = True - if data['enable_filter']: - vals['balance_cmp'] = value['comp_bal'] * int( - report.sign) - if not account.company_id.currency_id.is_zero( - vals['balance_cmp']): - flag = True - if flag: - sub_lines.append(vals) - lines += sorted(sub_lines, - key=lambda sub_line: sub_line['name']) - return lines - - def find_journal_items(self, report_lines, form): - cr = self.env.cr - journal_items = [] - for i in report_lines: - if i['type'] == 'account': - account = i['account'] - if form['target_move'] == 'posted': - search_query = "select aml.id, am.id as j_id, aml.account_id, aml.date," \ - " aml.name as label, am.name, " \ - + "(aml.debit-aml.credit) as balance, aml.debit, aml.credit, aml.partner_id " \ - + " from account_move_line aml join account_move am " \ - "on (aml.move_id=am.id and am.state=%s) " \ - + " where aml.account_id=%s" - vals = [form['target_move']] - else: - search_query = "select aml.id, am.id as j_id, aml.account_id, aml.date, " \ - "aml.name as label, am.name, " \ - + "(aml.debit-aml.credit) as balance, aml.debit, aml.credit, aml.partner_id " \ - + " from account_move_line aml join account_move am on (aml.move_id=am.id) " \ - + " where aml.account_id=%s" - vals = [] - if form['date_from'] and form['date_to']: - search_query += " and aml.date>=%s and aml.date<=%s" - vals += [account, form['date_from'], form['date_to']] - elif form['date_from']: - search_query += " and aml.date>=%s" - vals += [account, form['date_from']] - elif form['date_to']: - search_query += " and aml.date<=%s" - vals += [account, form['date_to']] - else: - vals += [account] - - cr.execute(search_query, tuple(vals)) - items = cr.dictfetchall() - - for j in items: - temp = j['id'] - j['id'] = re.sub('[^0-9a-zA-Z]+', '', i['name']) + str( - temp) - j['p_id'] = str(i['a_id']) - j['type'] = 'journal_item' - journal_items.append(j) - return journal_items diff --git a/dynamic_financial_report/wizard/bankbook.py b/dynamic_financial_report/wizard/bankbook.py deleted file mode 100644 index 76fc73ee5..000000000 --- a/dynamic_financial_report/wizard/bankbook.py +++ /dev/null @@ -1,527 +0,0 @@ -from odoo import models, fields, api -import io -import json -try: - from odoo.tools.misc import xlsxwriter -except ImportError: - import xlsxwriter -FETCH_RANGE = 2000 - - -class BankBook(models.TransientModel): - _name = "dynamic.bank.book" - - journal_ids = fields.Many2many( - "account.journal", - string="Journals", - ) - account_ids = fields.Many2many( - "account.account", - string="Accounts", - ) - account_tag_ids = fields.Many2many("account.account.tag", string="Account Tags") - analytic_ids = fields.Many2many( - "account.analytic.account", string="Analytic Accounts" - ) - analytic_tag_ids = fields.Many2many("account.analytic.tag", string="Analytic Tags") - company_id = fields.Many2one( - "res.company", - string="Company", - ) - date_from = fields.Date( - string="Start date", - ) - date_to = fields.Date( - string="End date", - ) - include_details = fields.Boolean(string="Include Details", default=True) - - entries = fields.Selection([('posted', 'All Posted Entries'), - ('all', 'All Entries')], string='Target Moves', default='all') - - def report_data(self, title): - cr = self.env.cr - - data = self.get_filters(default_filters={}) - WHERE = '(1=1)' - company_id = self.env.user.company_id - company_domain = [('company_id', '=', company_id.id)] - if data.get('account_tag_ids', []): - company_domain.append(('tag_ids','in', data.get('account_tag_ids', []))) - if data.get('account_ids', []): - company_domain.append(('id','in', data.get('account_ids', []))) - account_ids = self.env['account.account'].search(company_domain) - - if title == "Bank Book": - journals = self.env['account.journal'].search([('type', '=', 'bank')], - limit=1) - if title == "Cash Book": - journals = self.env['account.journal'].search([('type', '=', 'cash')], - limit=1) - journals_type = journals.id - WHERE += 'AND j.id = %s' % str(journals_type) - - if data.get('analytic_ids'): - WHERE += ' AND anl.id IN %s' % str(tuple(data.get('analytic_ids')) + tuple([0])) - - if data.get('entries') == 'posted': - WHERE += " AND m.state = 'posted'" - - if data.get('analytic_tag_ids'): - WHERE += ' AND analtag.account_analytic_tag_id IN %s' % str( - tuple(data.get('analytic_tag_ids')) + tuple([0])) - - move_lines = { - x.code: { - 'name': x.name, - 'code': x.code, - 'id': x.id, - 'lines': [] - } for x in sorted(account_ids, key=lambda a: a.code) - } - for account in account_ids: - company_id = self.env.user.company_id - currency = account.company_id.currency_id or company_id.currency_id - symbol = currency.symbol - rounding = currency.rounding - position = currency.position - - opening_balance = 0 - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get('date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account.id - elif data.get('date_from'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') - WHERE_CURRENT += " AND a.id = %s" % account.id - elif data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account.id - else: - WHERE_CURRENT = WHERE + " AND a.id = %s" % account.id - ORDER_BY_CURRENT = 'l.date' - sql = (''' - SELECT - l.date AS ldate, - l.id AS lid, - j.code AS lcode, - p.name AS partner_name, - m.name AS move_name, - l.name AS lname, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.debit - l.credit,0) AS balance, - COALESCE(l.amount_currency,0) AS amount_currency - FROM account_move_line l - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON (analtag.account_move_line_id=l.id) - LEFT JOIN account_move m ON (l.move_id=m.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - LEFT JOIN account_move i ON (m.id =i.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - --GROUP BY l.id, l.account_id, j.code, l.currency_id, l.date,l.debit_currency, l.credit_currency, l.ref, l.name, m.id, m.name, c.rounding, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ORDER BY %s - ''') % (WHERE_CURRENT, ORDER_BY_CURRENT) - cr.execute(sql) - current_lines = cr.dictfetchall() - for row in current_lines: - row['initial_bal'] = False - row['ending_bal'] = False - - current_balance = row['balance'] - row['balance'] = opening_balance + current_balance - opening_balance += current_balance - row['initial_bal'] = False - - move_lines[account.code]['lines'].append(row) - WHERE_FULL = WHERE + " AND a.id = %s" % account.id - sql = (''' - SELECT - COALESCE(SUM(l.debit),0) AS debit, - COALESCE(SUM(l.credit),0) AS credit, - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - ''') % WHERE_FULL - cr.execute(sql) - for row in cr.dictfetchall(): - row['ending_bal'] = True - row['initial_bal'] = False - move_lines[account.code]['lines'].append(row) - move_lines[account.code]['debit'] = row['debit'] - move_lines[account.code]['credit'] = row['credit'] - move_lines[account.code]['balance'] = row['balance'] - move_lines[account.code]['company_currency_id'] = currency.id - move_lines[account.code]['company_currency_symbol'] = symbol - move_lines[account.code]['company_currency_precision'] = rounding - move_lines[account.code]['company_currency_position'] = position - move_lines[account.code]['count'] = len(current_lines) - move_lines[account.code]['pages'] = self.get_page_list(len(current_lines)) - move_lines[account.code]['single_page'] = True if len(current_lines) <= FETCH_RANGE else False - return move_lines - def get_filters(self, default_filters={}): - company_id = self.env.user.company_id - company_domain = [('company_id','=', company_id.id)] - journals = self.journal_ids if self.journal_ids else self.env['account.journal'].search(company_domain) - accounts = self.account_ids if self.account_ids else self.env['account.account'].search(company_domain) - account_tags = self.account_tag_ids if self.account_tag_ids else self.env['account.account.tag'].search([]) - analytics = self.analytic_ids if self.analytic_ids else self.env['account.analytic.account'].search( - company_domain) - analytic_tags = self.analytic_tag_ids if self.analytic_tag_ids else self.env[ - 'account.analytic.tag'].sudo().search( - ['|', ('company_id', '=', company_id.id), ('company_id', '=', False)]) - filter_dict = { - 'journal_ids': self.journal_ids.ids, - 'account_ids': self.account_ids.ids, - 'account_tag_ids': self.account_tag_ids.ids, - 'analytic_ids': self.analytic_ids.ids, - 'analytic_tag_ids': self.analytic_tag_ids.ids, - 'company_id': self.company_id.id, - 'date_from': self.date_from, - 'date_to': self.date_to, - 'entries': self.entries, - 'journals_list': [(j.id, j.name) for j in journals], - 'accounts_list': [(a.id, a.name) for a in accounts], - 'account_tag_list': [(a.id, a.name) for a in account_tags], - 'analytics_list': [(anl.id, anl.name) for anl in analytics], - 'analytic_tag_list': [(anltag.id, anltag.name) for anltag in analytic_tags], - 'company_name': company_id and company_id.name, - } - filter_dict.update(default_filters) - return filter_dict - - def process_filters(self): - ''' To show on report headers''' - - data = self.get_filters(default_filters={}) - filters = {} - - if data.get('journal_ids'): - filters['journals'] = self.env['account.journal'].browse(data.get('journal_ids')).mapped('code') - else: - filters['journals'] = ['All'] - - if data.get('account_ids', []): - filters['accounts'] = self.env['account.account'].browse(data.get('account_ids', [])).mapped('code') - else: - filters['accounts'] = ['All'] - if data.get('include_details'): - filters['include_details'] = True - else: - filters['include_details'] = False - - if data.get('entries'): - filters['entries'] = data.get('entries') - if data.get('date_from', False): - filters['date_from'] = data.get('date_from') - if data.get('date_to', False): - filters['date_to'] = data.get('date_to') - if data.get('company_id'): - filters['company_id'] = data.get('company_id') - else: - filters['company_id'] = '' - filters['account_tags'] = ['All'] - filters['analytics'] = ['All'] - filters['analytic_tags'] = ['All'] - filters['journals_list'] = data.get('journals_list') - filters['accounts_list'] = data.get('accounts_list') - filters['account_tag_list'] = data.get('account_tag_list') - filters['analytics_list'] = data.get('analytics_list') - filters['analytic_tag_list'] = data.get('analytic_tag_list') - filters['company_name'] = data.get('company_name') - - return filters - - def bb_move_lines(self, offset=0, account=0, fetch_range=FETCH_RANGE): - cr = self.env.cr - offset_count = offset * fetch_range - opening_balance = 0 - data = self.get_filters(default_filters={}) - - company_id = self.env.user.company_id - - WHERE = '(1=1)' - - WHERE_CURRENT = WHERE - WHERE_CURRENT += " AND a.id = %s" % account - if data.get('entries') == 'posted': - WHERE += " AND m.state = 'posted'" - - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account - elif data.get('date_from'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') - WHERE_CURRENT += " AND a.id = %s" % account - elif data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account - - - else: - WHERE_CURRENT = WHERE + " AND a.id = %s" % account - - ORDER_BY_CURRENT = 'j.code, p.name, l.move_id, l.date' - move_lines = [] - sql = (''' - SELECT - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - GROUP BY j.code, p.name, l.move_id, l.date - ORDER BY %s - OFFSET %s ROWS - FETCH FIRST %s ROWS ONLY - ''') % (WHERE_CURRENT, ORDER_BY_CURRENT, 0, offset_count) - cr.execute(sql) - running_balance_list = cr.fetchall() - for running_balance in running_balance_list: - opening_balance += running_balance[0] - - sql = (''' - SELECT COUNT(*) - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - ''') % (WHERE_CURRENT) - cr.execute(sql) - count = cr.fetchone()[0] - - sql = (''' - SELECT - l.date AS ldate, - l.id AS lid, - l.account_id AS account_id, - j.code AS lcode, - l.currency_id, - --l.ref AS lref, - l.name AS lname, - m.id AS move_id, - m.name AS move_name, - c.symbol AS currency_symbol, - c.position AS currency_position, - c.rounding AS currency_precision, - cc.id AS company_currency_id, - cc.symbol AS company_currency_symbol, - cc.rounding AS company_currency_precision, - cc.position AS company_currency_position, - p.name AS partner_name, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.debit - l.credit,0) AS balance, - COALESCE(l.amount_currency,0) AS amount_currency - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - GROUP BY l.id, l.account_id, j.code, l.currency_id, l.amount_currency, l.name, m.id, m.name, c.rounding, cc.id, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ORDER BY %s - OFFSET %s ROWS - FETCH FIRST %s ROWS ONLY - ''') % (WHERE_CURRENT, ORDER_BY_CURRENT, offset_count, fetch_range) - cr.execute(sql) - for row in cr.dictfetchall(): - current_balance = row['balance'] - row['balance'] = opening_balance + current_balance - opening_balance += current_balance - row['initial_bal'] = False - move_lines.append(row) - - return count, offset_count, move_lines - - - def get_data(self, title): - filters = self.process_filters() - account_lines = self.report_data(title) - return filters, account_lines - - - def get_page_list(self, total_count): - - page_count = int(total_count / FETCH_RANGE) - if total_count % FETCH_RANGE: - page_count += 1 - return [i + 1 for i in range(0, int(page_count))] or [] - - def write(self, vals): - - if vals.get('journal_ids'): - vals.update({'journal_ids': [(4, j) for j in vals.get('journal_ids')]}) - if vals.get('journal_ids') == []: - vals.update({'journal_ids': [(5,)]}) - if vals.get('account_ids'): - vals.update({'account_ids': [(4, j) for j in vals.get('account_ids')]}) - if vals.get('account_ids') == []: - vals.update({'account_ids': [(5,)]}) - - if vals.get('account_tag_ids'): - vals.update({'account_tag_ids': [(4, j) for j in vals.get('account_tag_ids')]}) - if vals.get('account_tag_ids') == []: - vals.update({'account_tag_ids': [(5,)]}) - - if vals.get('analytic_ids'): - vals.update({'analytic_ids': [(4, j) for j in vals.get('analytic_ids')]}) - if vals.get('analytic_ids') == []: - vals.update({'analytic_ids': [(5,)]}) - - if vals.get('analytic_tag_ids'): - vals.update({'analytic_tag_ids': [(4, j) for j in vals.get('analytic_tag_ids')]}) - if vals.get('analytic_tag_ids') == []: - vals.update({'analytic_tag_ids': [(5,)]}) - return super(BankBook, self).write(vals) - - @api.model - def create(self, vals): - res = super(BankBook, self).create(vals) - return res - - def get_xlsx_report(self, data, response, report_data, dfr_data): - i = str(data) - n = json.loads(i) - filters = json.loads(report_data) - output = io.BytesIO() - workbook = xlsxwriter.Workbook(output, {'in_memory': True}) - sheet = workbook.add_worksheet() - head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '20px'}) - sub_heading = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '12px', - 'border': 1, - 'border_color': 'black'}) - sub_heading_sub = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '10px', - 'border': 2, - 'border_color': 'black'}) - sub_heading_total = workbook.add_format( - {'align': 'right', 'bold': True, 'font_size': '10px', - 'border': 2, - 'border_color': 'black'}) - sub_heading_main = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '10px', - 'border': 1, - 'border_color': 'black'}) - txt = workbook.add_format({'font_size': '10px', 'border': 1}) - sheet.merge_range('A2:J3', self.env.user.company_id.name + ':' + dfr_data, head) - date_head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '10px'}) - date_style = workbook.add_format({'align': 'center', - 'font_size': '10px'}) - if filters.get('date_from'): - sheet.merge_range('B4:C4', 'From: '+filters.get('date_from') , date_head) - if filters.get('date_to'): - sheet.merge_range('H4:I4', 'To: '+ filters.get('date_to'), date_head) - sheet.merge_range('A5:J6', ' Accounts: ' + ', '.join([ lt or '' for lt in filters['accounts'] ]) + ' Journals: ' + ', '.join([ lt or '' for lt in filters['journals'] ]) + ' Account Tags: ' + ', '.join([ lt or '' for lt in filters['account_tags'] ]) + ' Analytic Tags: ' + ', '.join([ lt or '' for lt in filters['analytic_tags'] ]) + ' Analytic: ' +', '.join([ at or '' for at in filters['analytics'] ]) + ' Entries: '+ filters.get('entries'), date_head) - - sheet.write('A8', 'Code', sub_heading) - sheet.write('B8', 'Account', sub_heading) - sheet.write('C8', 'Date', sub_heading) - sheet.write('D8', 'JRNL', sub_heading) - sheet.write('E8', 'Partner', sub_heading) - sheet.write('F8', 'Move', sub_heading) - sheet.write('G8', 'Entry Label', sub_heading) - sheet.write('H8', 'Debit', sub_heading) - sheet.write('I8', 'Credit', sub_heading) - sheet.write('J8', 'Balance', sub_heading) - lst = [] - for rec in n: - lst.append(rec) - row = 6 - col = 0 - row_1 = 5 - sheet.set_column(8, 0, 15) - sheet.set_column('B:B', 40) - sheet.set_column(8, 2, 15) - sheet.set_column(8, 3, 15) - sheet.set_column(8, 4, 15) - sheet.set_column(8, 5, 15) - sheet.set_column(8, 6, 50) - sheet.set_column(8, 7, 26) - sheet.set_column(8, 8, 15) - sheet.set_column(8, 9, 15) - for l in lst: - one_lst = [] - two_lst = [] - - if n[l]['count']: - - one_lst.append(n[l]) - row += 1 - row_1 += 1 - sheet.write(row +1, col, n[l]['code'], sub_heading_sub) - sheet.write(row +1, col + 1, n[l]['name'], sub_heading_sub) - sheet.write(row + 1, col + 2, '', sub_heading_sub) - sheet.write(row + 1, col + 3, '', sub_heading_sub) - sheet.write(row + 1, col + 4, '', sub_heading_sub) - sheet.write(row + 1, col + 5, '', sub_heading_sub) - sheet.write(row + 1, col + 6, '', sub_heading_sub) - - sheet.write(row +1, col + 7, n[l]['debit'], sub_heading_total) - sheet.write(row +1, col + 8, n[l]['credit'], sub_heading_total) - sheet.write(row +1, col + 9, n[l]['balance'], sub_heading_total) - - for rec_1 in n[l]['lines']: - row_1 += 1 - row += 1 - if rec_1['initial_bal']: - sheet.write(row +1, col, 'Initial Balance', sub_heading_main) - sheet.write(row + 1, col + 1, '', txt) - sheet.write(row + 1, col + 2, '', txt) - sheet.write(row + 1, col + 3, '', txt) - sheet.write(row + 1, col + 4, '', txt) - sheet.write(row + 1, col + 5, '', txt) - sheet.write(row + 1, col + 6, '', txt) - sheet.write(row +1, col + 7, n[l]['debit'], txt) - sheet.write(row +1, col + 8, n[l]['credit'], txt) - sheet.write(row +1, col + 9, n[l]['balance'], txt) - if not rec_1['initial_bal'] and not rec_1['ending_bal']: - sheet.write(row + 1, col , '', txt) - sheet.write(row + 1, col + 1, '', txt) - sheet.write(row +1, col + 2, rec_1.get('ldate'), txt) - sheet.write(row +1, col + 3, rec_1.get('lcode'), txt) - sheet.write(row +1, col + 4, rec_1.get('partner_name'), txt) - sheet.write(row +1, col + 5, rec_1.get('move_name'), txt) - sheet.write(row +1, col + 6, rec_1.get('lname'), txt) - sheet.write(row +1, col + 7, rec_1.get('debit'), txt) - sheet.write(row +1, col + 8, rec_1.get('credit'), txt) - sheet.write(row +1, col + 9, rec_1.get('balance'), txt) - - workbook.close() - output.seek(0) - response.stream.write(output.read()) - output.close() diff --git a/dynamic_financial_report/wizard/cash_flow_report.py b/dynamic_financial_report/wizard/cash_flow_report.py deleted file mode 100644 index 57376e4a3..000000000 --- a/dynamic_financial_report/wizard/cash_flow_report.py +++ /dev/null @@ -1,653 +0,0 @@ -from odoo import models, fields, api -import io -import json -from odoo.exceptions import UserError, ValidationError -try: - from odoo.tools.misc import xlsxwriter -except ImportError: - import xlsxwriter -FETCH_RANGE = 2000 - - -class CashFlow(models.TransientModel): - _name = "dynamic.cash.flow" - journal_ids = fields.Many2many( - "account.journal", - string="Journals", - ) - target_moves = fields.Selection( - [('all', 'All entries'), - ('posted', 'Posted Only')], string='Target Moves', default='all' - ) - analytic_ids = fields.Many2many( - "account.analytic.account", string="Analytic Accounts" - ) - analytic_tag_ids = fields.Many2many("account.analytic.tag", - string="Analytic Tags") - account_ids = fields.Many2many( - "account.account", - string="Accounts", - ) - company_id = fields.Many2one( - "res.company", - string="Company", - ) - date_from = fields.Date( - default='2021-01-01', - string="Start date", - ) - date_to = fields.Date( - default=fields.Date.today(), - string="End date", - ) - partner_ids = fields.Many2many('res.partner', string='Partner') - partner_category_ids = fields.Many2many('res.partner.category', - string='Partner_tags') - include_details = fields.Boolean(string="Include Details", default=True) - level = fields.Selection([('summary', 'Summary'), - ('consolidated', 'Consolidated'), - ('detailed', 'Detailed'), - ('very', 'Very Detailedy')], - string='Levels') - - reconciled = fields.Selection([('reconciled', 'Reconciled Only'), - ('unreconciled', 'Unreconciled Only')], - string='Reconcile Type') - - type = fields.Selection( - [('receivable', 'Receivable Only'), - ('payable', 'Payable only')], - string='Account Type', required=False - ) - - def get_journal_lines(self, account, data, offset=0, fetch_range=FETCH_RANGE): - account_type_id = self.env.ref( - 'account.data_account_type_liquidity').id - offset_count = offset * fetch_range - state = """AND am.state = 'posted' """ if data.get('target_moves') == 'posted' else '' - sql2 = """SELECT aa.name as account_name, aj.name, sum(aml.debit) AS total_debit, - sum(aml.credit) AS total_credit, COALESCE(SUM(aml.debit - aml.credit),0) AS balance FROM (SELECT am.* FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str( - data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' """ + state + """) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_journal aj ON aj.id = am.journal_id - WHERE aa.id = """ + str(account.id) + """ - GROUP BY aa.name, aj.name""" - - cr = self._cr - cr.execute(sql2) - fetched_data = cr.dictfetchall() - if fetched_data: - return { - 'account': account.name, - 'id': account.id, - 'journal_lines': fetched_data, - 'offset': offset_count, - } - - def process_filters(self): - # To show on report headers - data = self.get_filters(default_filters={}) - filters = {} - if data.get('date_from', False): - filters['date_from'] = data.get('date_from') - if data.get('date_to', False): - filters['date_to'] = data.get('date_to') - if data.get('company_id'): - filters['company_id'] = data.get('company_id') - else: - filters['company_id'] = '' - - if data.get('include_details'): - filters['include_details'] = True - else: - filters['include_details'] = False - if data.get('target_moves') == 'all': - filters['target_moves'] = 'All Entries' - else: - filters['target_moves'] = 'Posted Only' - return filters - - def get_filters(self, default_filters={}): - company_id = self.env.user.company_id - company_domain = [('company_id', '=', company_id.id)] - partner_company_domain = [('parent_id', '=', False), - '|', - ('company_id', '=', company_id.id), - ('company_id', '=', False)] - - filter_dict = { - 'account_ids': self.account_ids.ids, - 'company_id': self.company_id and self.company_id.id or False, - 'date_from': self.date_from, - 'date_to': self.date_to, - 'reconciled': self.reconciled, - 'type': self.type, - 'level': self.level, - 'target_moves' : self.target_moves, - 'company_name': self.company_id and self.company_id.name, - } - filter_dict.update(default_filters) - return filter_dict - - def get_data(self): - filters = self.process_filters() - account_lines = self.report_data() - if account_lines['date_from'] is False: - raise ValidationError("Please attach your document") - return filters, account_lines - - def get_page_list(self, total_count): - page_count = int(total_count / FETCH_RANGE) - if total_count % FETCH_RANGE: - page_count += 1 - return [i + 1 for i in range(0, int(page_count))] or [] - - @api.model - def create(self, vals): - ret = super(CashFlow, self).create(vals) - return ret - - def write(self, vals): - if vals['date_from'] is False: - raise ValidationError("Please enter start date") - if vals['date_to'] is False: - raise ValidationError("Please enter date") - if vals.get('journal_ids'): - vals.update( - {'journal_ids': [(4, j) for j in vals.get('journal_ids')]}) - if vals.get('journal_ids') == []: - vals.update({'journal_ids': [(5,)]}) - if vals.get('analytic_ids'): - vals.update({'analytic_ids': [(4, j) for j in vals.get('analytic_ids')]}) - if vals.get('analytic_ids') == []: - vals.update({'analytic_ids': [(5,)]}) - - if vals.get('analytic_tag_ids'): - vals.update({'analytic_tag_ids': [(4, j) for j in vals.get('analytic_tag_ids')]}) - if vals.get('analytic_tag_ids') == []: - vals.update({'analytic_tag_ids': [(5,)]}) - ret = super(CashFlow, self).write(vals) - return ret - - def report_data(self): - cr = self.env.cr - data = self.get_filters(default_filters={}) - company_id = self.env.user.company_id - currency = company_id.currency_id - symbol = company_id.currency_id.symbol - rounding = company_id.currency_id.rounding - position = company_id.currency_id.position - - fetched_data = [] - account_res = [] - journal_res = [] - fetched = [] - - account_type_id = self.env.ref('account.data_account_type_liquidity').id - model = self.env.context.get('active_model') - if data.get('level') == 'summary': - state = """ WHERE am.state = 'posted' """ if data.get('target_moves') == 'posted' else '' - query3 = """SELECT to_char(am.date, 'Month') as month_part, extract(YEAR from am.date) as year_part, - sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, - sum(aml.balance) AS total_balance FROM (SELECT am.date, am.id, am.state FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str( - data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' ) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - """ + state + """GROUP BY month_part,year_part""" - cr = self._cr - cr.execute(query3) - fetched_data = cr.dictfetchall() - elif data.get('date_from') is False: - account_type_id = self.env.ref( - 'account.data_account_type_liquidity').id - state = """AND am.state = 'posted' """ if data.get( - 'level') == 'posted' else '' - sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit, - sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance - FROM (SELECT am.* FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str( - data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' """ + state + """) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - GROUP BY aa.name, aa.code,aa.id""" - cr = self._cr - cr.execute(sql) - fetched_data = cr.dictfetchall() - elif data.get('date_from') is False and data.get('date_from') != False: - account_type_id = self.env.ref( - 'account.data_account_type_liquidity').id - state = """AND am.state = 'posted' """ if data.get( - 'level') == 'posted' else '' - sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit, - sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance - FROM (SELECT am.* FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str( - data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' """ + state + """) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - GROUP BY aa.name, aa.code,aa.id""" - cr = self._cr - cr.execute(sql) - fetched_data = cr.dictfetchall() - elif data.get('date_from') is False and data.get('date_from') != False: - account_type_id = self.env.ref( - 'account.data_account_type_liquidity').id - state = """AND am.state = 'posted' """ if data.get( - 'level') == 'posted' else '' - sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit, - sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance - FROM (SELECT am.* FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str( - data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' """ + state + """) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - GROUP BY aa.name, aa.code,aa.id""" - cr = self._cr - cr.execute(sql) - fetched_data = cr.dictfetchall() - - elif data.get('date_to') == " ": - account_type_id = self.env.ref( - 'account.data_account_type_liquidity').id - state = """AND am.state = 'posted' """ if data.get( - 'level') == 'posted' else '' - sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit, - sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance - FROM (SELECT am.* FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str( - data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' """ + state + """) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - GROUP BY aa.name, aa.code,aa.id""" - cr = self._cr - cr.execute(sql) - fetched_data = cr.dictfetchall() - - elif data.get('level') == 'consolidated': - state = """ WHERE am.state = 'posted' """ if data.get('level') == 'posted' else '' - query2 = """SELECT aat.name, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, - sum(aml.balance) AS total_balance FROM ( SELECT am.id, am.state FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str(data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' ) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - """ + state + """GROUP BY aat.name""" - cr = self._cr - cr.execute(query2) - fetched_data = cr.dictfetchall() - elif data.get('level') == 'detailed': - state = """ WHERE am.state = 'posted' """ if data.get('level') == 'posted' else '' - query1 = """SELECT aa.id,aa.name,aa.code, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, - sum(aml.balance) AS total_balance FROM (SELECT am.id, am.state FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str( - data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' ) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - """ + state + """GROUP BY aa.name, aa.code, aa.id""" - cr = self._cr - cr.execute(query1) - fetched_data = cr.dictfetchall() - for account in self.env['account.account'].search([]): - child_lines = self.get_journal_lines(account, data) - if child_lines: - journal_res.append(child_lines) - - else: - account_type_id = self.env.ref( - 'account.data_account_type_liquidity').id - state = """AND am.state = 'posted' """ if data.get('level') == 'posted' else '' - sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit, - sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance - FROM (SELECT am.* FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str( - data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' """ + state + """) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - GROUP BY aa.name, aa.code,aa.id""" - cr = self._cr - cr.execute(sql) - fetched_data = cr.dictfetchall() - for account in self.env['account.account'].search([]): - child_lines = self._get_lines(account, data) - if child_lines: - account_res.append(child_lines) - journals = self.get_journal_lines(account, data) - if journals: - journal_res.append(journals) - - return { - 'date_from': data.get('date_from'), - 'date_to': data.get('date_to'), - 'levels': data.get('level'), - 'doc_ids': self.ids, - 'doc_model': model, - 'fetched_data': fetched_data, - 'account_res': account_res, - 'journal_res': journal_res, - 'fetched': fetched, - 'company_currency_id': currency, - 'company_currency_symbol': symbol, - 'company_currency_position': position, - } - - def _get_lines(self, account, data): - account_type_id = self.env.ref( - 'account.data_account_type_liquidity').id - state = """AND am.state = 'posted' """ if data.get('target_moves') == 'posted' else '' - query = """SELECT aml.account_id,aj.id as j_id,aj.name,am.id, am.name as move_name, sum(aml.debit) AS total_debit, - sum(aml.credit) AS total_credit, COALESCE(SUM(aml.debit - aml.credit),0) AS balance FROM (SELECT am.* FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str( - data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' """ + state + """) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_journal aj ON aj.id = am.journal_id - WHERE aa.id = """ + str(account.id) + """ - GROUP BY am.name, aml.account_id, aj.id, aj.name, am.id""" - - cr = self._cr - cr.execute(query) - fetched_data = cr.dictfetchall() - - sql2 = """SELECT aa.name as account_name,aa.id as account_id, aj.id, aj.name, sum(aml.debit) AS total_debit, - sum(aml.credit) AS total_credit, sum(aml.balance) AS total_balance FROM (SELECT am.* FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str( - data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str( - account_type_id) + """' """ + state + """) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_journal aj ON aj.id = am.journal_id - WHERE aa.id = """ + str( - account.id) + """ - GROUP BY aa.name, aj.name, aj.id,aa.id""" - - cr = self._cr - cr.execute(sql2) - fetch_data = cr.dictfetchall() - if fetched_data: - return { - 'account': account.name, - 'id': account.id, - 'code': account.code, - 'move_lines': fetched_data, - 'journal_lines': fetch_data, - } - - def get_xlsx_report(self, data, response, report_data, dfr_data): - report_data = json.loads(report_data) - data = json.loads(data) - output = io.BytesIO() - workbook = xlsxwriter.Workbook(output, {'in_memory': True}) - fetched_data = [] - account_res = [] - journal_res = [] - fetched = [] - account_type_id = self.env.ref('account.data_account_type_liquidity').id - currency_symbol = self.env.user.company_id.currency_id.symbol - - if data['levels'] == 'summary': - state = """ WHERE am.state = 'posted' """ if data.get('target_move') == 'posted' else '' - query3 = """SELECT to_char(am.date, 'Month') as month_part, extract(YEAR from am.date) as year_part, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, - sum(aml.balance) AS total_balance FROM (SELECT am.date, am.id, am.state FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str(data.get('date_from')) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str(account_type_id) + """' ) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - """ + state + """GROUP BY month_part,year_part""" - cr = self._cr - cr.execute(query3) - fetched_data = cr.dictfetchall() - - elif data['levels'] == 'consolidated': - state = """ WHERE am.state = 'posted' """ if data.get('target_move') == 'posted' else '' - query2 = """SELECT aat.name, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, - sum(aml.balance) AS total_balance FROM ( SELECT am.id, am.state FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str(data['date_from']) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str(account_type_id) + """' ) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - """ + state + """GROUP BY aat.name""" - cr = self._cr - cr.execute(query2) - fetched_data = cr.dictfetchall() - elif data['levels'] == 'detailed': - state = """ WHERE am.state = 'posted' """ if data.get('target_move') == 'posted' else '' - query1 = """SELECT aa.name,aa.code, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, - sum(aml.balance) AS total_balance FROM (SELECT am.id, am.state FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str(data['date_from']) + """' and '""" + str( - data['date_to']) + """' AND aat.id='""" + str(account_type_id) + """' ) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - """ + state + """GROUP BY aa.name, aa.code""" - cr = self._cr - cr.execute(query1) - fetched_data = cr.dictfetchall() - for account in self.env['account.account'].search([]): - child_lines = self.get_journal_lines(account, data) - if child_lines: - journal_res.append(child_lines) - - else: - - account_type_id = self.env.ref('account.data_account_type_liquidity').id - state = """AND am.state = 'posted' """ if data.get('target_move') == 'posted' else '' - sql = """SELECT DISTINCT aa.name,aa.code, sum(aml.debit) AS total_debit, - sum(aml.credit) AS total_credit FROM (SELECT am.* FROM account_move as am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - WHERE am.date BETWEEN '""" + str(data['date_from']) + """' and '""" + str( - data.get('date_to')) + """' AND aat.id='""" + str(account_type_id) + """' """ + state + """) am - LEFT JOIN account_move_line aml ON aml.move_id = am.id - LEFT JOIN account_account aa ON aa.id = aml.account_id - LEFT JOIN account_account_type aat ON aat.id = aa.user_type_id - GROUP BY aa.name, aa.code""" - - cr = self._cr - cr.execute(sql) - fetched = cr.dictfetchall() - for account in self.env['account.account'].search([]): - child_lines = self._get_lines(account, data) - if child_lines: - account_res.append(child_lines) - logged_users = self.env['res.company']._company_default_get('account.account') - sheet = workbook.add_worksheet() - bold = workbook.add_format({'align': 'center', - 'bold': True, - 'font_size': '10px', - 'border': 1}) - date = workbook.add_format({'font_size': '10px'}) - cell_format = workbook.add_format({'bold': True, - 'font_size': '10px'}) - head = workbook.add_format({'align': 'center', - 'bold': True, - 'bg_color': '#D3D3D3', - 'font_size': '15px'}) - txt = workbook.add_format({'align': 'left', - 'font_size': '10px'}) - txt_left = workbook.add_format({'align': 'left', - 'font_size': '10px', - 'border': 1}) - txt_center = workbook.add_format({'align': 'center', - 'font_size': '10px', - 'border': 1}) - amount = workbook.add_format({'align': 'right', - 'font_size': '10px', - 'border': 1}) - amount_bold = workbook.add_format({'align': 'right', - 'bold': True, - 'font_size': '10px', - 'border': 1}) - txt_bold = workbook.add_format({'align': 'left', - 'bold': True, - 'font_size': '10px', - 'border': 1}) - - sheet.set_column('C:C', 30, cell_format) - sheet.set_column('D:E', 20, cell_format) - sheet.set_column('F:F', 20, cell_format) - sheet.merge_range('C3:F5', '') - sheet.merge_range('C3:F4', 'CASH FLOW STATEMENTS', head) - sheet.merge_range('C4:F4', '') - - sheet.write('D6', "Date From", cell_format) - sheet.write('E6', str(data['date_from']), date) - sheet.write('D7', "Date To", cell_format) - sheet.write('E7', str(data['date_to']), date) - if data['levels']: - sheet.write('D9', "Level", cell_format) - sheet.write('E9', data.get("levels"), date) - sheet.write('D8', "Target Moves", cell_format) - sheet.write('E8', report_data.get("target_moves"), date) - sheet.write('C11', 'NAME', bold) - sheet.write('D11', 'CASH IN', bold) - sheet.write('E11', 'CASH OUT', bold) - sheet.write('F11', 'BALANCE', bold) - - row_num = 8 - col_num = 2 - fetched_data_list = fetched_data.copy() - account_res_list = account_res.copy() - journal_res_list = journal_res.copy() - fetched_list = fetched.copy() - - for i_rec in fetched_data_list: - if data['levels'] == 'summary': - sheet.write(row_num + 1, col_num, str(i_rec['month_part']) + str(int(i_rec['year_part'])), txt_left) - sheet.write(row_num + 1, col_num + 1, str(i_rec['total_debit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 2, str(i_rec['total_credit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 3, str(i_rec['total_debit'] - i_rec['total_credit']) + str(currency_symbol), - amount) - row_num = row_num + 1 - elif data['levels'] == 'consolidated': - sheet.write(row_num + 1, col_num, i_rec['name'], txt_left) - sheet.write(row_num + 1, col_num + 1, str(i_rec['total_debit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 2, str(i_rec['total_credit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 3, str(i_rec['total_debit'] - i_rec['total_credit']) + str(currency_symbol), - amount) - row_num = row_num + 1 - - for j_rec in journal_res_list: - for k in fetched_data_list: - if k['name'] == j_rec['account']: - sheet.write(row_num + 1, col_num, str(k['code']) + str(k['name']), txt_bold) - sheet.write(row_num + 1, col_num + 1, str(k['total_debit']) + str(currency_symbol), amount_bold) - sheet.write(row_num + 1, col_num + 2, str(k['total_credit']) + str(currency_symbol), amount_bold) - sheet.write(row_num + 1, col_num + 3, - str(k['total_debit'] - k['total_credit']) + str(currency_symbol), amount_bold) - row_num = row_num + 1 - for l_jrec in j_rec['journal_lines']: - sheet.write(row_num + 1, col_num, l_jrec['name'], txt_left) - sheet.write(row_num + 1, col_num + 1, str(l_jrec['total_debit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 2, str(l_jrec['total_credit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 3, str(l_jrec['total_debit'] - l_jrec['total_credit']) + str(currency_symbol), - amount) - row_num = row_num + 1 - - for j_rec in account_res_list: - for k in fetched_list: - if k['name'] == j_rec['account']: - sheet.write(row_num + 1, col_num, str(k['code']) + str(k['name']), txt_bold) - sheet.write(row_num + 1, col_num + 1, str(k['total_debit']) + str(currency_symbol), amount_bold) - sheet.write(row_num + 1, col_num + 2, str(k['total_credit']) + str(currency_symbol), amount_bold) - sheet.write(row_num + 1, col_num + 3, - str(k['total_debit'] - k['total_credit']) + str(currency_symbol), amount_bold) - row_num = row_num + 1 - for l_jrec in j_rec['journal_lines']: - if l_jrec['account_name'] == j_rec['account']: - sheet.write(row_num + 1, col_num, l_jrec['name'], txt_left) - sheet.write(row_num + 1, col_num + 1, str(l_jrec['total_debit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 2, str(l_jrec['total_credit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 3, - str(l_jrec['total_debit'] - l_jrec['total_credit']) + str(currency_symbol), - amount) - row_num = row_num + 1 - for m_rec in j_rec['move_lines']: - if m_rec['name'] == l_jrec['name']: - sheet.write(row_num + 1, col_num, m_rec['move_name'], txt_center) - sheet.write(row_num + 1, col_num + 1, str(m_rec['total_debit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 2, str(m_rec['total_credit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 3, - str(m_rec['total_debit'] - m_rec['total_credit']) + str(currency_symbol), - amount) - row_num = row_num + 1 - - workbook.close() - output.seek(0) - response.stream.write(output.read()) - output.close() \ No newline at end of file diff --git a/dynamic_financial_report/wizard/day_book.py b/dynamic_financial_report/wizard/day_book.py deleted file mode 100644 index 563626291..000000000 --- a/dynamic_financial_report/wizard/day_book.py +++ /dev/null @@ -1,518 +0,0 @@ -from datetime import datetime - -from odoo import models, fields, api -import io -import json -import datetime -from odoo.http import request -from odoo.tools import date_utils - -try: - from odoo.tools.misc import xlsxwriter -except ImportError: - import xlsxwriter -FETCH_RANGE = 2500 - - -class DayBook(models.TransientModel): - _name = "dynamic.day.book" - - journal_ids = fields.Many2many( - "account.journal", - string="Journals", - ) - account_ids = fields.Many2many( - "account.account", - string="Accounts", - ) - - company_id = fields.Many2one( - "res.company", - string="Company", - ) - entries = fields.Selection([('posted', 'All Posted Entries'), - ('all', 'All Entries')], string='Target Moves', - default='all') - - date_from = fields.Date( - string="Start date", - ) - date_to = fields.Date( - string="End date", - ) - - include_details = fields.Boolean(string="Include Details", default=True) - - def report_data(self): - """ """ - cr = self.env.cr - - data = self.get_filters(default_filters={}) - - WHERE = '(1=1)' - company_id = self.env.user.company_id - company_domain = [('company_id', '=', company_id.id)] - if data.get('account_ids', []): - WHERE += ' AND a.id IN %s' % str( - tuple(data.get('account_ids')) + tuple([0])) - - if data.get('journal_ids'): - WHERE += ' AND j.id IN %s' % str( - tuple(data.get('journal_ids')) + tuple([0])) - - if data.get('entries') == 'posted': - WHERE += " AND m.state = 'posted'" - day_ids = self.env['account.move.line'].search([]) - - move_lines = { - x.date.strftime('%Y-%m-%d'): { - - 'date': x.date, - 'id': x.id, - 'lines': [], - 'days': [] - } for x in day_ids - } - - for day in day_ids: - - company_id = self.env.user.company_id - currency = day.company_id.currency_id or company_id.currency_id - symbol = currency.symbol - rounding = currency.rounding - position = currency.position - - opening_balance = 0 - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND l.date = '%s'" % day.date.strftime('%Y-%m-%d') - elif data.get('date_from'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') - WHERE_CURRENT += " AND l.date = '%s'" % day.date.strftime('%Y-%m-%d') - elif data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND l.date = '%s'" % day.date.strftime('%Y-%m-%d') - else: - WHERE_CURRENT = WHERE + " AND l.date = '%s'" % day.date.strftime('%Y-%m-%d') - # ORDER_BY_CURRENT = 'l.date' - sql = (''' - SELECT - l.date AS ldate, - l.account_id AS account_id, - l.id AS lid, - p.name AS partner_name, - m.name AS move_name, - l.name AS lname, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.debit - l.credit,0) AS balance, - COALESCE(l.amount_currency,0) AS amount_currency - FROM account_move_line l - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_move m ON (l.move_id=m.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - LEFT JOIN account_move i ON (m.id =i.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - --GROUP BY l.date,l.id,l.currency_id, l.debit_currency, l.credit_currency, l.ref, l.name, m.id, m.name, c.rounding, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ORDER BY l.date - ''') % (WHERE_CURRENT) - cr.execute(sql) - - current_lines = cr.dictfetchall() - - for row in current_lines: - current_balance = row['balance'] - row['balance'] = opening_balance + current_balance - opening_balance += current_balance - row['initial_bal'] = False - - WHERE_FULL = WHERE + " AND l.date = '%s'" % day.date.strftime('%Y-%m-%d') - sql = (''' - SELECT - COALESCE(SUM(l.debit),0) AS debit, - COALESCE(SUM(l.credit),0) AS credit, - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - ''') % WHERE_FULL - cr.execute(sql) - for row in cr.dictfetchall(): - row['ending_bal'] = True - row['initial_bal'] = False - - move_lines[day.date.strftime('%Y-%m-%d')]['lines'].append(row) - - move_lines[day.date.strftime('%Y-%m-%d')]['debit'] = row['debit'] - move_lines[day.date.strftime('%Y-%m-%d')]['credit'] = row['credit'] - move_lines[day.date.strftime('%Y-%m-%d')]['balance'] = row['balance'] - move_lines[day.date.strftime('%Y-%m-%d')]['company_currency_id'] = currency.id - move_lines[day.date.strftime('%Y-%m-%d')]['company_currency_symbol'] = symbol - move_lines[day.date.strftime('%Y-%m-%d')]['company_currency_precision'] = rounding - move_lines[day.date.strftime('%Y-%m-%d')]['company_currency_position'] = position - move_lines[day.date.strftime('%Y-%m-%d')]['count'] = len(current_lines) - - move_lines[day.date.strftime('%Y-%m-%d')]['pages'] = self.get_page_list( - len(current_lines)) - move_lines[day.date.strftime('%Y-%m-%d')]['single_page'] = True if len( - current_lines) <= FETCH_RANGE else False - - return move_lines - - def get_filters(self, default_filters={}): - """ shows filters """ - company_id = self.env.user.company_id - company_domain = [('company_id', '=', company_id.id)] - journals = self.journal_ids if self.journal_ids else self.env[ - 'account.journal'].search(company_domain) - accounts = self.account_ids if self.account_ids else self.env[ - 'account.account'].search(company_domain) - - filter_dict = { - 'journal_ids': self.journal_ids.ids, - 'account_ids': self.account_ids.ids, - 'entries': self.entries, - 'company_id': self.company_id.id, - 'date_from': self.date_from, - 'date_to': self.date_to, - 'journals_list': [(j.id, j.name) for j in journals], - 'accounts_list': [(a.id, a.name) for a in accounts], - - 'company_name': company_id and company_id.name, - } - filter_dict.update(default_filters) - - return filter_dict - - def process_filters(self): - ''' To show on report headers''' - - data = self.get_filters(default_filters={}) - - filters = {} - - if data.get('journal_ids'): - filters['journals'] = self.env['account.journal'].browse( - data.get('journal_ids')).mapped('code') - else: - filters['journals'] = ['All'] - - if data.get('account_ids', []): - filters['accounts'] = self.env['account.account'].browse( - data.get('account_ids', [])).mapped('code') - else: - filters['accounts'] = ['All'] - - if data.get('date_from', False): - filters['date_from'] = data.get('date_from') - if data.get('date_to', False): - filters['date_to'] = data.get('date_to') - - if data.get('entries'): - filters['entries'] = data.get('entries') - if data.get('include_details'): - filters['include_details'] = True - else: - filters['include_details'] = False - filters['company_id'] = '' - filters['journals_list'] = data.get('journals_list') - filters['accounts_list'] = data.get('accounts_list') - - filters['company_name'] = data.get('company_name') - - return filters - - def db_move_lines(self, offset=0, account=0, fetch_range=FETCH_RANGE): - """ shows sub lines ie,details of that particular day book""" - cr = self.env.cr - offset_count = offset * fetch_range - opening_balance = 0 - company_id = self.env.user.company_id - data = self.get_filters(default_filters={}) - lines = self.report_data() - dates = [] - for line in lines: - dates.append(lines.get(line).get('date').strftime("%Y-%m-%d")) - - WHERE = '(1=1)' - - WHERE_CURRENT = WHERE - WHERE_CURRENT += " AND l.id = %s" % account - if data.get('entries') == 'posted': - WHERE += " AND m.state = 'posted'" - if data.get('account_ids', []): - WHERE += ' AND a.id IN %s' % str( - tuple(data.get('account_ids')) + tuple([0])) - - if data.get('journal_ids'): - WHERE += ' AND j.id IN %s' % str( - tuple(data.get('journal_ids')) + tuple([0])) - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND l.id = %s" % account - elif data.get('date_from'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') - WHERE_CURRENT += " AND l.id = %s" % account - elif data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND l.id = %s" % account - - - else: - WHERE_CURRENT = WHERE + " AND l.id = %s" % account - - ORDER_BY_CURRENT = 'j.code,l.date, p.name, l.move_id' - move_lines = [] - sql = (''' - SELECT - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - GROUP BY j.code,l.date, p.name, l.move_id - ORDER BY %s - OFFSET %s ROWS - FETCH FIRST %s ROWS ONLY - ''') % (WHERE_CURRENT, ORDER_BY_CURRENT, 0, offset_count) - cr.execute(sql) - running_balance_list = cr.fetchall() - for running_balance in running_balance_list: - opening_balance += running_balance[0] - - sql = (''' - SELECT COUNT(*) - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - ''') % (WHERE) - cr.execute(sql) - count = cr.fetchone()[0] - - val = WHERE - - for line in lines: - sql = (''' - SELECT - - l.date AS ldate, - l.id AS lid, - l.account_id AS account_id, - j.code AS lcode, - l.currency_id, - --l.ref AS lref, - l.name AS lname, - m.id AS move_id, - m.name AS move_name, - c.symbol AS currency_symbol, - c.position AS currency_position, - c.rounding AS currency_precision, - cc.id AS company_currency_id, - cc.symbol AS company_currency_symbol, - cc.rounding AS company_currency_precision, - cc.position AS company_currency_position, - p.name AS partner_name, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.debit - l.credit,0) AS balance, - COALESCE(l.amount_currency,0) AS amount_currency - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - GROUP BY l.id, l.account_id, j.code,l.date, l.currency_id, l.amount_currency, l.name, m.id, m.name, c.rounding, cc.id, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ORDER BY %s - OFFSET %s ROWS - FETCH FIRST %s ROWS ONLY - ''') % (val, ORDER_BY_CURRENT, offset_count, fetch_range) - cr.execute(sql) - - for row in cr.dictfetchall(): - days = lines.get(row.get('ldate').strftime("%Y-%m-%d")) - if days: - if days.get('date'): - row['parent_id'] = days.get('date').strftime("%Y-%m-%d") - - move_lines.append(row) - - return count, offset_count, move_lines, dates - - def get_data(self): - """ shows complete data of day book""" - filters = self.process_filters() - account_lines = self.report_data() - - db_lines = self.db_move_lines() - - return filters, account_lines, db_lines - - def get_page_list(self, total_count): - - page_count = int(total_count / FETCH_RANGE) - if total_count % FETCH_RANGE: - page_count += 1 - return [i + 1 for i in range(0, int(page_count))] or [] - - def write(self, vals): - - if vals.get('journal_ids'): - vals.update( - {'journal_ids': [(4, j) for j in vals.get('journal_ids')]}) - - if vals.get('journal_ids') == []: - vals.update({'journal_ids': [(5,)]}) - - if vals.get('account_ids'): - vals.update( - {'account_ids': [(4, j) for j in vals.get('account_ids')]}) - if vals.get('account_ids') == []: - vals.update({'account_ids': [(5,)]}) - - return super(DayBook, self).write(vals) - - @api.model - def create(self, vals): - res = super(DayBook, self).create(vals) - return res - - def get_xlsx_report(self, data, response, report_data, dfr_data): - """ fetch xlsx report""" - i_data = str(data) - n_data = json.loads(i_data) - output = io.BytesIO() - value = json.loads(report_data) - - filters = json.loads(dfr_data) - - workbook = xlsxwriter.Workbook(output, {'in_memory': True}) - cell_format = workbook.add_format( - {'align': 'center', 'bold': True, 'bg_color': '#d3d3d3;', - 'border': 1}) - - sheet = workbook.add_worksheet() - head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '20px'}) - - txt = workbook.add_format({'font_size': '10px', 'border': 1}) - sub_heading_sub = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '10px', - 'border': 2, - 'border_color': 'black'}) - sheet.merge_range('B2:G3', - self.env.user.company_id.name + ':' + ' Day Book', - head) - date_head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '10px'}) - - if filters.get('date_from'): - sheet.merge_range('A4:C4', - 'From Date: ' + filters.get('date_from'), - date_head) - if filters.get('date_to'): - sheet.merge_range('D4:E4', 'To Date: ' + filters.get('date_to'), - date_head) - - sheet.merge_range('F4:G4', 'Target Moves: ' + filters.get('entries'), - date_head) - - sheet.merge_range('B5:D5', ' Journals: ' + ', '.join( - [lt or '' for lt in - filters['journals']]), date_head) - sheet.merge_range('E5:F5', ' Accounts: ' + ', '.join( - [lt or '' for lt in - filters['accounts']]), - date_head) - sheet.merge_range('A6:E6', 'Date', cell_format) - sheet.write('F6', 'Debit', cell_format) - sheet.write('G6', 'Credit', cell_format) - sheet.write('H6', 'Balance', cell_format) - - lst = [] - for rec in n_data: - lst.append(rec) - row = 5 - col = 0 - row_1 = 5 - sheet.set_column(2, 2, 20) - sheet.set_column(3, 3, 26) - sheet.set_column(4, 4, 26) - sheet.set_column(5, 5, 15) - sheet.set_column(6, 6, 15) - sheet.set_column(7, 7, 26) - sheet.set_column(8, 8, 15) - sheet.set_column(9, 9, 15) - sheet.set_column(6, 6, 15) - sheet.set_column(7, 7, 15) - - for l_rec in lst: - one_lst = [] - two_lst = [] - - if n_data[l_rec]['count']: - one_lst.append(n_data[l_rec]) - - sheet.merge_range(row + 1, col, row + 1, col + 4, - n_data[l_rec]['date'], sub_heading_sub) - sheet.write(row + 1, col + 5, n_data[l_rec]['debit'], sub_heading_sub) - sheet.write(row + 1, col + 6, n_data[l_rec]['credit'], sub_heading_sub) - sheet.write(row + 1, col + 7, n_data[l_rec]['balance'], sub_heading_sub) - - # - row += 2 - sheet.write(row, col, 'Date', cell_format) - sheet.write(row, col + 1, 'JRNL', cell_format) - sheet.write(row, col + 2, 'Partner', cell_format) - sheet.write(row, col + 3, 'Move', cell_format) - sheet.write(row, col + 4, 'Entry Label', cell_format) - sheet.write(row, col + 5, 'Debit', cell_format) - sheet.write(row, col + 6, 'Credit', cell_format) - sheet.write(row, col + 7, 'balance', cell_format) - - for r_rec in value: - if n_data[l_rec]['date'] == r_rec['ldate']: - row += 1 - sheet.write(row, col, r_rec['ldate'], txt) - sheet.write(row, col + 1, r_rec['lcode'], txt) - sheet.write(row, col + 2, r_rec['partner_name'], txt) - sheet.write(row, col + 3, r_rec['lname'], txt) - sheet.write(row, col + 4, r_rec['move_name'], txt) - sheet.write(row, col + 5, r_rec['debit'], txt) - sheet.write(row, col + 6, r_rec['credit'], txt) - sheet.write(row, col + 7, r_rec['balance'], txt) - - workbook.close() - output.seek(0) - response.stream.write(output.read()) - output.close() \ No newline at end of file diff --git a/dynamic_financial_report/wizard/dynamic_ledger_view.xml b/dynamic_financial_report/wizard/dynamic_ledger_view.xml deleted file mode 100644 index f8566e0ec..000000000 --- a/dynamic_financial_report/wizard/dynamic_ledger_view.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - General Ledger Report - dynamic.gl - - - Trial Balance Report - dynamic.tb - - - - - - - - - \ No newline at end of file diff --git a/dynamic_financial_report/wizard/dynamic_partner_ageing.xml b/dynamic_financial_report/wizard/dynamic_partner_ageing.xml deleted file mode 100644 index bd0f8a33b..000000000 --- a/dynamic_financial_report/wizard/dynamic_partner_ageing.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Partner Ageing Report - dynamic.al - - - - - \ No newline at end of file diff --git a/dynamic_financial_report/wizard/general_ledger.py b/dynamic_financial_report/wizard/general_ledger.py deleted file mode 100644 index 68bf6f600..000000000 --- a/dynamic_financial_report/wizard/general_ledger.py +++ /dev/null @@ -1,528 +0,0 @@ -from odoo import models, fields, api -import io -import json -from odoo.http import request -from odoo.tools import date_utils -try: - from odoo.tools.misc import xlsxwriter -except ImportError: - import xlsxwriter -FETCH_RANGE = 2000 - - -class GeneralLedger(models.TransientModel): - _name = "dynamic.general.ledger" - - journal_ids = fields.Many2many( - "account.journal", - string="Journals", - ) - account_ids = fields.Many2many( - "account.account", - string="Accounts", - ) - account_tag_ids = fields.Many2many("account.account.tag", string="Account Tags") - analytic_ids = fields.Many2many( - "account.analytic.account", string="Analytic Accounts" - ) - analytic_tag_ids = fields.Many2many("account.analytic.tag", string="Analytic Tags") - company_id = fields.Many2one( - "res.company", - string="Company", - ) - date_from = fields.Date( - string="Start date", - ) - date_to = fields.Date( - string="End date", - ) - include_details = fields.Boolean(string="Include Details", default=True) - - entries = fields.Selection([('posted', 'All Posted Entries'), - ('all', 'All Entries')], string='Target Moves', default='all') - - def report_data(self): - cr = self.env.cr - - data = self.get_filters(default_filters={}) - WHERE = '(1=1)' - company_id = self.env.user.company_id - company_domain = [('company_id', '=', company_id.id)] - if data.get('account_tag_ids', []): - company_domain.append(('tag_ids','in', data.get('account_tag_ids', []))) - if data.get('account_ids', []): - company_domain.append(('id','in', data.get('account_ids', []))) - account_ids = self.env['account.account'].search(company_domain) - - if data.get('journal_ids'): - WHERE += ' AND j.id IN %s' % str(tuple(data.get('journal_ids')) + tuple([0])) - - if data.get('analytic_ids'): - WHERE += ' AND anl.id IN %s' % str(tuple(data.get('analytic_ids')) + tuple([0])) - - if data.get('entries') == 'posted': - WHERE += " AND m.state = 'posted'" - - if data.get('analytic_tag_ids'): - WHERE += ' AND analtag.account_analytic_tag_id IN %s' % str( - tuple(data.get('analytic_tag_ids')) + tuple([0])) - - move_lines = { - x.code: { - 'name': x.name, - 'code': x.code, - 'id': x.id, - 'lines': [] - } for x in sorted(account_ids, key=lambda a: a.code) - } - for account in account_ids: - company_id = self.env.user.company_id - currency = account.company_id.currency_id or company_id.currency_id - symbol = currency.symbol - rounding = currency.rounding - position = currency.position - - opening_balance = 0 - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get('date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account.id - elif data.get('date_from'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') - WHERE_CURRENT += " AND a.id = %s" % account.id - elif data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account.id - else: - WHERE_CURRENT = WHERE + " AND a.id = %s" % account.id - ORDER_BY_CURRENT = 'l.date' - sql = (''' - SELECT - l.date AS ldate, - l.id AS lid, - j.code AS lcode, - p.name AS partner_name, - m.name AS move_name, - l.name AS lname, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.debit - l.credit,0) AS balance, - COALESCE(l.amount_currency,0) AS amount_currency - FROM account_move_line l - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON (analtag.account_move_line_id=l.id) - LEFT JOIN account_move m ON (l.move_id=m.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - LEFT JOIN account_move i ON (m.id =i.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - --GROUP BY l.id, l.account_id, j.code, l.currency_id, l.date,l.debit_currency, l.credit_currency, l.ref, l.name, m.id, m.name, c.rounding, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ORDER BY %s - ''') % (WHERE_CURRENT, ORDER_BY_CURRENT) - cr.execute(sql) - current_lines = cr.dictfetchall() - for row in current_lines: - row['initial_bal'] = False - row['ending_bal'] = False - - current_balance = row['balance'] - row['balance'] = opening_balance + current_balance - opening_balance += current_balance - row['initial_bal'] = False - - move_lines[account.code]['lines'].append(row) - WHERE_FULL = WHERE + " AND a.id = %s" % account.id - sql = (''' - SELECT - COALESCE(SUM(l.debit),0) AS debit, - COALESCE(SUM(l.credit),0) AS credit, - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - ''') % WHERE_FULL - cr.execute(sql) - for row in cr.dictfetchall(): - row['ending_bal'] = True - row['initial_bal'] = False - move_lines[account.code]['lines'].append(row) - move_lines[account.code]['debit'] = row['debit'] - move_lines[account.code]['credit'] = row['credit'] - move_lines[account.code]['balance'] = row['balance'] - move_lines[account.code]['company_currency_id'] = currency.id - move_lines[account.code]['company_currency_symbol'] = symbol - move_lines[account.code]['company_currency_precision'] = rounding - move_lines[account.code]['company_currency_position'] = position - move_lines[account.code]['count'] = len(current_lines) - move_lines[account.code]['pages'] = self.get_page_list(len(current_lines)) - move_lines[account.code]['single_page'] = True if len(current_lines) <= FETCH_RANGE else False - return move_lines - def get_filters(self, default_filters={}): - company_id = self.env.user.company_id - company_domain = [('company_id','=', company_id.id)] - journals = self.journal_ids if self.journal_ids else self.env['account.journal'].search(company_domain) - accounts = self.account_ids if self.account_ids else self.env['account.account'].search(company_domain) - account_tags = self.account_tag_ids if self.account_tag_ids else self.env['account.account.tag'].search([]) - analytics = self.analytic_ids if self.analytic_ids else self.env['account.analytic.account'].search( - company_domain) - analytic_tags = self.analytic_tag_ids if self.analytic_tag_ids else self.env[ - 'account.analytic.tag'].sudo().search( - ['|', ('company_id', '=', company_id.id), ('company_id', '=', False)]) - filter_dict = { - 'journal_ids': self.journal_ids.ids, - 'account_ids': self.account_ids.ids, - 'account_tag_ids': self.account_tag_ids.ids, - 'analytic_ids': self.analytic_ids.ids, - 'analytic_tag_ids': self.analytic_tag_ids.ids, - 'company_id': self.company_id.id, - 'date_from': self.date_from, - 'date_to': self.date_to, - 'entries': self.entries, - 'journals_list': [(j.id, j.name) for j in journals], - 'accounts_list': [(a.id, a.name) for a in accounts], - 'account_tag_list': [(a.id, a.name) for a in account_tags], - 'analytics_list': [(anl.id, anl.name) for anl in analytics], - 'analytic_tag_list': [(anltag.id, anltag.name) for anltag in analytic_tags], - 'company_name': company_id and company_id.name, - } - filter_dict.update(default_filters) - return filter_dict - - def process_filters(self): - ''' To show on report headers''' - - data = self.get_filters(default_filters={}) - filters = {} - - if data.get('journal_ids'): - filters['journals'] = self.env['account.journal'].browse(data.get('journal_ids')).mapped('code') - else: - filters['journals'] = ['All'] - - if data.get('account_ids', []): - filters['accounts'] = self.env['account.account'].browse(data.get('account_ids', [])).mapped('code') - else: - filters['accounts'] = ['All'] - if data.get('include_details'): - filters['include_details'] = True - else: - filters['include_details'] = False - - if data.get('entries'): - filters['entries'] = data.get('entries') - if data.get('date_from', False): - filters['date_from'] = data.get('date_from') - if data.get('date_to', False): - filters['date_to'] = data.get('date_to') - if data.get('company_id'): - filters['company_id'] = data.get('company_id') - else: - filters['company_id'] = '' - filters['account_tags'] = ['All'] - filters['analytics'] = ['All'] - filters['analytic_tags'] = ['All'] - filters['journals_list'] = data.get('journals_list') - filters['accounts_list'] = data.get('accounts_list') - filters['account_tag_list'] = data.get('account_tag_list') - filters['analytics_list'] = data.get('analytics_list') - filters['analytic_tag_list'] = data.get('analytic_tag_list') - filters['company_name'] = data.get('company_name') - - return filters - - def gl_move_lines(self, offset=0, account=0, fetch_range=FETCH_RANGE): - cr = self.env.cr - offset_count = offset * fetch_range - opening_balance = 0 - data = self.get_filters(default_filters={}) - WHERE = '(1=1)' - WHERE_CURRENT = WHERE - WHERE_CURRENT += " AND a.id = %s" % account - if data.get('entries') == 'posted': - WHERE += " AND m.state = 'posted'" - - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account - elif data.get('date_from'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') - WHERE_CURRENT += " AND a.id = %s" % account - elif data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account - - - else: - WHERE_CURRENT = WHERE + " AND a.id = %s" % account - - ORDER_BY_CURRENT = 'j.code, p.name, l.move_id, l.date' - move_lines = [] - sql = (''' - SELECT - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - GROUP BY j.code, p.name, l.move_id, l.date - ORDER BY %s - OFFSET %s ROWS - FETCH FIRST %s ROWS ONLY - ''') % (WHERE_CURRENT, ORDER_BY_CURRENT, 0, offset_count) - cr.execute(sql) - running_balance_list = cr.fetchall() - for running_balance in running_balance_list: - opening_balance += running_balance[0] - - sql = (''' - SELECT COUNT(*) - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - ''') % (WHERE_CURRENT) - cr.execute(sql) - count = cr.fetchone()[0] - - sql = (''' - SELECT - l.date AS ldate, - l.id AS lid, - l.account_id AS account_id, - j.code AS lcode, - l.currency_id, - --l.ref AS lref, - l.name AS lname, - m.id AS move_id, - m.name AS move_name, - c.symbol AS currency_symbol, - c.position AS currency_position, - c.rounding AS currency_precision, - cc.id AS company_currency_id, - cc.symbol AS company_currency_symbol, - cc.rounding AS company_currency_precision, - cc.position AS company_currency_position, - p.name AS partner_name, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.debit - l.credit,0) AS balance, - COALESCE(l.amount_currency,0) AS amount_currency - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - GROUP BY l.id, l.account_id, j.code, l.currency_id, l.amount_currency, l.name, m.id, m.name, c.rounding, cc.id, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ORDER BY %s - OFFSET %s ROWS - FETCH FIRST %s ROWS ONLY - ''') % (WHERE_CURRENT, ORDER_BY_CURRENT, offset_count, fetch_range) - cr.execute(sql) - for row in cr.dictfetchall(): - current_balance = row['balance'] - row['balance'] = opening_balance + current_balance - opening_balance += current_balance - row['initial_bal'] = False - move_lines.append(row) - - return count, offset_count, move_lines - - - def get_data(self): - filters = self.process_filters() - account_lines = self.report_data() - return filters, account_lines - - - def get_page_list(self, total_count): - - page_count = int(total_count / FETCH_RANGE) - if total_count % FETCH_RANGE: - page_count += 1 - return [i + 1 for i in range(0, int(page_count))] or [] - - def write(self, vals): - - if vals.get('journal_ids'): - vals.update({'journal_ids': [(4, j) for j in vals.get('journal_ids')]}) - if vals.get('journal_ids') == []: - vals.update({'journal_ids': [(5,)]}) - if vals.get('account_ids'): - vals.update({'account_ids': [(4, j) for j in vals.get('account_ids')]}) - if vals.get('account_ids') == []: - vals.update({'account_ids': [(5,)]}) - - if vals.get('account_tag_ids'): - vals.update({'account_tag_ids': [(4, j) for j in vals.get('account_tag_ids')]}) - if vals.get('account_tag_ids') == []: - vals.update({'account_tag_ids': [(5,)]}) - - if vals.get('analytic_ids'): - vals.update({'analytic_ids': [(4, j) for j in vals.get('analytic_ids')]}) - if vals.get('analytic_ids') == []: - vals.update({'analytic_ids': [(5,)]}) - - if vals.get('analytic_tag_ids'): - vals.update({'analytic_tag_ids': [(4, j) for j in vals.get('analytic_tag_ids')]}) - if vals.get('analytic_tag_ids') == []: - vals.update({'analytic_tag_ids': [(5,)]}) - return super(GeneralLedger, self).write(vals) - - @api.model - def create(self, vals): - res = super(GeneralLedger, self).create(vals) - return res - - def get_xlsx_report(self, data, response, report_data, dfr_data): - i_data = str(data) - n_data = json.loads(i_data) - filters = json.loads(report_data) - output = io.BytesIO() - workbook = xlsxwriter.Workbook(output, {'in_memory': True}) - sheet = workbook.add_worksheet() - head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '20px'}) - sub_heading = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '12px', - 'border': 1, - 'border_color': 'black'}) - sub_heading_sub = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '10px', - 'border': 2, - 'border_color': 'black'}) - sub_heading_total = workbook.add_format( - {'align': 'right', 'bold': True, 'font_size': '10px', - 'border': 2, - 'border_color': 'black'}) - sub_heading_main = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '10px', - 'border': 1, - 'border_color': 'black'}) - txt = workbook.add_format({'font_size': '10px', 'border': 1}) - sheet.merge_range('A2:J3', self.env.user.company_id.name + ':' + ' General Ledger', head) - date_head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '10px'}) - - if filters.get('date_from'): - sheet.merge_range('B4:C4', 'From: '+filters.get('date_from') , date_head) - if filters.get('date_to'): - sheet.merge_range('H4:I4', 'To: '+ filters.get('date_to'), date_head) - sheet.merge_range('A5:J6', ' Accounts: ' + ', '.join([ lt or '' for lt in filters['accounts'] ]) + ' Journals: ' + ', '.join([ lt or '' for lt in filters['journals'] ]) + ' Account Tags: ' + ', '.join([ lt or '' for lt in filters['account_tags'] ]) + ' Analytic Tags: ' + ', '.join([ lt or '' for lt in filters['analytic_tags'] ]) + ' Analytic: ' +', '.join([ at or '' for at in filters['analytics'] ]) + ' Entries: '+ filters.get('entries'), date_head) - - sheet.write('A8', 'Code', sub_heading) - sheet.write('B8', 'Amount', sub_heading) - sheet.write('C8', 'Date', sub_heading) - sheet.write('D8', 'JRNL', sub_heading) - sheet.write('E8', 'Partner', sub_heading) - sheet.write('F8', 'Move', sub_heading) - sheet.write('G8', 'Entry Label', sub_heading) - sheet.write('H8', 'Debit', sub_heading) - sheet.write('I8', 'Credit', sub_heading) - sheet.write('J8', 'Balance', sub_heading) - lst = [] - for rec in n_data: - lst.append(rec) - row = 6 - col = 0 - row_1 = 5 - sheet.set_column(8, 0, 15) - sheet.set_column('B:B', 40) - sheet.set_column(8, 2, 15) - sheet.set_column(8, 3, 15) - sheet.set_column(8, 4, 15) - sheet.set_column(8, 5, 15) - sheet.set_column(8, 6, 50) - sheet.set_column(8, 7, 26) - sheet.set_column(8, 8, 15) - sheet.set_column(8, 9, 15) - for l_list in lst: - one_lst = [] - two_lst = [] - - if n_data[l_list]['count']: - - one_lst.append(n_data[l_list]) - row += 1 - row_1 += 1 - sheet.write(row +1, col, n_data[l_list]['code'], sub_heading_sub) - sheet.write(row +1, col + 1, n_data[l_list]['name'], sub_heading_sub) - sheet.write(row + 1, col + 2, '', sub_heading_sub) - sheet.write(row + 1, col + 3, '', sub_heading_sub) - sheet.write(row + 1, col + 4, '', sub_heading_sub) - sheet.write(row + 1, col + 5, '', sub_heading_sub) - sheet.write(row + 1, col + 6, '', sub_heading_sub) - - sheet.write(row +1, col + 7, n_data[l_list]['debit'], sub_heading_total) - sheet.write(row +1, col + 8, n_data[l_list]['credit'], sub_heading_total) - sheet.write(row +1, col + 9, n_data[l_list]['balance'], sub_heading_total) - - for rec_1 in n_data[l_list]['lines']: - row_1 += 1 - row += 1 - if rec_1['initial_bal']: - sheet.write(row +1, col, 'Initial Balance', sub_heading_main) - sheet.write(row + 1, col + 1, '', txt) - sheet.write(row + 1, col + 2, '', txt) - sheet.write(row + 1, col + 3, '', txt) - sheet.write(row + 1, col + 4, '', txt) - sheet.write(row + 1, col + 5, '', txt) - sheet.write(row + 1, col + 6, '', txt) - sheet.write(row +1, col + 7, n_data[l_list]['debit'], txt) - sheet.write(row +1, col + 8, n_data[l_list]['credit'], txt) - sheet.write(row +1, col + 9, n_data[l_list]['balance'], txt) - if not rec_1['initial_bal'] and not rec_1['ending_bal']: - sheet.write(row + 1, col , '', txt) - sheet.write(row + 1, col + 1, '', txt) - sheet.write(row +1, col + 2, rec_1.get('ldate'), txt) - sheet.write(row +1, col + 3, rec_1.get('lcode'), txt) - sheet.write(row +1, col + 4, rec_1.get('partner_name'), txt) - sheet.write(row +1, col + 5, rec_1.get('move_name'), txt) - sheet.write(row +1, col + 6, rec_1.get('lname'), txt) - sheet.write(row +1, col + 7, rec_1.get('debit'), txt) - sheet.write(row +1, col + 8, rec_1.get('credit'), txt) - sheet.write(row +1, col + 9, rec_1.get('balance'), txt) - if rec_1['ending_bal']: - sheet.write(row +1, col, 'Ending Balance', sub_heading_main) - sheet.write(row + 1, col + 1, '', txt) - sheet.write(row + 1, col + 2, '', txt) - sheet.write(row + 1, col + 3, '', txt) - sheet.write(row + 1, col + 4, '', txt) - sheet.write(row + 1, col + 5, '', txt) - sheet.write(row + 1, col + 6, '', txt) - sheet.write(row +1, col + 7, n_data[l_list]['debit'], txt) - sheet.write(row +1, col + 8, n_data[l_list]['credit'], txt) - sheet.write(row +1, col + 9, n_data[l_list]['balance'], txt) - workbook.close() - output.seek(0) - response.stream.write(output.read()) - output.close() diff --git a/dynamic_financial_report/wizard/partner_ledger.py b/dynamic_financial_report/wizard/partner_ledger.py deleted file mode 100644 index 74a61948d..000000000 --- a/dynamic_financial_report/wizard/partner_ledger.py +++ /dev/null @@ -1,610 +0,0 @@ -import io -import json -from odoo import models, fields, api - -try: - from odoo.tools.misc import xlsxwriter -except ImportError: - import xlsxwriter -FETCH_RANGE = 2000 - - -class PartnerLedger(models.TransientModel): - _name = "dynamic.partner.ledger" - journal_ids = fields.Many2many( - "account.journal", - string="Journals", - ) - account_ids = fields.Many2many( - "account.account", - string="Accounts", - ) - company_id = fields.Many2one( - "res.company", - string="Company", - ) - date_from = fields.Date( - string="Start date", - ) - date_to = fields.Date( - string="End date", - ) - partner_ids = fields.Many2many('res.partner', string='Partner') - partner_category_ids = fields.Many2many('res.partner.category', - string='Partner_tags') - include_details = fields.Boolean(string="Include Details", default=True) - reconciled = fields.Selection([ - ('unreconciled', 'Unreconciled Only')], - string='Reconcile Type') - type = fields.Selection( - [('receivable', 'Receivable Only'), - ('payable', 'Payable only')], - string='Account Type', required=False - ) - target_moves = fields.Selection( - [('all_entries', 'All entries'), - ('posted_only', 'Posted Only')], string='Target Moves', - default='all_entries' - ) - - def process_filters(self): - # To show on report headers - - data = self.get_filters(default_filters={}) - filters = {} - if data.get('partner_ids', []): - filters['partners'] = self.env['res.partner'].browse( - data.get('partner_ids', [])).mapped('name') - else: - filters['partners'] = ['All'] - - if data.get('journal_ids', []): - filters['journals'] = self.env['account.journal'].browse( - data.get('journal_ids', [])).mapped('code') - else: - filters['journals'] = ['All'] - if data.get('account_ids', []): - filters['accounts'] = self.env['account.account'].browse( - data.get('account_ids', [])).mapped('code') - else: - filters['accounts'] = ['All Payable and Receivable'] - - if data.get('partner_category_ids', []): - filters['categories'] = self.env['res.partner.category'].browse( - data.get('partner_category_ids', [])).mapped('name') - else: - filters['categories'] = ['All'] - - if data.get('date_from', False): - filters['date_from'] = data.get('date_from') - if data.get('date_to', False): - filters['date_to'] = data.get('date_to') - - if data.get('reconciled') == 'unreconciled': - filters['reconciled'] = 'Uneconciled' - - if data.get('target_moves') == 'all_entries': - filters['target_moves'] = 'All Entries' - else: - filters['target_moves'] = 'Posted Only' - - if data.get('type') == 'receivable': - filters['type'] = 'Receivable' - elif data.get('type') == 'payable': - filters['type'] = 'Payable' - else: - filters['type'] = 'Receivable and Payable' - - if data.get('company_id'): - filters['company_id'] = data.get('company_id') - else: - filters['company_id'] = '' - - if data.get('include_details'): - filters['include_details'] = True - else: - filters['include_details'] = False - - filters['journals_list'] = data.get('journals_list') - filters['accounts_list'] = data.get('accounts_list') - filters['partners_list'] = data.get('partners_list') - filters['category_list'] = data.get('category_list') - filters['company_name'] = data.get('company_name') - - return filters - - def get_filters(self, default_filters={}): - company_id = self.env.user.company_id - company_domain = [('company_id', '=', company_id.id)] - account_domain = [('company_id', '=', company_id.id), ( - 'user_type_id.type', 'in', ('receivable', 'payable'))] - partner_company_domain = [('parent_id', '=', False), - '|', - ('company_id', '=', company_id.id), - ('company_id', '=', False)] - - journals = self.journal_ids if self.journal_ids else self.env[ - 'account.journal'].search(company_domain) - accounts = self.account_ids if self.account_ids else self.env[ - 'account.account'].search(account_domain) - partners = self.partner_ids if self.partner_ids else self.env[ - 'res.partner'].search(partner_company_domain) - categories = self.partner_category_ids if self.partner_category_ids else \ - self.env['res.partner.category'].search([]) - - filter_dict = { - 'journal_ids': self.journal_ids.ids, - 'account_ids': self.account_ids.ids, - 'partner_ids': self.partner_ids.ids, - 'partner_category_ids': self.partner_category_ids.ids, - 'company_id': self.company_id and self.company_id.id or False, - 'date_from': self.date_from, - 'date_to': self.date_to, - 'reconciled': self.reconciled, - 'type': self.type, - 'target_moves': self.target_moves, - 'journals_list': [(j.id, j.name) for j in journals], - 'accounts_list': [(a.id, a.name) for a in accounts], - 'partners_list': [(p.id, p.name) for p in partners], - 'category_list': [(c.id, c.name) for c in categories], - 'company_name': self.company_id and self.company_id.name, - } - filter_dict.update(default_filters) - return filter_dict - - def get_data(self): - filters = self.process_filters() - account_lines = self.report_data() - return filters, account_lines - - def get_page_list(self, total_count): - page_count = int(total_count / FETCH_RANGE) - if total_count % FETCH_RANGE: - page_count += 1 - return [i + 1 for i in range(0, int(page_count))] or [] - - @api.model - def create(self, vals): - ret = super(PartnerLedger, self).create(vals) - return ret - - def write(self, vals): - - if vals.get('journal_ids'): - vals.update( - {'journal_ids': [(4, j) for j in vals.get('journal_ids')]}) - if vals.get('journal_ids') == []: - vals.update({'journal_ids': [(5,)]}) - - if vals.get('account_ids'): - vals.update( - {'account_ids': [(4, j) for j in vals.get('account_ids')]}) - if vals.get('account_ids') == []: - vals.update({'account_ids': [(5,)]}) - if vals.get('partner_ids'): - vals.update( - {'partner_ids': [(4, j) for j in vals.get('partner_ids')]}) - if vals.get('partner_ids') == []: - vals.update({'partner_ids': [(5,)]}) - - if vals.get('partner_category_ids'): - vals.update({'partner_category_ids': [(4, j) for j in vals.get( - 'partner_category_ids')]}) - if vals.get('partner_category_ids') == []: - vals.update({'partner_category_ids': [(5,)]}) - - ret = super(PartnerLedger, self).write(vals) - return ret - - def report_data(self): - # Summary details of each partner - cr = self.env.cr - data = self.get_filters(default_filters={}) - WHERE = '1=1' - company_id = self.env.user.company_id - partner_company_domain = [('parent_id', '=', False), - '|', - ('company_id', '=', company_id.id), - ('company_id', '=', False)] - if self.partner_category_ids: - partner_company_domain.append( - ('category_id', 'in', self.partner_category_ids.ids)) - - if data.get('partner_ids', []): - partner_ids = self.env['res.partner'].browse( - data.get('partner_ids')) - else: - partner_ids = self.env['res.partner'].search(partner_company_domain) - - move_lines = { - x.id: { - 'name': x.name, - 'code': x.id, - 'id': x.id, - 'lines': [] - } for x in partner_ids - } - for partner in partner_ids: - company_id = self.env.user.company_id - currency = partner.company_id.currency_id or company_id.currency_id - symbol = currency.symbol - rounding = currency.rounding - position = currency.position - - opening_balance = 0.0 - type = ('receivable', 'payable') - if self.type: - type = tuple([self.type, 'none']) - WHERE += ' AND ty.type IN %s' % str(type) - - if data.get('reconciled') == 'unreconciled': - WHERE += ' AND l.amount_residual != 0' - - if data.get('journal_ids', []): - WHERE += ' AND j.id IN %s' % str( - tuple(data.get('journal_ids')) + tuple([0])) - - if data.get('account_ids', []): - WHERE += ' AND a.id IN %s' % str( - tuple(data.get('account_ids')) + tuple([0])) - - if data.get('partner_ids', []): - WHERE += ' AND p.id IN %s' % str( - tuple(data.get('partner_ids')) + tuple([0])) - - if data.get('company_id', False): - WHERE += ' AND l.company_id = %s' % data.get('company_id') - - if data.get('target_moves') == 'posted_only': - WHERE += " AND m.state = 'posted'" - - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND p.id = %s" % partner.id - elif data.get('date_from'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') - WHERE_CURRENT += " AND p.id = %s" % partner.id - elif data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND p.id = %s" % partner.id - else: - WHERE_CURRENT = WHERE + " AND p.id = %s" % partner.id - - ORDER_BY_CURRENT = 'l.date' - - sql = (''' - SELECT - l.date AS ldate, - l.id AS lid, - j.code AS lcode, - a.name AS account_name, - a.code AS account_code, - m.name AS move_name, - l.name AS lname, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.balance,0) AS balance, - COALESCE(l.amount_currency,0) AS balance_currency - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_account_type AS ty ON (a.user_type_id = ty.id ) - --LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - AND ty.type IN %s - --GROUP BY l.id, l.account_id, j.code, l.currency_id, l.amount_currency, l.ref, l.name, m.id, m.name, c.rounding, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ORDER BY %s - ''') % (WHERE_CURRENT, type, ORDER_BY_CURRENT) - cr.execute(sql) - current_lines = cr.dictfetchall() - for row in current_lines: - row['initial_bal'] = False - row['ending_bal'] = False - - current_balance = row['balance'] - row['balance'] = opening_balance + current_balance - opening_balance += current_balance - row['initial_bal'] = False - - move_lines[partner.id]['lines'].append(row) - WHERE_FULL = WHERE + " AND p.id = %s" % partner.id - sql = (''' - SELECT - COALESCE(SUM(l.debit),0) AS debit, - COALESCE(SUM(l.credit),0) AS credit, - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_account_type AS ty ON (a.user_type_id = ty.id ) - --LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - AND ty.type IN %s - ''') % (WHERE_FULL, type) - cr.execute(sql) - for row in cr.dictfetchall(): - if (data.get( - 'display_accounts') == 'balance_not_zero' and currency.is_zero( - row['debit'] - row['credit'])) \ - or (data.get('balance_less_than_zero') and ( - row['debit'] - row['credit']) > 0) \ - or (data.get('balance_greater_than_zero') and ( - row['debit'] - row['credit']) < 0): - move_lines.pop(partner.id, None) - else: - row['ending_bal'] = True - row['initial_bal'] = False - move_lines[partner.id]['lines'].append(row) - move_lines[partner.id]['debit'] = row['debit'] - move_lines[partner.id]['credit'] = row['credit'] - move_lines[partner.id]['balance'] = row['balance'] - move_lines[partner.id]['company_currency_id'] = currency.id - move_lines[partner.id]['company_currency_symbol'] = symbol - move_lines[partner.id][ - 'company_currency_precision'] = rounding - move_lines[partner.id][ - 'company_currency_position'] = position - move_lines[partner.id]['count'] = len(current_lines) - move_lines[partner.id]['pages'] = self.get_page_list( - len(current_lines)) - move_lines[partner.id]['single_page'] = True if len( - current_lines) <= FETCH_RANGE else False - - return move_lines - - def pl_move_lines(self, offset=0, partner=0, - fetch_range=FETCH_RANGE): - # To show detailed move lines as sub lines - cr = self.env.cr - data = self.get_filters(default_filters={}) - offset_count = offset * fetch_range - opening_balance = 0 - company_id = self.env.user.company_id - currency_id = company_id.currency_id - - WHERE = '1=1' - type = ('receivable', 'payable') - if data.get('type'): - type = tuple([self.type, 'none']) - WHERE += ' AND ty.type IN %s' % str(type) - - if data.get('reconciled') == 'unreconciled': - WHERE += ' AND l.full_reconcile_id is null AND' \ - ' l.balance != 0 AND a.reconcile is true' - - if data.get('journal_ids', []): - WHERE += ' AND j.id IN %s' % str( - tuple(data.get('journal_ids')) + tuple([0])) - - if data.get('account_ids', []): - WHERE += ' AND a.id IN %s' % str( - tuple(data.get('account_ids')) + tuple([0])) - - if data.get('partner_ids', []): - WHERE += ' AND p.id IN %s' % str( - tuple(data.get('partner_ids')) + tuple([0])) - - if data.get('company_id', False): - WHERE += ' AND l.company_id = %s' % data.get('company_id') - - if data.get('target_moves') == 'posted_only': - WHERE += " AND m.state = 'posted'" - - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND p.id = %s" % partner - elif data.get('date_from'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get( - 'date_from') - WHERE_CURRENT += " AND p.id = %s" % partner - elif data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND p.id = %s" % partner - elif not data.get('date_from') and not data.get('date_to'): - WHERE_CURRENT = WHERE + " AND p.id = %s" % partner - else: - WHERE_CURRENT = WHERE + " AND p.id = %s" % partner - ORDER_BY_CURRENT = 'l.date' - move_lines = [] - - sql = (''' - SELECT COUNT(*) - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_account_type AS ty ON (a.user_type_id = ty.id ) - --LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - AND ty.type IN %s - ''') % (WHERE_CURRENT, type) - cr.execute(sql) - count = cr.fetchone()[0] - - sql = (''' - SELECT - l.id AS lid, - l.account_id AS account_id, - l.partner_id AS partner_id, - l.date AS ldate, - j.code AS lcode, - l.currency_id, - l.amount_currency, - --l.ref AS lref, - l.name AS lname, - m.id AS move_id, - m.name AS move_name, - c.symbol AS currency_symbol, - c.position AS currency_position, - c.rounding AS currency_precision, - cc.id AS company_currency_id, - cc.symbol AS company_currency_symbol, - cc.rounding AS company_currency_precision, - cc.position AS company_currency_position, - p.name AS partner_name, - a.name AS account_name, - a.code AS account_code, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.debit - l.credit,0) AS balance, - COALESCE(l.amount_currency,0) AS amount_currency - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_account_type AS ty ON (a.user_type_id = ty.id) - --LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_currency cc ON (l.company_currency_id=cc.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - AND ty.type IN %s - GROUP BY l.id, l.partner_id,a.code, a.name, l.account_id, l.date, j.code, l.currency_id, l.amount_currency, l.name, m.id, m.name, c.rounding, cc.id, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ORDER BY %s - OFFSET %s ROWS - FETCH FIRST %s ROWS ONLY - ''') % ( - WHERE_CURRENT, type, ORDER_BY_CURRENT, offset_count, fetch_range) - cr.execute(sql) - - for row in cr.dictfetchall(): - move_lines.append(row) - - return count, offset_count, move_lines - - def get_xlsx_report(self, data, response, report_data, dfr_data): - i_data = str(data) - n_data = json.loads(i_data) - filters = json.loads(report_data) - - output = io.BytesIO() - workbook = xlsxwriter.Workbook(output, {'in_memory': True}) - cell_format = workbook.add_format( - {'align': 'center', 'bold': True, 'bg_color': '#d3d3d3;', - 'border': 1 - }) - sheet = workbook.add_worksheet() - head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '20px'}) - - txt = workbook.add_format({'font_size': '10px', 'border': 1}) - sub_heading_sub = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '10px', - 'border': 2, - 'border_color': 'black'}) - sheet.merge_range('A1:H2', - self.env.user.company_id.name + ':' + 'Partner Ledger', - head) - date_head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '10px'}) - - sheet.merge_range('A3:B3', - 'Target Moves: ' + filters.get('target_moves'), - date_head) - - sheet.merge_range('C3:D3', 'Account Type: ' + filters.get('type'), - date_head) - sheet.merge_range('E3:F3', ' Partners: ' + ', '.join( - [lt or '' for lt in - filters['partners']]), date_head) - sheet.merge_range('G3:H3', ' Partner Type: ' + ', '.join( - [lt or '' for lt in - filters['categories']]), - date_head) - sheet.merge_range('A4:B4', ' Journals: ' + ', '.join( - [lt or '' for lt in - filters['journals']]), - date_head) - sheet.merge_range('C4:D4', ' Accounts: ' + ', '.join( - [lt or '' for lt in - filters['accounts']]), - date_head) - - if filters.get('date_from') and filters.get('date_to'): - sheet.merge_range('E4:F4', 'From: ' + filters.get('date_from'), - date_head) - - sheet.merge_range('G4:H4', 'To: ' + filters.get('date_to'), - date_head) - elif filters.get('date_from'): - sheet.merge_range('E4:F4', 'From: ' + filters.get('date_from'), - date_head) - elif filters.get('date_to'): - sheet.merge_range('E4:F4', 'To: ' + filters.get('date_to'), - date_head) - - sheet.merge_range('A5:E5', 'Partner', cell_format) - sheet.write('F5', 'Debit', cell_format) - sheet.write('G5', 'Credit', cell_format) - sheet.write('H5', 'Balance', cell_format) - - lst = [] - for rec in n_data: - lst.append(rec) - row = 4 - col = 0 - - sheet.set_column(0, 0, 15) - sheet.set_column(1, 1, 15) - sheet.set_column(2, 2, 25) - sheet.set_column(3, 3, 15) - sheet.set_column(4, 4, 36) - sheet.set_column(5, 5, 15) - sheet.set_column(6, 6, 15) - sheet.set_column(7, 7, 15) - for l_list in lst: - one_lst = [] - two_lst = [] - - if n_data[l_list]['count']: - one_lst.append(n_data[l_list]) - two_lst = (n_data[l_list]['lines']) - two_lst.pop() - - row += 1 - sheet.merge_range(row, col + 0, row, col + 4, n_data[l_list]['name'], - sub_heading_sub) - sheet.write(row, col + 5, n_data[l_list]['debit'], sub_heading_sub) - sheet.write(row, col + 6, n_data[l_list]['credit'], sub_heading_sub) - sheet.write(row, col + 7, n_data[l_list]['balance'], sub_heading_sub) - row += 1 - sheet.write(row, col + 0, 'Date', cell_format) - sheet.write(row, col + 1, 'JRNL', cell_format) - sheet.write(row, col + 2, 'Account', cell_format) - sheet.write(row, col + 3, 'Move', cell_format) - sheet.write(row, col + 4, 'Entry Label', cell_format) - sheet.write(row, col + 5, 'Debit', cell_format) - sheet.write(row, col + 6, 'Credit', cell_format) - sheet.write(row, col + 7, 'Balance', cell_format) - for r_rec in two_lst: - row += 1 - sheet.write(row, col + 0, r_rec['ldate'], txt) - sheet.write(row, col + 1, r_rec['lcode'], txt) - sheet.write(row, col + 2, r_rec['account_code'], txt) - sheet.write(row, col + 3, r_rec['move_name'], txt) - sheet.write(row, col + 4, r_rec['lname'], txt) - sheet.write(row, col + 5, r_rec['debit'], txt) - sheet.write(row, col + 6, r_rec['credit'], txt) - sheet.write(row, col + 7, r_rec['balance'], txt) - - workbook.close() - output.seek(0) - response.stream.write(output.read()) - output.close() \ No newline at end of file diff --git a/dynamic_financial_report/wizard/partner_ledger_view.xml b/dynamic_financial_report/wizard/partner_ledger_view.xml deleted file mode 100644 index 3722d1558..000000000 --- a/dynamic_financial_report/wizard/partner_ledger_view.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Partner Ledger Report - dynamic.pl - - - - - - \ No newline at end of file diff --git a/dynamic_financial_report/wizard/trial_balance.py b/dynamic_financial_report/wizard/trial_balance.py deleted file mode 100644 index ad23baa09..000000000 --- a/dynamic_financial_report/wizard/trial_balance.py +++ /dev/null @@ -1,374 +0,0 @@ -from odoo import models, fields, api -import io -import json -try: - from odoo.tools.misc import xlsxwriter -except ImportError: - import xlsxwriter -FETCH_RANGE = 2000 - - -class TrialBalance(models.TransientModel): - _name = "dynamic.trial.balance" - - journal_ids = fields.Many2many( - "account.journal", - string="Journals", - ) - account_ids = fields.Many2many( - "account.account", - string="Accounts", - ) - analytic_ids = fields.Many2many( - "account.analytic.account", string="Analytic Accounts" - ) - company_id = fields.Many2one( - "res.company", - string="Company", - ) - date_from = fields.Date( - string="Start date", - ) - date_to = fields.Date( - string="End date", - ) - entries = fields.Selection([('posted', 'All Posted Entries'), - ('all', 'All Entries')], string='Target Moves', default='all') - include_details = fields.Boolean(string="Include Details", default=True) - - def report_data(self): - cr = self.env.cr - data = self.get_filters(default_filters={}) - WHERE = '(1=1)' - company_id = self.env.user.company_id - company_domain = [('company_id', '=', company_id.id)] - account_ids = self.env['account.account'].search(company_domain) - if data.get('journal_ids'): - WHERE += ' AND j.id IN %s' % str(tuple(data.get('journal_ids')) + tuple([0])) - if data.get('entries') == 'posted': - WHERE += " AND m.state = 'posted'" - - - if data.get('analytic_ids'): - WHERE += ' AND anl.id IN %s' % str(tuple(data.get('analytic_ids')) + tuple([0])) - move_lines = { - x.code: { - 'name': x.name, - 'code': x.code, - 'id': x.id, - 'lines': [], - - } for x in sorted(account_ids, key=lambda a: a.code) - - } - for account in account_ids: - company_id = self.env.user.company_id - currency = account.company_id.currency_id or company_id.currency_id - symbol = currency.symbol - rounding = currency.rounding - position = currency.position - - opening_balance = 0 - - WHERE_INIT = WHERE + " AND l.date < '%s'" % data.get('date_from') - WHERE_INIT += " AND l.account_id = %s" % account.id - if data.get('date_from'): - sql_b = (''' - SELECT - COALESCE(SUM(l.debit),0) AS debit, - COALESCE(SUM(l.credit),0) AS credit, - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - ''') % WHERE_INIT - cr.execute(sql_b) - bal = cr.dictfetchall() - for row in bal: - row['move_name'] = 'Initial Balance' - row['account_id'] = account.id - row['initial_bal'] = True - row['ending_bal'] = False - opening_balance += row['balance'] - move_lines[account.code]['lines'].append(row) - - if data.get('date_from') and data.get('date_to'): - WHERE_CURRENT = WHERE + " AND l.date >= '%s'" % data.get('date_from') + " AND l.date <= '%s'" % data.get( - 'date_to') - WHERE_CURRENT += " AND a.id = %s" % account.id - else: - WHERE_CURRENT = WHERE + " AND a.id = %s" % account.id - sql = (''' - SELECT - l.date AS ldate, - l.id AS lid, - j.code AS lcode, - p.name AS partner_name, - m.name AS move_name, - l.name AS lname, - COALESCE(l.debit,0) AS debit, - COALESCE(l.credit,0) AS credit, - COALESCE(l.debit - l.credit,0) AS balance, - COALESCE(l.amount_currency,0) AS amount_currency - FROM account_move_line l - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON (analtag.account_move_line_id=l.id) - LEFT JOIN account_move m ON (l.move_id=m.id) - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - LEFT JOIN account_move i ON (m.id =i.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - --GROUP BY l.id, l.account_id, j.code, l.currency_id, l.debit_currency, l.credit_currency, l.ref, l.name, m.id, m.name, c.rounding, cc.rounding, cc.position, c.position, c.symbol, cc.symbol, p.name - ''') % (WHERE_CURRENT) - - cr.execute(sql) - current_lines = cr.dictfetchall() - for row in current_lines: - row['initial_bal'] = False - row['ending_bal'] = False - - current_balance = row['balance'] - row['balance'] = opening_balance + current_balance - opening_balance += current_balance - row['initial_bal'] = False - - move_lines[account.code]['lines'].append(row) - WHERE_FULL = WHERE + " AND a.id = %s" % account.id - sql = (''' - SELECT - COALESCE(SUM(l.debit),0) AS debit, - COALESCE(SUM(l.credit),0) AS credit, - COALESCE(SUM(l.debit - l.credit),0) AS balance - FROM account_move_line l - JOIN account_move m ON (l.move_id=m.id) - JOIN account_account a ON (l.account_id=a.id) - LEFT JOIN account_analytic_account anl ON (l.analytic_account_id=anl.id) - LEFT JOIN account_analytic_tag_account_move_line_rel analtag ON analtag.account_move_line_id = l.id - LEFT JOIN res_currency c ON (l.currency_id=c.id) - LEFT JOIN res_partner p ON (l.partner_id=p.id) - JOIN account_journal j ON (l.journal_id=j.id) - WHERE %s - ''') % WHERE_FULL - cr.execute(sql) - - for row in cr.dictfetchall(): - row['ending_bal'] = True - row['initial_bal'] = False - move_lines[account.code]['lines'].append(row) - move_lines[account.code]['debit'] = row['debit'] - move_lines[account.code]['credit'] = row['credit'] - move_lines[account.code]['balance'] = row['balance'] - move_lines[account.code]['company_currency_id'] = currency.id - move_lines[account.code]['company_currency_symbol'] = symbol - move_lines[account.code]['company_currency_precision'] = rounding - move_lines[account.code]['company_currency_position'] = position - move_lines[account.code]['count'] = len(current_lines) - move_lines[account.code]['pages'] = self.get_page_list(len(current_lines)) - move_lines[account.code]['single_page'] = True if len(current_lines) <= FETCH_RANGE else False - - return move_lines - - def get_credit_debit_total(self): - move_line = self.report_data() - l_keys = move_line.keys() - debit = 0 - credit = 0 - currency_details = [] - for rec in l_keys: - single_line = move_line[rec] - if single_line['count']: - debit += single_line['debit'] - credit += single_line['credit'] - c_detail = { - 'currency': single_line['company_currency_id'], - 'symbol':single_line['company_currency_symbol'], - 'rounding':single_line['company_currency_precision'], - 'position':single_line['company_currency_position'], - - } - if c_detail not in currency_details: - currency_details.append(c_detail) - total = { - 'debit': debit, - 'credit':credit, - 'currency_details':currency_details - } - return total - - - @api.model - def get_filters(self, default_filters={}): - company_id = self.env.user.company_id - company_domain = [('company_id','=', company_id.id)] - journals = self.journal_ids if self.journal_ids else self.env['account.journal'].search(company_domain) - accounts = self.account_ids if self.account_ids else self.env['account.account'].search(company_domain) - analytics = self.analytic_ids if self.analytic_ids else self.env['account.analytic.account'].search( - company_domain) - - filter_dict = { - 'journal_ids': self.journal_ids.ids, - 'analytic_ids': self.analytic_ids.ids, - 'company_id': company_id.id, - 'date_from': self.date_from, - 'date_to': self.date_to, - 'entries':self.entries, - 'journals_list': [(j.id, j.name) for j in journals], - 'accounts_list': [(a.id, a.name) for a in accounts], - 'analytics_list': [(anl.id, anl.name) for anl in analytics], - 'company_name': company_id and company_id.name, - } - filter_dict.update(default_filters) - return filter_dict - - def process_filters(self): - ''' To show on report headers''' - data = self.get_filters(default_filters={}) - filters = {} - if data.get('journal_ids'): - filters['journals'] = self.env['account.journal'].browse(data.get('journal_ids')).mapped('code') - else: - filters['journals'] = ['All'] - if data.get('entries'): - filters['entries'] = data.get('entries') - if data.get('date_from'): - filters['date_from'] = data.get('date_from') - if data.get('date_to'): - filters['date_to'] = data.get('date_to') - - filters['analytics'] = ['All'] - filters['company_id'] = '' - filters['journals_list'] = data.get('journals_list') - filters['analytics_list'] = data.get('analytics_list') - filters['company_name'] = data.get('company_name') - - return filters - - def get_data(self): - filters = self.process_filters() - account_lines = self.report_data() - total = self.get_credit_debit_total() - return filters, account_lines, total - - - def get_page_list(self, total_count): - page_count = int(total_count / FETCH_RANGE) - if total_count % FETCH_RANGE: - page_count += 1 - return [i + 1 for i in range(0, int(page_count))] or [] - - def write(self, vals): - if vals.get('journal_ids'): - vals.update({'journal_ids': [(4, j) for j in vals.get('journal_ids')]}) - if vals.get('journal_ids') == []: - vals.update({'journal_ids': [(5,)]}) - if vals.get('account_ids'): - vals.update({'account_ids': [(4, j) for j in vals.get('account_ids')]}) - if vals.get('account_ids') == []: - vals.update({'account_ids': [(5,)]}) - if vals.get('analytic_ids'): - vals.update({'analytic_ids': [(4, j) for j in vals.get('analytic_ids')]}) - if vals.get('analytic_ids') == []: - vals.update({'analytic_ids': [(5,)]}) - return super(TrialBalance, self).write(vals) - - @api.model - def create(self, vals): - res = super(TrialBalance, self).create(vals) - return res - - - def get_xlsx_report(self, data, response ,report_data, dfr_data): - - i_data = str(data) - acount_line = json.loads(i_data) - total_sub = json.loads(report_data) - output = io.BytesIO() - total = json.loads(total_sub['d1']) - filters = json.loads(total_sub['d2']) - workbook = xlsxwriter.Workbook(output, {'in_memory': True}) - sheet = workbook.add_worksheet() - head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '20px'}) - sub_heading = workbook.add_format( - {'align': 'center', 'bold': True, 'font_size': '10px', - 'border': 1, - 'border_color': 'black'}) - txt = workbook.add_format({'font_size': '10px', 'border': 1}) - txt_l = workbook.add_format({'font_size': '10px', 'border': 1, 'bold': True}) - sheet.merge_range('A2:D3', self.env.user.company_id.name + ':' + ' Trial Balance', head) - date_head = workbook.add_format({'align': 'center', 'bold': True, - 'font_size': '10px'}) - date_style = workbook.add_format({'align': 'center', - 'font_size': '10px'}) - if filters.get('date_from'): - sheet.merge_range('A4:B4', 'From: '+filters.get('date_from') , date_head) - if filters.get('date_to'): - sheet.merge_range('C4:D4', 'To: '+ filters.get('date_to'), date_head) - sheet.merge_range('A5:D6', 'Journals: ' + ', '.join([ lt or '' for lt in filters['journals'] ]) + ' Analytic: ' +', '.join([ at or '' for at in filters['analytics'] ]) + ' Entries: '+ filters.get('entries'), date_head) - sheet.write('A7', 'Code', sub_heading) - sheet.write('B7', 'Amount', sub_heading) - if filters.get('date_from'): - sheet.write('C7', 'Initial Debit', sub_heading) - sheet.write('D7', 'Initial Credit', sub_heading) - sheet.write('E7', 'Debit', sub_heading) - sheet.write('F7', 'Credit', sub_heading) - else: - sheet.write('C7', 'Debit', sub_heading) - sheet.write('D7', 'Credit', sub_heading) - lst = [] - for rec in acount_line: - lst.append(rec) - row = 6 - col = 0 - sheet.set_column(5, 0, 15) - sheet.set_column(6, 1, 15) - sheet.set_column(7, 2, 26) - if filters.get('date_from'): - sheet.set_column(8, 3, 15) - sheet.set_column(9, 4, 15) - sheet.set_column(10, 5, 15) - sheet.set_column(11, 6, 15) - else: - - sheet.set_column(8, 3, 15) - sheet.set_column(9, 4, 15) - for l in lst: - one_lst = [] - two_lst = [] - - if acount_line[l]['count']: - one_lst.append(acount_line[l]) - - row += 1 - sheet.write(row, col, acount_line[l]['code'], txt) - sheet.write(row, col + 1, acount_line[l]['name'], txt) - if filters.get('date_from'): - for i_b in acount_line[l]['lines']: - if i_b['initial_bal']: - sheet.write(row, col + 2, i_b['debit'], txt) - sheet.write(row, col + 3, i_b['credit'], txt) - sheet.write(row, col + 4, acount_line[l]['debit'], txt) - sheet.write(row, col + 5, acount_line[l]['credit'], txt) - - else: - sheet.write(row, col + 2, acount_line[l]['debit'], txt) - sheet.write(row, col + 3, acount_line[l]['credit'], txt) - sheet.write(row+1, col, 'Total', sub_heading) - if filters.get('date_from'): - sheet.write(row + 1, col + 4, total['debit'], txt_l) - sheet.write(row + 1, col + 5, total['credit'], txt_l) - else: - sheet.write(row + 1, col + 2, total['debit'], txt_l) - sheet.write(row + 1, col + 3, total['credit'], txt_l) - - workbook.close() - output.seek(0) - response.stream.write(output.read()) - output.close()