diff --git a/account_partner_ledger_filter/__init__.py b/account_partner_ledger_filter/__init__.py new file mode 100644 index 000000000..a957a587e --- /dev/null +++ b/account_partner_ledger_filter/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +import wizard +import models diff --git a/account_partner_ledger_filter/__manifest__.py b/account_partner_ledger_filter/__manifest__.py new file mode 100644 index 000000000..8d0cdede0 --- /dev/null +++ b/account_partner_ledger_filter/__manifest__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Fasluca() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': 'Partner Ledger with Partner Filter', + 'version': '10.0.1.0', + 'summary': """Partner Ledger Report with Partner Filter""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': "https://cybrosys.com/", + 'category': 'Accounting', + 'depends': ['account'], + 'data': [ + 'views/report.xml', + 'wizard/account_report_general_ledger_view.xml' + ], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'license': 'LGPL-3', + 'installable': True, + 'application': False +} diff --git a/account_partner_ledger_filter/models/__init__.py b/account_partner_ledger_filter/models/__init__.py new file mode 100644 index 000000000..f22d63076 --- /dev/null +++ b/account_partner_ledger_filter/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import account_partner_ledger diff --git a/account_partner_ledger_filter/models/account_partner_ledger.py b/account_partner_ledger_filter/models/account_partner_ledger.py new file mode 100644 index 000000000..47ca86daa --- /dev/null +++ b/account_partner_ledger_filter/models/account_partner_ledger.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +import time +import logging +from odoo import api, models + + +_logger = logging.getLogger(__name__) + + +class ReportPartnerLedger(models.AbstractModel): + _inherit = 'report.account.report_partnerledger' + + @api.model + def render_html(self, docids, data=None): + self.model = self.env.context.get('active_model') + docs = self.env[self.model].browse(self.env.context.get('active_ids', [])).id + + data['computed'] = {} + + obj_partner = self.env['res.partner'] + query_get_data = self.env['account.move.line'].with_context(data['form'].get('used_context', {}))._query_get() + data['computed']['move_state'] = ['draft', 'posted'] + if data['form'].get('target_move', 'all') == 'posted': + data['computed']['move_state'] = ['posted'] + result_selection = data['form'].get('result_selection', 'customer') + if result_selection == 'supplier': + data['computed']['ACCOUNT_TYPE'] = ['payable'] + elif result_selection == 'customer': + data['computed']['ACCOUNT_TYPE'] = ['receivable'] + else: + data['computed']['ACCOUNT_TYPE'] = ['payable', 'receivable'] + + self.env.cr.execute(""" + SELECT a.id + FROM account_account a + WHERE a.internal_type IN %s + AND NOT a.deprecated""", (tuple(data['computed']['ACCOUNT_TYPE']),)) + data['computed']['account_ids'] = [a for (a,) in self.env.cr.fetchall()] + params = [tuple(data['computed']['move_state']), tuple(data['computed']['account_ids'])] + query_get_data[2] + reconcile_clause = "" if data['form']['reconciled'] else ' AND "account_move_line".reconciled = false ' + query = """ + SELECT DISTINCT "account_move_line".partner_id + FROM """ + query_get_data[0] + """, account_account AS account, account_move AS am + WHERE "account_move_line".partner_id IS NOT NULL + AND "account_move_line".account_id = account.id + AND am.id = "account_move_line".move_id + AND am.state IN %s + AND "account_move_line".account_id IN %s + AND NOT account.deprecated + AND """ + query_get_data[1] + reconcile_clause + self.env.cr.execute(query, tuple(params)) + #---------------------Taking only selected partners--------------------------- + if data['form']['partner_ids']: + partner_ids = data['form']['partner_ids'] + else: + partner_ids = [res['partner_id'] for res in self.env.cr.dictfetchall()] + #----------------------------------------------------------------------------- + partners = obj_partner.browse(partner_ids) + partners = sorted(partners, key=lambda x: (x.ref, x.name)) + + docargs = { + 'doc_ids': partner_ids, + 'doc_model': self.env['res.partner'], + 'data': data, + 'docs': partners, + 'time': time, + 'lines': self._lines, + 'sum_partner': self._sum_partner, + } + return self.env['report'].render('account.report_partnerledger', docargs) \ No newline at end of file diff --git a/account_partner_ledger_filter/static/description/banner.jpg b/account_partner_ledger_filter/static/description/banner.jpg new file mode 100644 index 000000000..cad4d04ac Binary files /dev/null and b/account_partner_ledger_filter/static/description/banner.jpg differ diff --git a/account_partner_ledger_filter/static/description/cybro_logo.png b/account_partner_ledger_filter/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/account_partner_ledger_filter/static/description/cybro_logo.png differ diff --git a/account_partner_ledger_filter/static/description/icon.png b/account_partner_ledger_filter/static/description/icon.png new file mode 100644 index 000000000..b1256ef4c Binary files /dev/null and b/account_partner_ledger_filter/static/description/icon.png differ diff --git a/account_partner_ledger_filter/static/description/index.html b/account_partner_ledger_filter/static/description/index.html new file mode 100644 index 000000000..9ea2e1f7c --- /dev/null +++ b/account_partner_ledger_filter/static/description/index.html @@ -0,0 +1,68 @@ +
+

Partner Ledger report with Partner Filter

+

Cybrosys Techno Solutions - www.cybrosys.com

+
+ +
+
+
You can generate partner ledger report from partner form and list
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+ +
+
This will open partner ledger report wizard with the selected partner.
+
You can add or remove partner from wizard in case of fault selection
+
+
+
+ + +
+
+ +
+
+
+ +
+

Need Any Help?

+ +
+ diff --git a/account_partner_ledger_filter/static/description/partner_form.png b/account_partner_ledger_filter/static/description/partner_form.png new file mode 100644 index 000000000..33489e711 Binary files /dev/null and b/account_partner_ledger_filter/static/description/partner_form.png differ diff --git a/account_partner_ledger_filter/static/description/partner_list.png b/account_partner_ledger_filter/static/description/partner_list.png new file mode 100644 index 000000000..596a59108 Binary files /dev/null and b/account_partner_ledger_filter/static/description/partner_list.png differ diff --git a/account_partner_ledger_filter/static/description/report_wiz.png b/account_partner_ledger_filter/static/description/report_wiz.png new file mode 100644 index 000000000..ecc6ba734 Binary files /dev/null and b/account_partner_ledger_filter/static/description/report_wiz.png differ diff --git a/account_partner_ledger_filter/views/report.xml b/account_partner_ledger_filter/views/report.xml new file mode 100644 index 000000000..6f79d511b --- /dev/null +++ b/account_partner_ledger_filter/views/report.xml @@ -0,0 +1,25 @@ + + + + + + Partner Ledger + ir.actions.act_window + account.report.partner.ledger + form + form + + {'default_partner_ids':active_ids} + new + + + + + Partner Ledger + client_print_multi + + action + res.partner + + + \ No newline at end of file diff --git a/account_partner_ledger_filter/wizard/__init__.py b/account_partner_ledger_filter/wizard/__init__.py new file mode 100644 index 000000000..de9b8ac41 --- /dev/null +++ b/account_partner_ledger_filter/wizard/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import account_report_partner_ledger diff --git a/account_partner_ledger_filter/wizard/account_report_general_ledger_view.xml b/account_partner_ledger_filter/wizard/account_report_general_ledger_view.xml new file mode 100644 index 000000000..87d691cd5 --- /dev/null +++ b/account_partner_ledger_filter/wizard/account_report_general_ledger_view.xml @@ -0,0 +1,15 @@ + + + + Partner Ledger + account.report.partner.ledger + + + + + + + + + + diff --git a/account_partner_ledger_filter/wizard/account_report_partner_ledger.py b/account_partner_ledger_filter/wizard/account_report_partner_ledger.py new file mode 100644 index 000000000..b8a87fc10 --- /dev/null +++ b/account_partner_ledger_filter/wizard/account_report_partner_ledger.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models + + +class AccountPartnerLedger(models.TransientModel): + _inherit = "account.report.partner.ledger" + + partner_ids = fields.Many2many('res.partner', 'partner_ledger_partner_rel', 'id', 'partner_id', string='Partners') + + def _print_report(self, data): + data = self.pre_print_report(data) + data['form'].update({'reconciled': self.reconciled, 'amount_currency': self.amount_currency, + 'partner_ids': self.partner_ids.ids}) + return self.env['report'].get_action(self, 'account.report_partnerledger', data=data)