diff --git a/account_partner_ledger_filter/__init__.py b/account_partner_ledger_filter/__init__.py new file mode 100644 index 000000000..619210a1f --- /dev/null +++ b/account_partner_ledger_filter/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import wizard +from . import models diff --git a/account_partner_ledger_filter/__manifest__.py b/account_partner_ledger_filter/__manifest__.py new file mode 100644 index 000000000..a5291680e --- /dev/null +++ b/account_partner_ledger_filter/__manifest__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-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': '11.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..33ee74695 --- /dev/null +++ b/account_partner_ledger_filter/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . 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..ddf118a84 --- /dev/null +++ b/account_partner_ledger_filter/models/account_partner_ledger.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +import time +import logging +from odoo import api, models, _ +from odoo.exceptions import UserError + + +_logger = logging.getLogger(__name__) + + +class ReportPartnerLedger(models.AbstractModel): + _inherit = 'report.account.report_partnerledger' + + + @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.")) + + 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".full_reconcile_id IS NULL ' + 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()] + # ----------------------------------------------------------------------------- + # 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 or '', x.name or '')) + + return { + 'doc_ids': partner_ids, + 'doc_model': self.env['res.partner'], + 'data': data, + 'docs': partners, + 'time': time, + 'lines': self._lines, + 'sum_partner': self._sum_partner, + } \ 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..26f213412 --- /dev/null +++ b/account_partner_ledger_filter/static/description/index.html @@ -0,0 +1,62 @@ +
+

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..bbf392466 --- /dev/null +++ b/account_partner_ledger_filter/views/report.xml @@ -0,0 +1,16 @@ + + + + + + + \ 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..370b2f995 --- /dev/null +++ b/account_partner_ledger_filter/wizard/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . 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..25318d218 --- /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..bd67f3dd2 --- /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.ref('account.action_report_partnerledger').report_action(self, data=data)