From 1ca3b3df3421961caec3b747a364071c80f5c7da Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 17:14:58 +0700 Subject: initial commit --- base_accounting_kit/wizard/__init__.py | 37 ++ .../wizard/account_bank_book_wizard.py | 111 ++++++ .../wizard/account_bank_book_wizard_view.xml | 43 +++ .../wizard/account_cash_book_wizard.py | 111 ++++++ .../wizard/account_cash_book_wizard_view.xml | 43 +++ .../wizard/account_day_book_wizard.py | 77 ++++ .../wizard/account_day_book_wizard_view.xml | 40 +++ base_accounting_kit/wizard/account_lock_date.py | 65 ++++ base_accounting_kit/wizard/account_lock_date.xml | 36 ++ .../wizard/account_report_common_partner.py | 40 +++ base_accounting_kit/wizard/aged_partner.py | 69 ++++ base_accounting_kit/wizard/aged_partner.xml | 41 +++ .../asset_depreciation_confirmation_wizard.py | 44 +++ ...sset_depreciation_confirmation_wizard_views.xml | 38 ++ base_accounting_kit/wizard/asset_modify.py | 114 ++++++ base_accounting_kit/wizard/asset_modify_views.xml | 40 +++ base_accounting_kit/wizard/cash_flow_report.py | 91 +++++ base_accounting_kit/wizard/cash_flow_report.xml | 53 +++ base_accounting_kit/wizard/financial_report.py | 392 +++++++++++++++++++++ base_accounting_kit/wizard/financial_report.xml | 65 ++++ base_accounting_kit/wizard/general_ledger.py | 55 +++ base_accounting_kit/wizard/general_ledger.xml | 40 +++ base_accounting_kit/wizard/journal_audit.py | 45 +++ base_accounting_kit/wizard/journal_audit.xml | 35 ++ base_accounting_kit/wizard/partner_ledger.py | 42 +++ base_accounting_kit/wizard/partner_ledger.xml | 33 ++ base_accounting_kit/wizard/tax_report.py | 34 ++ base_accounting_kit/wizard/tax_report.xml | 38 ++ base_accounting_kit/wizard/trial_balance.py | 42 +++ base_accounting_kit/wizard/trial_balance.xml | 35 ++ 30 files changed, 1949 insertions(+) create mode 100644 base_accounting_kit/wizard/__init__.py create mode 100644 base_accounting_kit/wizard/account_bank_book_wizard.py create mode 100644 base_accounting_kit/wizard/account_bank_book_wizard_view.xml create mode 100644 base_accounting_kit/wizard/account_cash_book_wizard.py create mode 100644 base_accounting_kit/wizard/account_cash_book_wizard_view.xml create mode 100644 base_accounting_kit/wizard/account_day_book_wizard.py create mode 100644 base_accounting_kit/wizard/account_day_book_wizard_view.xml create mode 100644 base_accounting_kit/wizard/account_lock_date.py create mode 100644 base_accounting_kit/wizard/account_lock_date.xml create mode 100644 base_accounting_kit/wizard/account_report_common_partner.py create mode 100644 base_accounting_kit/wizard/aged_partner.py create mode 100644 base_accounting_kit/wizard/aged_partner.xml create mode 100644 base_accounting_kit/wizard/asset_depreciation_confirmation_wizard.py create mode 100644 base_accounting_kit/wizard/asset_depreciation_confirmation_wizard_views.xml create mode 100644 base_accounting_kit/wizard/asset_modify.py create mode 100644 base_accounting_kit/wizard/asset_modify_views.xml create mode 100644 base_accounting_kit/wizard/cash_flow_report.py create mode 100644 base_accounting_kit/wizard/cash_flow_report.xml create mode 100644 base_accounting_kit/wizard/financial_report.py create mode 100644 base_accounting_kit/wizard/financial_report.xml create mode 100644 base_accounting_kit/wizard/general_ledger.py create mode 100644 base_accounting_kit/wizard/general_ledger.xml create mode 100644 base_accounting_kit/wizard/journal_audit.py create mode 100644 base_accounting_kit/wizard/journal_audit.xml create mode 100644 base_accounting_kit/wizard/partner_ledger.py create mode 100644 base_accounting_kit/wizard/partner_ledger.xml create mode 100644 base_accounting_kit/wizard/tax_report.py create mode 100644 base_accounting_kit/wizard/tax_report.xml create mode 100644 base_accounting_kit/wizard/trial_balance.py create mode 100644 base_accounting_kit/wizard/trial_balance.xml (limited to 'base_accounting_kit/wizard') diff --git a/base_accounting_kit/wizard/__init__.py b/base_accounting_kit/wizard/__init__.py new file mode 100644 index 0000000..5eff555 --- /dev/null +++ b/base_accounting_kit/wizard/__init__.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# +from . import account_bank_book_wizard +from . import account_cash_book_wizard +from . import account_day_book_wizard +from . import account_lock_date +from . import account_report_common_partner +from . import aged_partner +from . import asset_depreciation_confirmation_wizard +from . import asset_modify +from . import cash_flow_report +from . import financial_report +from . import general_ledger +from . import journal_audit +from . import partner_ledger +from . import tax_report +from . import trial_balance diff --git a/base_accounting_kit/wizard/account_bank_book_wizard.py b/base_accounting_kit/wizard/account_bank_book_wizard.py new file mode 100644 index 0000000..211d52c --- /dev/null +++ b/base_accounting_kit/wizard/account_bank_book_wizard.py @@ -0,0 +1,111 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# +from datetime import date + +from odoo import models, fields, api, _ +from odoo.exceptions import UserError + + +class BankBookWizard(models.TransientModel): + _name = 'account.bank.book.report' + _description = 'Account Bank Book Report' + + company_id = fields.Many2one('res.company', string='Company', + readonly=True, + default=lambda self: self.env.company) + target_move = fields.Selection([('posted', 'All Posted Entries'), + ('all', 'All Entries')], string='Target Moves', required=True, + default='posted') + date_from = fields.Date(string='Start Date', default=date.today(), + required=True) + date_to = fields.Date(string='End Date', default=date.today(), + required=True) + display_account = fields.Selection( + [('all', 'All'), ('movement', 'With movements'), + ('not_zero', 'With balance is not equal to 0')], + string='Display Accounts', required=True, default='movement') + sortby = fields.Selection( + [('sort_date', 'Date'), ('sort_journal_partner', 'Journal & Partner')], + string='Sort by', + required=True, default='sort_date') + initial_balance = fields.Boolean(string='Include Initial Balances', + help='If you selected date, this field allow you to add a row to display the amount of debit/credit/balance that precedes the filter you\'ve set.') + + def _get_default_account_ids(self): + journals = self.env['account.journal'].search([('type', '=', 'bank')]) + accounts = [] + for journal in journals: + accounts.append(journal.payment_credit_account_id.id) + return accounts + + account_ids = fields.Many2many('account.account', + 'account_report_bankbook_account_rel', + 'report_id', 'account_id', + 'Accounts', + default=_get_default_account_ids) + journal_ids = fields.Many2many('account.journal', + 'account_report_bankbook_journal_rel', + 'account_id', 'journal_id', + string='Journals', required=True, + default=lambda self: self.env[ + 'account.journal'].search([])) + + @api.onchange('account_ids') + def onchange_account_ids(self): + if self.account_ids: + journals = self.env['account.journal'].search( + [('type', '=', 'bank')]) + accounts = [] + for journal in journals: + accounts.append(journal.payment_credit_account_id.id) + domain = {'account_ids': [('id', 'in', accounts)]} + return {'domain': domain} + + def _build_contexts(self, data): + result = {} + result['journal_ids'] = 'journal_ids' in data['form'] and data['form'][ + 'journal_ids'] or False + result['state'] = 'target_move' in data['form'] and data['form'][ + 'target_move'] or '' + result['date_from'] = data['form']['date_from'] or False + result['date_to'] = data['form']['date_to'] or False + result['strict_range'] = True if result['date_from'] else False + return result + + def check_report(self): + self.ensure_one() + if self.initial_balance and not self.date_from: + raise UserError(_("You must choose a Start Date")) + data = {} + data['ids'] = self.env.context.get('active_ids', []) + data['model'] = self.env.context.get('active_model', 'ir.ui.menu') + data['form'] = self.read( + ['date_from', 'date_to', 'journal_ids', 'target_move', + 'display_account', + 'account_ids', 'sortby', 'initial_balance'])[0] + used_context = self._build_contexts(data) + data['form']['used_context'] = dict(used_context, + lang=self.env.context.get( + 'lang') or 'en_US') + return self.env.ref( + 'base_accounting_kit.action_report_bank_book').report_action(self, + data=data) diff --git a/base_accounting_kit/wizard/account_bank_book_wizard_view.xml b/base_accounting_kit/wizard/account_bank_book_wizard_view.xml new file mode 100644 index 0000000..8f0f62f --- /dev/null +++ b/base_accounting_kit/wizard/account_bank_book_wizard_view.xml @@ -0,0 +1,43 @@ + + + + + account.bank.book.form.view + account.bank.book.report + +
+ + + + + + + + + + + + + + +
+
+ +
+
+ + + Bank Book Report + ir.actions.act_window + account.bank.book.report + + form + new + + + +
+
\ No newline at end of file diff --git a/base_accounting_kit/wizard/account_cash_book_wizard.py b/base_accounting_kit/wizard/account_cash_book_wizard.py new file mode 100644 index 0000000..808be83 --- /dev/null +++ b/base_accounting_kit/wizard/account_cash_book_wizard.py @@ -0,0 +1,111 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# +from datetime import date + +from odoo import models, fields, api, _ +from odoo.exceptions import UserError + + +class CashBookWizard(models.TransientModel): + _name = 'account.cash.book.report' + _description = 'Account Cash Book Report' + + company_id = fields.Many2one('res.company', string='Company', + readonly=True, + default=lambda self: self.env.company) + target_move = fields.Selection([('posted', 'All Posted Entries'), + ('all', 'All Entries')], string='Target Moves', required=True, + default='posted') + date_from = fields.Date(string='Start Date', default=date.today(), + required=True) + date_to = fields.Date(string='End Date', default=date.today(), + required=True) + display_account = fields.Selection( + [('all', 'All'), ('movement', 'With movements'), + ('not_zero', 'With balance is not equal to 0')], + string='Display Accounts', required=True, default='movement') + sortby = fields.Selection( + [('sort_date', 'Date'), ('sort_journal_partner', 'Journal & Partner')], + string='Sort by', + required=True, default='sort_date') + initial_balance = fields.Boolean(string='Include Initial Balances', + help='If you selected date, this field allow you to add a row to display the amount of debit/credit/balance that precedes the filter you\'ve set.') + + def _get_default_account_ids(self): + journals = self.env['account.journal'].search([('type', '=', 'cash')]) + accounts = [] + for journal in journals: + accounts.append(journal.payment_credit_account_id.id) + return accounts + + account_ids = fields.Many2many('account.account', + 'account_report_cashbook_account_rel', + 'report_id', 'account_id', + 'Accounts', + default=_get_default_account_ids) + journal_ids = fields.Many2many('account.journal', + 'account_report_cashbook_journal_rel', + 'account_id', 'journal_id', + string='Journals', required=True, + default=lambda self: self.env[ + 'account.journal'].search([])) + + @api.onchange('account_ids') + def onchange_account_ids(self): + if self.account_ids: + journals = self.env['account.journal'].search( + [('type', '=', 'cash')]) + accounts = [] + for journal in journals: + accounts.append(journal.payment_credit_account_id.id) + domain = {'account_ids': [('id', 'in', accounts)]} + return {'domain': domain} + + def _build_contexts(self, data): + result = {} + result['journal_ids'] = 'journal_ids' in data['form'] and data['form'][ + 'journal_ids'] or False + result['state'] = 'target_move' in data['form'] and data['form'][ + 'target_move'] or '' + result['date_from'] = data['form']['date_from'] or False + result['date_to'] = data['form']['date_to'] or False + result['strict_range'] = True if result['date_from'] else False + return result + + def check_report(self): + self.ensure_one() + if self.initial_balance and not self.date_from: + raise UserError(_("You must choose a Start Date")) + data = {} + data['ids'] = self.env.context.get('active_ids', []) + data['model'] = self.env.context.get('active_model', 'ir.ui.menu') + data['form'] = self.read( + ['date_from', 'date_to', 'journal_ids', 'target_move', + 'display_account', + 'account_ids', 'sortby', 'initial_balance'])[0] + used_context = self._build_contexts(data) + data['form']['used_context'] = dict(used_context, + lang=self.env.context.get( + 'lang') or 'en_US') + return self.env.ref( + 'base_accounting_kit.action_report_cash_book').report_action(self, + data=data) diff --git a/base_accounting_kit/wizard/account_cash_book_wizard_view.xml b/base_accounting_kit/wizard/account_cash_book_wizard_view.xml new file mode 100644 index 0000000..d2ae177 --- /dev/null +++ b/base_accounting_kit/wizard/account_cash_book_wizard_view.xml @@ -0,0 +1,43 @@ + + + + + account.cash.book.form.view + account.cash.book.report + +
+ + + + + + + + + + + + + + +
+
+ +
+
+ + + Cash Book Report + ir.actions.act_window + account.cash.book.report + + form + new + + + +
+
\ No newline at end of file diff --git a/base_accounting_kit/wizard/account_day_book_wizard.py b/base_accounting_kit/wizard/account_day_book_wizard.py new file mode 100644 index 0000000..bee07b5 --- /dev/null +++ b/base_accounting_kit/wizard/account_day_book_wizard.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# +from datetime import date + +from odoo import models, fields + + +class DayBookWizard(models.TransientModel): + _name = 'account.day.book.report' + _description = 'Account Day Book Report' + + company_id = fields.Many2one('res.company', string='Company', + readonly=True, + default=lambda self: self.env.company) + journal_ids = fields.Many2many('account.journal', string='Journals', + required=True, + default=lambda self: self.env[ + 'account.journal'].search([])) + target_move = fields.Selection([('posted', 'All Posted Entries'), + ('all', 'All Entries')], string='Target Moves', required=True, + default='posted') + + account_ids = fields.Many2many('account.account', + 'account_report_daybook_account_rel', + 'report_id', 'account_id', + 'Accounts') + + date_from = fields.Date(string='Start Date', default=date.today(), + required=True) + date_to = fields.Date(string='End Date', default=date.today(), + required=True) + + def _build_contexts(self, data): + result = {} + result['journal_ids'] = 'journal_ids' in data['form'] and data['form'][ + 'journal_ids'] or False + result['state'] = 'target_move' in data['form'] and data['form'][ + 'target_move'] or '' + result['date_from'] = data['form']['date_from'] or False + result['date_to'] = data['form']['date_to'] or False + result['strict_range'] = True if result['date_from'] else False + return result + + def check_report(self): + self.ensure_one() + data = {} + data['ids'] = self.env.context.get('active_ids', []) + data['model'] = self.env.context.get('active_model', 'ir.ui.menu') + data['form'] = \ + self.read(['date_from', 'date_to', 'journal_ids', 'target_move', + 'account_ids'])[0] + used_context = self._build_contexts(data) + data['form']['used_context'] = dict(used_context, + lang=self.env.context.get( + 'lang') or 'en_US') + return self.env.ref( + 'base_accounting_kit.day_book_pdf_report').report_action(self, + data=data) diff --git a/base_accounting_kit/wizard/account_day_book_wizard_view.xml b/base_accounting_kit/wizard/account_day_book_wizard_view.xml new file mode 100644 index 0000000..cdb74b2 --- /dev/null +++ b/base_accounting_kit/wizard/account_day_book_wizard_view.xml @@ -0,0 +1,40 @@ + + + + + account.day.book.form.view + account.day.book.report + +
+ + + + + + + + + + + +
+
+ +
+
+ + + Day Book Report + ir.actions.act_window + account.day.book.report + + form + new + + + +
+
\ No newline at end of file diff --git a/base_accounting_kit/wizard/account_lock_date.py b/base_accounting_kit/wizard/account_lock_date.py new file mode 100644 index 0000000..7fcff94 --- /dev/null +++ b/base_accounting_kit/wizard/account_lock_date.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# +from odoo import api, fields, models, SUPERUSER_ID, _ +from odoo.exceptions import UserError + + +class AccountUpdateLockDate(models.TransientModel): + _name = 'account.lock.date' + _description = 'Lock date for accounting' + + company_id = fields.Many2one(comodel_name='res.company', string="Company", + required=True) + period_lock_date = fields.Date(string="Lock Date for Non-Advisers", + help="Only users with the 'Adviser' role can edit accounts prior to " + "and inclusive of this date. Use it for period locking inside an " + "open fiscal year, for example.") + fiscalyear_lock_date = fields.Date(string="Lock Date", + help="No users, including Advisers, can edit accounts prior to and " + "inclusive of this date. Use it for fiscal year locking for " + "example.") + + @api.model + def default_get(self, field_list): + res = super(AccountUpdateLockDate, self).default_get(field_list) + company = self.env.company + res.update({ + 'company_id': company.id, + 'period_lock_date': company.period_lock_date, + 'fiscalyear_lock_date': company.fiscalyear_lock_date, + }) + return res + + def _check_execute_allowed(self): + self.ensure_one() + has_adviser_group = self.env.user.has_group( + 'account.group_account_manager') + if not (has_adviser_group or self.env.uid == SUPERUSER_ID): + raise UserError(_("You are not allowed to execute this action.")) + + def execute(self): + self.ensure_one() + self._check_execute_allowed() + self.company_id.sudo().write({ + 'period_lock_date': self.period_lock_date, + 'fiscalyear_lock_date': self.fiscalyear_lock_date, + }) diff --git a/base_accounting_kit/wizard/account_lock_date.xml b/base_accounting_kit/wizard/account_lock_date.xml new file mode 100644 index 0000000..25d3743 --- /dev/null +++ b/base_accounting_kit/wizard/account_lock_date.xml @@ -0,0 +1,36 @@ + + + + + account.lock.date.form + account.lock.date + +
+ + + + + +
+
+
+
+
+ + + + Lock your Fiscal Period + account.lock.date + form + new + + + + +
diff --git a/base_accounting_kit/wizard/account_report_common_partner.py b/base_accounting_kit/wizard/account_report_common_partner.py new file mode 100644 index 0000000..1b8989b --- /dev/null +++ b/base_accounting_kit/wizard/account_report_common_partner.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# + +from odoo import fields, models + + +class AccountingCommonPartnerReport(models.TransientModel): + _name = 'account.common.partner.report' + _description = 'Account Common Partner Report' + _inherit = "account.common.report" + + result_selection = fields.Selection([('customer', 'Receivable Accounts'), + ('supplier', 'Payable Accounts'), + ('customer_supplier', + 'Receivable and Payable Accounts') + ], string="Partner's", required=True, + default='customer') + + def pre_print_report(self, data): + data['form'].update(self.read(['result_selection'])[0]) + return data diff --git a/base_accounting_kit/wizard/aged_partner.py b/base_accounting_kit/wizard/aged_partner.py new file mode 100644 index 0000000..85d5367 --- /dev/null +++ b/base_accounting_kit/wizard/aged_partner.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# + +import time + +from dateutil.relativedelta import relativedelta + +from odoo import fields, models, _ +from odoo.exceptions import UserError + + +class AccountAgedTrialBalance(models.TransientModel): + _name = 'account.aged.trial.balance' + _inherit = 'account.common.partner.report' + _description = 'Account Aged Trial balance Report' + + journal_ids = fields.Many2many('account.journal', string='Journals', + required=True) + period_length = fields.Integer(string='Period Length (days)', + required=True, default=30) + date_from = fields.Date(default=lambda *a: time.strftime('%Y-%m-%d')) + + def _print_report(self, data): + + res = {} + data = self.pre_print_report(data) + data['form'].update(self.read(['period_length'])[0]) + period_length = data['form']['period_length'] + if period_length <= 0: + raise UserError(_('You must set a period length greater than 0.')) + if not data['form']['date_from']: + raise UserError(_('You must set a start date.')) + + start = data['form']['date_from'] + + for i in range(5)[::-1]: + stop = start - relativedelta(days=period_length - 1) + res[str(i)] = { + 'name': (i != 0 and ( + str((5 - (i + 1)) * period_length) + '-' + str( + (5 - i) * period_length)) or ( + '+' + str(4 * period_length))), + 'stop': start.strftime('%Y-%m-%d'), + 'start': (i != 0 and stop.strftime('%Y-%m-%d') or False), + } + start = stop - relativedelta(days=1) + data['form'].update(res) + return self.env.ref( + 'base_accounting_kit.action_report_aged_partner_balance').with_context( + landscape=True).report_action(self, data=data) diff --git a/base_accounting_kit/wizard/aged_partner.xml b/base_accounting_kit/wizard/aged_partner.xml new file mode 100644 index 0000000..92a5aa6 --- /dev/null +++ b/base_accounting_kit/wizard/aged_partner.xml @@ -0,0 +1,41 @@ + + + + + Aged Partner Balance + account.aged.trial.balance + +
+ + + + + + + + +
+
+ +
+
+ + + Aged Partner Balance + account.aged.trial.balance + ir.actions.act_window + tree,form + + {} + new + + + + +
diff --git a/base_accounting_kit/wizard/asset_depreciation_confirmation_wizard.py b/base_accounting_kit/wizard/asset_depreciation_confirmation_wizard.py new file mode 100644 index 0000000..0464184 --- /dev/null +++ b/base_accounting_kit/wizard/asset_depreciation_confirmation_wizard.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# + +from odoo import api, fields, models, _ + + +class AssetDepreciationConfirmationWizard(models.TransientModel): + _name = "asset.depreciation.confirmation.wizard" + _description = "asset.depreciation.confirmation.wizard" + + date = fields.Date('Account Date', required=True, help="Choose the period for which you want to automatically post the depreciation lines of running assets", default=fields.Date.context_today) + + def asset_compute(self): + self.ensure_one() + context = self._context + created_move_ids = self.env['account.asset.asset'].compute_generated_entries(self.date, asset_type=context.get('asset_type')) + + return { + 'name': _('Created Asset Moves') if context.get('asset_type') == 'purchase' else _('Created Revenue Moves'), + 'view_mode': 'tree,form', + 'res_model': 'account.move', + 'view_id': False, + 'domain': "[('id','in',[" + ','.join(str(id) for id in created_move_ids) + "])]", + 'type': 'ir.actions.act_window', + } diff --git a/base_accounting_kit/wizard/asset_depreciation_confirmation_wizard_views.xml b/base_accounting_kit/wizard/asset_depreciation_confirmation_wizard_views.xml new file mode 100644 index 0000000..a4b5fff --- /dev/null +++ b/base_accounting_kit/wizard/asset_depreciation_confirmation_wizard_views.xml @@ -0,0 +1,38 @@ + + + + asset.depreciation.confirmation.wizard + asset.depreciation.confirmation.wizard + +
+
+

+ This wizard will post installment/depreciation lines for the selected month.
+ This will generate journal entries for all related installment lines on this period of asset/revenue recognition as well. +

+
+ + + +
+
+
+
+
+ + + Post Depreciation Lines + asset.depreciation.confirmation.wizard + tree,form + + new + {'asset_type': 'purchase'} + + + + +
diff --git a/base_accounting_kit/wizard/asset_modify.py b/base_accounting_kit/wizard/asset_modify.py new file mode 100644 index 0000000..7fddb99 --- /dev/null +++ b/base_accounting_kit/wizard/asset_modify.py @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# + +from lxml import etree + +from odoo import api, fields, models, _ +from odoo.addons.base.models.ir_ui_view import ( +transfer_field_to_modifiers, transfer_node_to_modifiers, transfer_modifiers_to_node, +) + + +def setup_modifiers(node, field=None, context=None, in_tree_view=False): + modifiers = {} + if field is not None: + transfer_field_to_modifiers(field, modifiers) + transfer_node_to_modifiers( + node, modifiers, context=context) + transfer_modifiers_to_node(modifiers, node) + + +class AssetModify(models.TransientModel): + _name = 'asset.modify' + _description = 'Modify Asset' + + name = fields.Text(string='Reason', required=True) + method_number = fields.Integer(string='Number of Depreciations', required=True) + method_period = fields.Integer(string='Period Length') + method_end = fields.Date(string='Ending date') + asset_method_time = fields.Char(compute='_get_asset_method_time', string='Asset Method Time', readonly=True) + + def _get_asset_method_time(self): + if self.env.context.get('active_id'): + asset = self.env['account.asset.asset'].browse(self.env.context.get('active_id')) + self.asset_method_time = asset.method_time + + @api.model + def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False): + result = super(AssetModify, self).fields_view_get(view_id, view_type, toolbar=toolbar, submenu=submenu) + asset_id = self.env.context.get('active_id') + active_model = self.env.context.get('active_model') + if active_model == 'account.asset.asset' and asset_id: + asset = self.env['account.asset.asset'].browse(asset_id) + doc = etree.XML(result['arch']) + if asset.method_time == 'number' and doc.xpath("//field[@name='method_end']"): + node = doc.xpath("//field[@name='method_end']")[0] + node.set('invisible', '1') + setup_modifiers(node, result['fields']['method_end']) + elif asset.method_time == 'end' and doc.xpath("//field[@name='method_number']"): + node = doc.xpath("//field[@name='method_number']")[0] + node.set('invisible', '1') + setup_modifiers(node, result['fields']['method_number']) + result['arch'] = etree.tostring(doc, encoding='unicode') + return result + + @api.model + def default_get(self, fields): + res = super(AssetModify, self).default_get(fields) + asset_id = self.env.context.get('active_id') + asset = self.env['account.asset.asset'].browse(asset_id) + if 'name' in fields: + res.update({'name': asset.name}) + if 'method_number' in fields and asset.method_time == 'number': + res.update({'method_number': asset.method_number}) + if 'method_period' in fields: + res.update({'method_period': asset.method_period}) + if 'method_end' in fields and asset.method_time == 'end': + res.update({'method_end': asset.method_end}) + if self.env.context.get('active_id'): + active_asset = self.env['account.asset.asset'].browse(self.env.context.get('active_id')) + res['asset_method_time'] = active_asset.method_time + return res + + def modify(self): + """ Modifies the duration of asset for calculating depreciation + and maintains the history of old values, in the chatter. + """ + asset_id = self.env.context.get('active_id', False) + asset = self.env['account.asset.asset'].browse(asset_id) + old_values = { + 'method_number': asset.method_number, + 'method_period': asset.method_period, + 'method_end': asset.method_end, + } + asset_vals = { + 'method_number': self.method_number, + 'method_period': self.method_period, + 'method_end': self.method_end, + } + asset.write(asset_vals) + asset.compute_depreciation_board() + tracked_fields = self.env['account.asset.asset'].fields_get(['method_number', 'method_period', 'method_end']) + changes, tracking_value_ids = asset._message_track(tracked_fields, old_values) + if changes: + asset.message_post(subject=_('Depreciation board modified'), body=self.name, tracking_value_ids=tracking_value_ids) + return {'type': 'ir.actions.act_window_close'} diff --git a/base_accounting_kit/wizard/asset_modify_views.xml b/base_accounting_kit/wizard/asset_modify_views.xml new file mode 100644 index 0000000..edd5cd4 --- /dev/null +++ b/base_accounting_kit/wizard/asset_modify_views.xml @@ -0,0 +1,40 @@ + + + + + wizard.asset.modify.form + asset.modify + +
+ + + + + + + + + + +
+
+ +
+
+ + + Modify Asset + asset.modify + ir.actions.act_window + tree,form + + new + + +
diff --git a/base_accounting_kit/wizard/cash_flow_report.py b/base_accounting_kit/wizard/cash_flow_report.py new file mode 100644 index 0000000..85b4021 --- /dev/null +++ b/base_accounting_kit/wizard/cash_flow_report.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# + +from odoo import api, fields, models + + +class AccountingReport(models.TransientModel): + _name = "cash.flow.report" + _inherit = "account.common.report" + _description = "Cash Flow Report" + + @api.model + def _get_account_report(self): + reports = [] + if self._context.get('active_id'): + menu = self.env['ir.ui.menu'].browse( + self._context.get('active_id')).name + reports = self.env['account.financial.report'].search( + [('name', 'ilike', menu)]) + return reports and reports[0] or False + + enable_filter = fields.Boolean(string='Enable Comparison') + account_report_id = fields.Many2one('account.financial.report', + string='Account Reports', + required=True, + default=_get_account_report) + label_filter = fields.Char(string='Column Label', + help="This label will be displayed on report to show the balance" + " computed for the given comparison filter.") + filter_cmp = fields.Selection( + [('filter_no', 'No Filters'), ('filter_date', 'Date')], + string='Filter by', required=True, default='filter_no') + date_from_cmp = fields.Date(string='Date Start') + date_to_cmp = fields.Date(string='Date End') + debit_credit = fields.Boolean(string='Display Debit/Credit Columns', + help="This option allows you to get more details about the way your balances are computed. Because it is space consuming, we do not allow to use it while doing a comparison.") + + def _build_comparison_context(self, data): + result = {} + result['journal_ids'] = 'journal_ids' in data['form'] and data['form'][ + 'journal_ids'] or False + result['state'] = 'target_move' in data['form'] and data['form'][ + 'target_move'] or '' + if data['form']['filter_cmp'] == 'filter_date': + result['date_from'] = data['form']['date_from_cmp'] + result['date_to'] = data['form']['date_to_cmp'] + result['strict_range'] = True + return result + + # @api.multi + def check_report(self): + res = super(AccountingReport, self).check_report() + data = {} + data['form'] = self.read( + ['account_report_id', 'date_from_cmp', 'date_to_cmp', + 'journal_ids', 'filter_cmp', 'target_move'])[0] + for field in ['account_report_id']: + if isinstance(data['form'][field], tuple): + data['form'][field] = data['form'][field][0] + comparison_context = self._build_comparison_context(data) + res['data']['form']['comparison_context'] = comparison_context + return res + + def _print_report(self, data): + data['form'].update(self.read( + ['date_from_cmp', 'debit_credit', 'date_to_cmp', 'filter_cmp', + 'account_report_id', 'enable_filter', 'label_filter', + 'target_move'])[0]) + return self.env.ref( + 'base_accounting_kit.action_report_cash_flow').report_action(self, + data=data, + config=False) diff --git a/base_accounting_kit/wizard/cash_flow_report.xml b/base_accounting_kit/wizard/cash_flow_report.xml new file mode 100644 index 0000000..6c8e255 --- /dev/null +++ b/base_accounting_kit/wizard/cash_flow_report.xml @@ -0,0 +1,53 @@ + + + + Cash Flow Statement + cash.flow.report + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cash Flow Statement + cash.flow.report + ir.actions.act_window + form + + new + + + + + diff --git a/base_accounting_kit/wizard/financial_report.py b/base_accounting_kit/wizard/financial_report.py new file mode 100644 index 0000000..0f656bf --- /dev/null +++ b/base_accounting_kit/wizard/financial_report.py @@ -0,0 +1,392 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# +import re + +from odoo import api, models, fields + + +class FinancialReport(models.TransientModel): + _name = "financial.report" + _inherit = "account.common.report" + _description = "Financial Reports" + + view_format = fields.Selection([ + ('vertical', 'Vertical'), + ('horizontal', 'Horizontal')], + default='vertical', + string="Format") + + @api.model + def _get_account_report(self): + reports = [] + if self._context.get('active_id'): + menu = self.env['ir.ui.menu'].browse( + self._context.get('active_id')).name + reports = self.env['account.financial.report'].search([ + ('name', 'ilike', menu)]) + return reports and reports[0] or False + + enable_filter = fields.Boolean( + string='Enable Comparison', + default=False) + account_report_id = fields.Many2one( + 'account.financial.report', + string='Account Reports', + required=True) + + date_from = fields.Date(string='Start Date') + date_to = fields.Date(string='End Date') + debit_credit = fields.Boolean( + string='Display Debit/Credit Columns', + default=True, + help="This option allows you to" + " get more details about the " + "way your balances are computed." + " Because it is space consuming," + " we do not allow to use it " + "while doing a comparison.") + company_id = fields.Many2one( + 'res.company', + string='Company', + index=True, + default=lambda self: self.env.company.id) + + def view_report_pdf(self): + """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() + data['ids'] = self.env.context.get('active_ids', []) + data['model'] = self.env.context.get('active_model', 'ir.ui.menu') + data['form'] = self.read( + ['date_from', 'enable_filter', 'debit_credit', 'date_to', + 'account_report_id', 'target_move', 'view_format', + 'company_id'])[0] + used_context = self._build_contexts(data) + data['form']['used_context'] = dict( + used_context, + lang=self.env.context.get('lang') or 'en_US') + + report_lines = self.get_account_lines(data['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'] + id = item['id'] + report_id = item['r_id'] + else: + item['level'] = set_report_level(item) + currency = self._get_currency() + data['currency'] = currency + data['journal_items'] = journal_items + data['report_lines'] = report_lines + # checking view type + return self.env.ref( + 'base_accounting_kit.financial_report_pdf').report_action(self, + 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 = self.env['account.financial.report'].search([ + ('id', '=', data['account_report_id'][0]) + ]) + 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) + # p_name = p_name.replace(" ", "-") + + # "-" + str(report.parent_id.id) + else: + p_name = False + vals = { + 'r_id': report.id, + '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, + # 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 = { + 'account': account.id, + '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 + + @api.model + def _get_currency(self): + journal = self.env['account.journal'].browse( + self.env.context.get('default_journal_id', False)) + if journal.currency_id: + return journal.currency_id.id + return self.env.company.currency_id.symbol + + +class ProfitLossPdf(models.AbstractModel): + """ Abstract model for generating PDF report value and send to template """ + + _name = 'report.base_accounting_kit.report_financial' + _description = 'Financial Report' + + @api.model + def _get_report_values(self, docids, data=None): + """ Provide report values to template """ + ctx = { + 'data': data, + 'journal_items': data['journal_items'], + 'report_lines': data['report_lines'], + 'account_report': data['form']['account_report_id'][1], + 'currency': data['currency'], + } + return ctx diff --git a/base_accounting_kit/wizard/financial_report.xml b/base_accounting_kit/wizard/financial_report.xml new file mode 100644 index 0000000..6353059 --- /dev/null +++ b/base_accounting_kit/wizard/financial_report.xml @@ -0,0 +1,65 @@ + + + + + + financial.report.extended.wiz + financial.report + +
+ + + + + + + + + + + + + + +
+
+
+
+
+ + + Profit and Loss + financial.report + ir.actions.act_window + form + + new + + + + + + Balance Sheet + financial.report + ir.actions.act_window + form + + new + + + + + + +
+
diff --git a/base_accounting_kit/wizard/general_ledger.py b/base_accounting_kit/wizard/general_ledger.py new file mode 100644 index 0000000..c73ca99 --- /dev/null +++ b/base_accounting_kit/wizard/general_ledger.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# + +from odoo import fields, models, _ +from odoo.exceptions import UserError + + +class AccountReportGeneralLedger(models.TransientModel): + _inherit = "account.common.account.report" + _name = "account.report.general.ledger" + _description = "General Ledger Report" + + initial_balance = fields.Boolean(string='Include Initial Balances', + help='If you selected date, this field ' + 'allow you to add a row to display ' + 'the amount of debit/credit/balance ' + 'that precedes the filter you\'ve ' + 'set.') + sortby = fields.Selection( + [('sort_date', 'Date'), ('sort_journal_partner', 'Journal & Partner')], + string='Sort by', required=True, default='sort_date') + journal_ids = fields.Many2many('account.journal', + 'account_report_general_ledger_journal_rel', + 'account_id', 'journal_id', + string='Journals', required=True) + + def _print_report(self, data): + data = self.pre_print_report(data) + data['form'].update(self.read(['initial_balance', 'sortby'])[0]) + if data['form'].get('initial_balance') and not data['form'].get( + 'date_from'): + raise UserError(_("You must define a Start Date")) + records = self.env[data['model']].browse(data.get('ids', [])) + return self.env.ref( + 'base_accounting_kit.action_report_general_ledger').with_context( + landscape=True).report_action(records, data=data) diff --git a/base_accounting_kit/wizard/general_ledger.xml b/base_accounting_kit/wizard/general_ledger.xml new file mode 100644 index 0000000..363a140 --- /dev/null +++ b/base_accounting_kit/wizard/general_ledger.xml @@ -0,0 +1,40 @@ + + + + + General Ledger + account.report.general.ledger + + + + + + + + + + + + + + + General Ledger + ir.actions.act_window + account.report.general.ledger + form + + new + + report + + + + + diff --git a/base_accounting_kit/wizard/journal_audit.py b/base_accounting_kit/wizard/journal_audit.py new file mode 100644 index 0000000..4bfadab --- /dev/null +++ b/base_accounting_kit/wizard/journal_audit.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# + +from odoo import fields, models + + +class AccountPrintJournal(models.TransientModel): + _inherit = "account.common.journal.report" + _name = "account.print.journal" + _description = "Account Print Journal" + + sort_selection = fields.Selection( + [('date', 'Date'), ('move_name', 'Journal Entry Number')], + 'Entries Sorted by', required=True, default='move_name') + journal_ids = fields.Many2many('account.journal', string='Journals', + required=True, + default=lambda self: self.env[ + 'account.journal'].search( + [('type', 'in', ['sale', 'purchase'])])) + + def _print_report(self, data): + data = self.pre_print_report(data) + data['form'].update({'sort_selection': self.sort_selection}) + return self.env.ref( + 'base_accounting_kit.action_report_journal').with_context( + landscape=True).report_action(self, data=data) diff --git a/base_accounting_kit/wizard/journal_audit.xml b/base_accounting_kit/wizard/journal_audit.xml new file mode 100644 index 0000000..08e896f --- /dev/null +++ b/base_accounting_kit/wizard/journal_audit.xml @@ -0,0 +1,35 @@ + + + + + Journals Audit + account.print.journal + + + + + + + + + + + + + + Journals Audit + ir.actions.act_window + account.print.journal + form + + new + + + + + diff --git a/base_accounting_kit/wizard/partner_ledger.py b/base_accounting_kit/wizard/partner_ledger.py new file mode 100644 index 0000000..4c47aaa --- /dev/null +++ b/base_accounting_kit/wizard/partner_ledger.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# + +from odoo import fields, models + + +class AccountPartnerLedger(models.TransientModel): + _name = "account.report.partner.ledger" + _inherit = "account.common.partner.report" + _description = "Account Partner Ledger" + + amount_currency = fields.Boolean("With Currency", + help="It adds the currency column on report if the " + "currency differs from the company currency.") + reconciled = fields.Boolean('Reconciled Entries') + + def _print_report(self, data): + data = self.pre_print_report(data) + data['form'].update({'reconciled': self.reconciled, + 'amount_currency': self.amount_currency}) + return self.env.ref( + 'base_accounting_kit.action_report_partnerledger').report_action( + self, data=data) diff --git a/base_accounting_kit/wizard/partner_ledger.xml b/base_accounting_kit/wizard/partner_ledger.xml new file mode 100644 index 0000000..ab20b63 --- /dev/null +++ b/base_accounting_kit/wizard/partner_ledger.xml @@ -0,0 +1,33 @@ + + + + Partner Ledger + account.report.partner.ledger + + + + + + + + + + + + + + + + Partner Ledger + account.report.partner.ledger + ir.actions.act_window + form + + new + + + + diff --git a/base_accounting_kit/wizard/tax_report.py b/base_accounting_kit/wizard/tax_report.py new file mode 100644 index 0000000..5a3acb6 --- /dev/null +++ b/base_accounting_kit/wizard/tax_report.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# + +from odoo import models + + +class AccountTaxReport(models.TransientModel): + _inherit = "account.common.report" + _name = 'kit.account.tax.report' + _description = 'Tax Report' + + def _print_report(self, data): + return self.env.ref( + 'base_accounting_kit.action_report_account_tax').report_action( + self, data=data) diff --git a/base_accounting_kit/wizard/tax_report.xml b/base_accounting_kit/wizard/tax_report.xml new file mode 100644 index 0000000..d5ef3a8 --- /dev/null +++ b/base_accounting_kit/wizard/tax_report.xml @@ -0,0 +1,38 @@ + + + + + Tax Reports + kit.account.tax.report + + + + + + + + + + + + + + + + Tax Reports + kit.account.tax.report + ir.actions.act_window + form + + {} + new + + + + + diff --git a/base_accounting_kit/wizard/trial_balance.py b/base_accounting_kit/wizard/trial_balance.py new file mode 100644 index 0000000..6676b7b --- /dev/null +++ b/base_accounting_kit/wizard/trial_balance.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-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 . +# +############################################################################# + +from odoo import fields, models + + +class AccountBalanceReport(models.TransientModel): + _inherit = "account.common.account.report" + _name = 'account.balance.report' + _description = 'Trial Balance Report' + + journal_ids = fields.Many2many('account.journal', + 'account_balance_report_journal_rel', + 'account_id', 'journal_id', + string='Journals', required=True, + default=[]) + + def _print_report(self, data): + data = self.pre_print_report(data) + records = self.env[data['model']].browse(data.get('ids', [])) + return self.env.ref( + 'base_accounting_kit.action_report_trial_balance').report_action( + records, data=data) diff --git a/base_accounting_kit/wizard/trial_balance.xml b/base_accounting_kit/wizard/trial_balance.xml new file mode 100644 index 0000000..59102eb --- /dev/null +++ b/base_accounting_kit/wizard/trial_balance.xml @@ -0,0 +1,35 @@ + + + + + Trial Balance + account.balance.report + + + + + + + + + + + + + + Trial Balance + account.balance.report + ir.actions.act_window + form + + new + + + + + + -- cgit v1.2.3