diff --git a/account_journal_report/__init__.py b/account_journal_report/__init__.py new file mode 100644 index 000000000..55a12ddc2 --- /dev/null +++ b/account_journal_report/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from . import report +from . import wizard + diff --git a/account_journal_report/__manifest__.py b/account_journal_report/__manifest__.py new file mode 100644 index 000000000..da42bb511 --- /dev/null +++ b/account_journal_report/__manifest__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: fasluca() +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +{ + 'name': 'Account Journal Report', + 'summary': """""", + 'version': '11.0.1.0', + 'description': """""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': "https://cybrosys.com/", + 'category': 'Accounting', + 'depends': ['web', 'account'], + 'license': 'AGPL-3', + 'data': [ + 'views/account_report.xml', + 'views/report_journal.xml', + 'wizard/account_report_common_journal_view.xml', + 'wizard/account_report_cash_journal_view.xml', + 'wizard/account_report_bank_journal_view.xml', + 'views/report_menu_view.xml', + + ], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'installable': True, + 'auto_install': False, +} diff --git a/account_journal_report/report/__init__.py b/account_journal_report/report/__init__.py new file mode 100644 index 000000000..176b6efa9 --- /dev/null +++ b/account_journal_report/report/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import account_common_journal diff --git a/account_journal_report/report/account_common_journal.py b/account_journal_report/report/account_common_journal.py new file mode 100644 index 000000000..16bb3fa84 --- /dev/null +++ b/account_journal_report/report/account_common_journal.py @@ -0,0 +1,119 @@ +# -*- coding: utf-8 -*- + +import time +from odoo import api, models, _ +from odoo.exceptions import UserError + + +class ReportCommonJournal(models.AbstractModel): + _name = 'report.account_journal_report.report_common_journal' + + def lines(self, target_move, journal_ids, sort_selection, data): + if isinstance(journal_ids, int): + journal_ids = [journal_ids] + + move_state = ['draft', 'posted'] + if target_move == 'posted': + move_state = ['posted'] + + query_get_clause = self._get_query_get_clause(data) + params = [tuple(move_state), tuple(journal_ids)] + query_get_clause[2] + query = 'SELECT "account_move_line".id FROM ' + query_get_clause[0] + ', account_move am, account_account acc WHERE "account_move_line".account_id = acc.id AND "account_move_line".move_id=am.id AND am.state IN %s AND "account_move_line".journal_id IN %s AND ' + query_get_clause[1] + ' ORDER BY ' + if sort_selection == 'date': + query += '"account_move_line".date' + else: + query += 'am.name' + query += ', "account_move_line".move_id, acc.code' + self.env.cr.execute(query, tuple(params)) + ids = (x[0] for x in self.env.cr.fetchall()) + return self.env['account.move.line'].browse(ids) + + def _sum_debit(self, data, journal_id): + move_state = ['draft', 'posted'] + if data['form'].get('target_move', 'all') == 'posted': + move_state = ['posted'] + + query_get_clause = self._get_query_get_clause(data) + params = [tuple(move_state), tuple(journal_id.ids)] + query_get_clause[2] + + self.env.cr.execute('SELECT SUM(debit) FROM ' + query_get_clause[0] + ', account_move am ' + 'WHERE "account_move_line".move_id=am.id AND am.state IN %s AND "account_move_line".journal_id IN %s AND ' + query_get_clause[1] + ' ', + tuple(params)) + return self.env.cr.fetchone()[0] or 0.0 + + def _sum_credit(self, data, journal_id): + move_state = ['draft', 'posted'] + if data['form'].get('target_move', 'all') == 'posted': + move_state = ['posted'] + + query_get_clause = self._get_query_get_clause(data) + params = [tuple(move_state), tuple(journal_id.ids)] + query_get_clause[2] + self.env.cr.execute('SELECT SUM(credit) FROM ' + query_get_clause[0] + ', account_move am ' + 'WHERE "account_move_line".move_id=am.id AND am.state IN %s AND "account_move_line".journal_id IN %s AND ' + query_get_clause[1] + ' ', + tuple(params)) + return self.env.cr.fetchone()[0] or 0.0 + + def _get_taxes(self, data, journal_id): + move_state = ['draft', 'posted'] + if data['form'].get('target_move', 'all') == 'posted': + move_state = ['posted'] + + query_get_clause = self._get_query_get_clause(data) + params = [tuple(move_state), tuple(journal_id.ids)] + query_get_clause[2] + query = """ + SELECT rel.account_tax_id, SUM("account_move_line".balance) AS base_amount + FROM account_move_line_account_tax_rel rel, """ + query_get_clause[0] + """ + LEFT JOIN account_move am ON "account_move_line".move_id = am.id + WHERE "account_move_line".id = rel.account_move_line_id + AND am.state IN %s + AND "account_move_line".journal_id IN %s + AND """ + query_get_clause[1] + """ + GROUP BY rel.account_tax_id""" + self.env.cr.execute(query, tuple(params)) + ids = [] + base_amounts = {} + for row in self.env.cr.fetchall(): + ids.append(row[0]) + base_amounts[row[0]] = row[1] + + + res = {} + for tax in self.env['account.tax'].browse(ids): + self.env.cr.execute('SELECT sum(debit - credit) FROM ' + query_get_clause[0] + ', account_move am ' + 'WHERE "account_move_line".move_id=am.id AND am.state IN %s AND "account_move_line".journal_id IN %s AND ' + query_get_clause[1] + ' AND tax_line_id = %s', + tuple(params + [tax.id])) + res[tax] = { + 'base_amount': base_amounts[tax.id], + 'tax_amount': self.env.cr.fetchone()[0] or 0.0, + } + if journal_id.type == 'sale': + #sales operation are credits + res[tax]['base_amount'] = res[tax]['base_amount'] * -1 + res[tax]['tax_amount'] = res[tax]['tax_amount'] * -1 + return res + + def _get_query_get_clause(self, data): + return self.env['account.move.line'].with_context(data['form'].get('used_context', {}))._query_get() + + @api.model + def get_report_values(self, docids, data=None): + if not data.get('form'): + raise UserError(_("Form content is missing, this report cannot be printed.")) + + target_move = data['form'].get('target_move', 'all') + sort_selection = data['form'].get('sort_selection', 'date') + + res = {} + for journal in data['form']['journal_ids']: + res[journal] = self.with_context(data['form'].get('used_context', {})).lines(target_move, journal, sort_selection, data) + return { + 'doc_ids': data['form']['journal_ids'], + 'doc_model': self.env['account.journal'], + 'data': data, + 'docs': self.env['account.journal'].browse(data['form']['journal_ids']), + 'time': time, + 'lines': res, + 'sum_credit': self._sum_credit, + 'sum_debit': self._sum_debit, + 'get_taxes': self._get_taxes, + } diff --git a/account_journal_report/static/description/acc_jou_rep.png b/account_journal_report/static/description/acc_jou_rep.png new file mode 100644 index 000000000..1ffda5372 Binary files /dev/null and b/account_journal_report/static/description/acc_jou_rep.png differ diff --git a/account_journal_report/static/description/banner.jpg b/account_journal_report/static/description/banner.jpg new file mode 100644 index 000000000..912c42e7a Binary files /dev/null and b/account_journal_report/static/description/banner.jpg differ diff --git a/account_journal_report/static/description/cybro_logo.png b/account_journal_report/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/account_journal_report/static/description/cybro_logo.png differ diff --git a/account_journal_report/static/description/icon.png b/account_journal_report/static/description/icon.png new file mode 100644 index 000000000..6f21183d4 Binary files /dev/null and b/account_journal_report/static/description/icon.png differ diff --git a/account_journal_report/static/description/index.html b/account_journal_report/static/description/index.html new file mode 100644 index 000000000..e67c5d37e --- /dev/null +++ b/account_journal_report/static/description/index.html @@ -0,0 +1,68 @@ +
+
+

Account Journal Reports

+

Cybrosys Technologies

+
+
+ +
+
+ +

+ Some additional reports to make it easy for accountants +

+
+
+ +
+
+
+

Overview

+

+ This module adds some journal based reports to the Odoo accounting.like, +

+ Common Journal
+ Cash Journal
+ Bank Journal
+
+

+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+

Need Any Help?

+ +
+ diff --git a/account_journal_report/views/account_report.xml b/account_journal_report/views/account_report.xml new file mode 100644 index 000000000..9d4c8d10b --- /dev/null +++ b/account_journal_report/views/account_report.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/account_journal_report/views/report_journal.xml b/account_journal_report/views/report_journal.xml new file mode 100644 index 000000000..70d8b51a9 --- /dev/null +++ b/account_journal_report/views/report_journal.xml @@ -0,0 +1,79 @@ + + + + diff --git a/account_journal_report/views/report_menu_view.xml b/account_journal_report/views/report_menu_view.xml new file mode 100644 index 000000000..5854e946f --- /dev/null +++ b/account_journal_report/views/report_menu_view.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/account_journal_report/wizard/__init__.py b/account_journal_report/wizard/__init__.py new file mode 100644 index 000000000..3b6a8d5ec --- /dev/null +++ b/account_journal_report/wizard/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from . import account_report_common_journal +from . import account_report_cash_journal +from . import account_report_bank_journal diff --git a/account_journal_report/wizard/account_report_bank_journal.py b/account_journal_report/wizard/account_report_bank_journal.py new file mode 100644 index 000000000..86641f6e4 --- /dev/null +++ b/account_journal_report/wizard/account_report_bank_journal.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models + + +class AccountBankJournalReport(models.TransientModel): + _inherit = "account.common.journal.report" + _name = "account.bank.journal.report" + + 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', ['bank'])])) + + def _print_report(self, data): + data = self.pre_print_report(data) + data['form'].update({'sort_selection': self.sort_selection}) + return self.env.ref('account_journal_report.action_report_bank_journal').with_context(landscape=True).report_action(self, data=data) diff --git a/account_journal_report/wizard/account_report_bank_journal_view.xml b/account_journal_report/wizard/account_report_bank_journal_view.xml new file mode 100644 index 000000000..8e7f0ea93 --- /dev/null +++ b/account_journal_report/wizard/account_report_bank_journal_view.xml @@ -0,0 +1,27 @@ + + + + Bank Journal + account.bank.journal.report + + + + + + + + + + + + + + Bank Journal + account.bank.journal.report + form + form + + new + + + \ No newline at end of file diff --git a/account_journal_report/wizard/account_report_cash_journal.py b/account_journal_report/wizard/account_report_cash_journal.py new file mode 100644 index 000000000..37191aaef --- /dev/null +++ b/account_journal_report/wizard/account_report_cash_journal.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models + + +class AccountCashJournalReport(models.TransientModel): + _inherit = "account.common.journal.report" + _name = "account.cash.journal.report" + + 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', '=', 'cash')])) + + def _print_report(self, data): + data = self.pre_print_report(data) + data['form'].update({'sort_selection': self.sort_selection}) + return self.env.ref('account_journal_report.action_report_cash_journal').with_context(landscape=True).report_action(self, data=data) diff --git a/account_journal_report/wizard/account_report_cash_journal_view.xml b/account_journal_report/wizard/account_report_cash_journal_view.xml new file mode 100644 index 000000000..64b54f3f0 --- /dev/null +++ b/account_journal_report/wizard/account_report_cash_journal_view.xml @@ -0,0 +1,27 @@ + + + + Cash Journal + account.cash.journal.report + + + + + + + + + + + + + + Cash Journal + account.cash.journal.report + form + form + + new + + + \ No newline at end of file diff --git a/account_journal_report/wizard/account_report_common_journal.py b/account_journal_report/wizard/account_report_common_journal.py new file mode 100644 index 000000000..d8b80f7c2 --- /dev/null +++ b/account_journal_report/wizard/account_report_common_journal.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models + + +class AccountJournalReport(models.TransientModel): + _inherit = "account.common.journal.report" + _name = "account.journal.report" + + sort_selection = fields.Selection([('date', 'Date'), ('move_name', 'Journal Entry Number'),], 'Entries Sorted by', required=True, default='move_name') + + def _print_report(self, data): + data = self.pre_print_report(data) + data['form'].update({'sort_selection': self.sort_selection}) + return self.env.ref('account_journal_report.action_report_common_journal').with_context(landscape=True).report_action(self, data=data) diff --git a/account_journal_report/wizard/account_report_common_journal_view.xml b/account_journal_report/wizard/account_report_common_journal_view.xml new file mode 100644 index 000000000..292101024 --- /dev/null +++ b/account_journal_report/wizard/account_report_common_journal_view.xml @@ -0,0 +1,27 @@ + + + + Common Journal + account.journal.report + + + + + + + + + + + + + + Common Journal + account.journal.report + form + form + + new + + + \ No newline at end of file