From 248fb56ff88333c6be58309cffa0e4f08402d0eb Mon Sep 17 00:00:00 2001 From: Darshan Patel Date: Thu, 28 Jan 2016 16:25:38 +0530 Subject: [PATCH 1/3] [ADD] : Added account_report_entries_hooks module --- account_report_entries_hooks/__init__.py | 6 ++ account_report_entries_hooks/__openerp__.py | 21 ++++++ .../report/__init__.py | 6 ++ .../report/account_entries_report.py | 75 +++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 account_report_entries_hooks/__init__.py create mode 100644 account_report_entries_hooks/__openerp__.py create mode 100644 account_report_entries_hooks/report/__init__.py create mode 100644 account_report_entries_hooks/report/account_entries_report.py diff --git a/account_report_entries_hooks/__init__.py b/account_report_entries_hooks/__init__.py new file mode 100644 index 00000000..d365a10a --- /dev/null +++ b/account_report_entries_hooks/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import report diff --git a/account_report_entries_hooks/__openerp__.py b/account_report_entries_hooks/__openerp__.py new file mode 100644 index 00000000..c26c7379 --- /dev/null +++ b/account_report_entries_hooks/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + 'name' : 'Account Report Entries Hooks', + 'version' : '8.0.1.0.0', + "author": "Eficent Business and IT Consulting Services S.L., " + "Serpent Consulting Services Pvt. Ltd.," + "Odoo Community Association (OCA)", + 'category' : 'Accounting & Finance', + 'description' : """ + This module + """, + "website": "http://www.eficent.com", + "license": "AGPL-3", + 'depends' : ['account'], + 'installable': True, + 'auto_install': False, +} diff --git a/account_report_entries_hooks/report/__init__.py b/account_report_entries_hooks/report/__init__.py new file mode 100644 index 00000000..3e233f12 --- /dev/null +++ b/account_report_entries_hooks/report/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import account_entries_report diff --git a/account_report_entries_hooks/report/account_entries_report.py b/account_report_entries_hooks/report/account_entries_report.py new file mode 100644 index 00000000..1ecf89a6 --- /dev/null +++ b/account_report_entries_hooks/report/account_entries_report.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from openerp import tools +from openerp import models +import openerp.addons.decimal_precision as dp + + +class account_entries_report(models.Model): + _inherit = "account.entries.report" + + def _select(self): + select_str = """ + SELECT + l.id as id, + am.date as date, + l.date_maturity as date_maturity, + l.date_created as date_created, + am.ref as ref, + am.state as move_state, + l.state as move_line_state, + l.reconcile_id as reconcile_id, + l.partner_id as partner_id, + l.product_id as product_id, + l.product_uom_id as product_uom_id, + am.company_id as company_id, + am.journal_id as journal_id, + p.fiscalyear_id as fiscalyear_id, + am.period_id as period_id, + l.account_id as account_id, + l.analytic_account_id as analytic_account_id, + a.type as type, + a.user_type as user_type, + 1 as nbr, + l.quantity as quantity, + l.currency_id as currency_id, + l.amount_currency as amount_currency, + l.debit as debit, + l.credit as credit, + coalesce(l.debit, 0.0) - coalesce(l.credit, 0.0) as balance + """ + return select_str + + def _from(self): + from_str=""" + FROM + account_move_line l + left join account_account a on (l.account_id = a.id) + left join account_move am on (am.id=l.move_id) + left join account_period p on (am.period_id=p.id) + where l.state != 'draft' + """ + return from_str + + def _where(self): + where_str = """ + """ + return where_str + + def _group_by(self): + group_by_str = """ + """ + return group_by_str + + def init(self, cr): + tools.drop_view_if_exists(cr, self._table) + cr.execute("""CREATE or REPLACE VIEW %s as ( + %s + %s + %s + %s + )""" % (self._table, self._select(), self._from(), self._where(), + self._group_by())) From ae73680fe63b39e9699b168c702eb635388014d6 Mon Sep 17 00:00:00 2001 From: Darshan Patel Date: Fri, 29 Jan 2016 19:25:44 +0530 Subject: [PATCH 2/3] [ADD] Added Readme file --- account_entries_report_hooks/README.rst | 69 +++++++++++++++++++ .../__init__.py | 0 .../__openerp__.py | 2 +- .../report/__init__.py | 0 .../report/account_entries_report.py | 0 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 account_entries_report_hooks/README.rst rename {account_report_entries_hooks => account_entries_report_hooks}/__init__.py (100%) rename {account_report_entries_hooks => account_entries_report_hooks}/__openerp__.py (93%) rename {account_report_entries_hooks => account_entries_report_hooks}/report/__init__.py (100%) rename {account_report_entries_hooks => account_entries_report_hooks}/report/account_entries_report.py (100%) diff --git a/account_entries_report_hooks/README.rst b/account_entries_report_hooks/README.rst new file mode 100644 index 00000000..7143eb35 --- /dev/null +++ b/account_entries_report_hooks/README.rst @@ -0,0 +1,69 @@ +.. image:: https://img.shields.io/badge/license-AGPLv3-blue.svg + :target: https://www.gnu.org/licenses/agpl.html + :alt: License: AGPL-3 + +=============================== +Account Entries Report Hooks +=============================== + +This module extends the functionality of account.entries.report module +which intends to override it in order to support and allow you to extend +it by other modules that want to add or change the standard behaviour. + +Installation +============ + +No external library is used. + +Configuration +============= + +To configure this module, you need to: + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/91/9.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed `feedback +`_. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Eficent Business and IT Consulting Services S.L. +* Serpent Consulting Services Pvt. Ltd. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. \ No newline at end of file diff --git a/account_report_entries_hooks/__init__.py b/account_entries_report_hooks/__init__.py similarity index 100% rename from account_report_entries_hooks/__init__.py rename to account_entries_report_hooks/__init__.py diff --git a/account_report_entries_hooks/__openerp__.py b/account_entries_report_hooks/__openerp__.py similarity index 93% rename from account_report_entries_hooks/__openerp__.py rename to account_entries_report_hooks/__openerp__.py index c26c7379..bba15eaf 100644 --- a/account_report_entries_hooks/__openerp__.py +++ b/account_entries_report_hooks/__openerp__.py @@ -4,7 +4,7 @@ # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { - 'name' : 'Account Report Entries Hooks', + 'name' : 'Account Entries Report Hooks', 'version' : '8.0.1.0.0', "author": "Eficent Business and IT Consulting Services S.L., " "Serpent Consulting Services Pvt. Ltd.," diff --git a/account_report_entries_hooks/report/__init__.py b/account_entries_report_hooks/report/__init__.py similarity index 100% rename from account_report_entries_hooks/report/__init__.py rename to account_entries_report_hooks/report/__init__.py diff --git a/account_report_entries_hooks/report/account_entries_report.py b/account_entries_report_hooks/report/account_entries_report.py similarity index 100% rename from account_report_entries_hooks/report/account_entries_report.py rename to account_entries_report_hooks/report/account_entries_report.py From ea81cfb7ddd5a207cff16cf75a2bd88239aac655 Mon Sep 17 00:00:00 2001 From: Darshan Patel Date: Mon, 1 Feb 2016 16:15:58 +0530 Subject: [PATCH 3/3] [IMP] : Modified Readme file --- account_entries_report_hooks/README.rst | 17 +++++++++++------ account_entries_report_hooks/__init__.py | 2 +- account_entries_report_hooks/__openerp__.py | 2 +- account_entries_report_hooks/report/__init__.py | 2 +- .../report/account_entries_report.py | 5 +++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/account_entries_report_hooks/README.rst b/account_entries_report_hooks/README.rst index 7143eb35..404d15ed 100644 --- a/account_entries_report_hooks/README.rst +++ b/account_entries_report_hooks/README.rst @@ -6,9 +6,9 @@ Account Entries Report Hooks =============================== -This module extends the functionality of account.entries.report module -which intends to override it in order to support and allow you to extend -it by other modules that want to add or change the standard behaviour. +This model extends the functionality of the "Account Entries Report" +by overriding the standard query with a new one that will allow other +modules to extend more flexibly. Installation ============ @@ -18,14 +18,19 @@ No external library is used. Configuration ============= -To configure this module, you need to: +In order to extend the Account Entries Report, you need to: +- Include this module as dependency in your own module +- Inherit from "account.entries.report" module +- Add your own fields, as needed +- Implement one of the new methods _select, _from, _where, _group_by, calling +first to the super() method and then adding the extra string as needed. Usage ===== .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/91/9.0 + :target: https://runbot.odoo-community.org/runbot/91/8.0 Bug Tracker =========== @@ -37,7 +42,7 @@ help us smashing it by providing a detailed and welcomed `feedback `_. +8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. Credits ======= diff --git a/account_entries_report_hooks/__init__.py b/account_entries_report_hooks/__init__.py index d365a10a..3fd88c48 100644 --- a/account_entries_report_hooks/__init__.py +++ b/account_entries_report_hooks/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # © 2015 Eficent Business and IT Consulting Services S.L. - # Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2015 Serpent Consulting Services Pvt. Ltd. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import report diff --git a/account_entries_report_hooks/__openerp__.py b/account_entries_report_hooks/__openerp__.py index bba15eaf..55cbf38c 100644 --- a/account_entries_report_hooks/__openerp__.py +++ b/account_entries_report_hooks/__openerp__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # © 2015 Eficent Business and IT Consulting Services S.L. - # Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2015 Serpent Consulting Services Pvt. Ltd. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { 'name' : 'Account Entries Report Hooks', diff --git a/account_entries_report_hooks/report/__init__.py b/account_entries_report_hooks/report/__init__.py index 3e233f12..590eba3f 100644 --- a/account_entries_report_hooks/report/__init__.py +++ b/account_entries_report_hooks/report/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # © 2015 Eficent Business and IT Consulting Services S.L. - # Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2015 Serpent Consulting Services Pvt. Ltd. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import account_entries_report diff --git a/account_entries_report_hooks/report/account_entries_report.py b/account_entries_report_hooks/report/account_entries_report.py index 1ecf89a6..7b0e53dc 100644 --- a/account_entries_report_hooks/report/account_entries_report.py +++ b/account_entries_report_hooks/report/account_entries_report.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # © 2015 Eficent Business and IT Consulting Services S.L. - # Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2015 Serpent Consulting Services Pvt. Ltd. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from openerp import tools from openerp import models @@ -50,12 +50,13 @@ class account_entries_report(models.Model): left join account_account a on (l.account_id = a.id) left join account_move am on (am.id=l.move_id) left join account_period p on (am.period_id=p.id) - where l.state != 'draft' + """ return from_str def _where(self): where_str = """ + where l.state != 'draft' """ return where_str