From ecbe202141dd2e8d966307eed4d8035d2ac29536 Mon Sep 17 00:00:00 2001 From: Hendrix Costa Date: Wed, 5 Oct 2016 19:23:52 -0300 Subject: [PATCH] [ADD] New module pos_session_report --- pos_session_report/README.rst | 84 ++++++++ pos_session_report/__init__.py | 6 + pos_session_report/__openerp__.py | 21 ++ pos_session_report/i18n/pt_BR.po | 152 +++++++++++++++ pos_session_report/models/__init__.py | 6 + pos_session_report/models/pos_session.py | 14 ++ pos_session_report/report/__init__.py | 6 + .../report/details_pos_session_report.py | 68 +++++++ .../report/pos_session_report.xml | 184 ++++++++++++++++++ 9 files changed, 541 insertions(+) create mode 100644 pos_session_report/README.rst create mode 100644 pos_session_report/__init__.py create mode 100644 pos_session_report/__openerp__.py create mode 100644 pos_session_report/i18n/pt_BR.po create mode 100644 pos_session_report/models/__init__.py create mode 100644 pos_session_report/models/pos_session.py create mode 100644 pos_session_report/report/__init__.py create mode 100644 pos_session_report/report/details_pos_session_report.py create mode 100644 pos_session_report/report/pos_session_report.xml diff --git a/pos_session_report/README.rst b/pos_session_report/README.rst new file mode 100644 index 00000000..8fe3d4eb --- /dev/null +++ b/pos_session_report/README.rst @@ -0,0 +1,84 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============== +Pos Session Report Detailed +============== + +This module extends the functionality of Pos Session Sumary +and to allow you to show detailed informations about pos session + +Installation +============ + +To install this module, you need to: + +#. Do this ... + +Configuration +============= + +To configure this module, you need to: + +#. Go to ... + +.. figure:: path/to/local/image.png + :alt: alternative description + :width: 600 px + +Usage +===== + +To use this module, you need to: + +#. Go to ... + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch} + +.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt +.. branch is "8.0" for example + +Known issues / Roadmap +====================== + +* ... + +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 +------------ + +* Hendrix Costa + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://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 https://odoo-community.org. \ No newline at end of file diff --git a/pos_session_report/__init__.py b/pos_session_report/__init__.py new file mode 100644 index 00000000..b5ce654f --- /dev/null +++ b/pos_session_report/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA () +# Hendrix Costa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import report diff --git a/pos_session_report/__openerp__.py b/pos_session_report/__openerp__.py new file mode 100644 index 00000000..095d180a --- /dev/null +++ b/pos_session_report/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA () +# Hendrix Costa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Point of Sale - Session Detailed Report", + "version": "8.0.1.0.0", + "author": "KMEE INFORMATICA LTDA, " + "Odoo Community Association (OCA)", + 'website': 'http://odoo-brasil.org', + "license": "AGPL-3", + "category": "Point Of Sale", + "depends": [ + 'point_of_sale', + ], + 'data': [ + "report/pos_session_report.xml", + ], + "installable": True, +} diff --git a/pos_session_report/i18n/pt_BR.po b/pos_session_report/i18n/pt_BR.po new file mode 100644 index 00000000..3e1c2fb1 --- /dev/null +++ b/pos_session_report/i18n/pt_BR.po @@ -0,0 +1,152 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_journal_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-09-06 18:31+0000\n" +"PO-Revision-Date: 2016-09-06 18:31+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "- Troco" +msgstr "- Troco" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Amount" +msgstr "Valor" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Closing Date" +msgstr "Data de Fechamento" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Currency" +msgstr "Moeda" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Date" +msgstr "Data" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Difference" +msgstr "Diferença" + +#. module: pos_journal_report +#: field:report.pos_journal_report.pos_journal_report,display_name:0 +msgid "Display Name" +msgstr "Display Name" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Ending Balance" +msgstr "Saldo Final" + +#. module: pos_journal_report +#: field:report.pos_journal_report.pos_journal_report,id:0 +msgid "ID" +msgstr "ID" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Journal" +msgstr "Diário" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Journal:" +msgstr "Diário:" + +#. module: pos_journal_report +#: field:report.pos_journal_report.pos_journal_report,__last_update:0 +msgid "Last Modified on" +msgstr "Last Modified on" + +#. module: pos_journal_report +#: model:ir.actions.report.xml,name:pos_journal_report.action_report_pos_journal_report +msgid "Mapa da Caixa" +msgstr "Mapa da Caixa" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Name" +msgstr "Nome" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Opening Date" +msgstr "Data de Abertura" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Point of Sale" +msgstr "Ponto de Venda" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Pos Order" +msgstr "Pos Order" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "QTD Parcelas" +msgstr "QTD Parcelas" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Reference" +msgstr "Referência" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Responsible" +msgstr "Responsável" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Session Summary:" +msgstr "Resumo da sessão :" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Starting Balance" +msgstr "Saldo Inicial" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "State" +msgstr "Situação" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Statement Summary" +msgstr "Resumo declaração" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Status" +msgstr "Situação" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Total Transactions" +msgstr "Transações Totais" + +#. module: pos_journal_report +#: view:website:pos_journal_report.pos_journal_report_document +msgid "Total:" +msgstr "Total:" + diff --git a/pos_session_report/models/__init__.py b/pos_session_report/models/__init__.py new file mode 100644 index 00000000..f1c52160 --- /dev/null +++ b/pos_session_report/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA () +# Hendrix Costa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import pos_session diff --git a/pos_session_report/models/pos_session.py b/pos_session_report/models/pos_session.py new file mode 100644 index 00000000..2c8200cd --- /dev/null +++ b/pos_session_report/models/pos_session.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA () +# Hendrix Costa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import models, fields + + +class PosSession(models.Model): + _inherit = 'pos.session' + + user_id = fields.Many2one('res.users', + default=lambda self: self.env.user, + string='User') diff --git a/pos_session_report/report/__init__.py b/pos_session_report/report/__init__.py new file mode 100644 index 00000000..a25be619 --- /dev/null +++ b/pos_session_report/report/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA () +# Hendrix Costa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import details_pos_session_report diff --git a/pos_session_report/report/details_pos_session_report.py b/pos_session_report/report/details_pos_session_report.py new file mode 100644 index 00000000..cb209785 --- /dev/null +++ b/pos_session_report/report/details_pos_session_report.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA () +# Hendrix Costa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp.report import report_sxw +from openerp import models + + +class DetailsPosSessionReport(report_sxw.rml_parse): + + def _get_qtd_payments(self, line): + if line.amount < 0: + return '' + + for statement_bank_line in line.pos_statement_id.statement_ids: + if statement_bank_line.amount < 0: + return len(line.pos_statement_id.statement_ids)-1 + return len(line.pos_statement_id.statement_ids) + + def _get_account_bank_statement_lines(self): + pos_session_obj = self.pool.get('pos.session').browse( + self.cr, self.uid,self.ids, context='') + statements_lines = [] + lines_done = [] + + for pos_session in pos_session_obj: + for statement in pos_session.statement_ids: + for line in statement.line_ids: + if (not (line.id in lines_done) or line.amount < 0): + result = { + 'id': line.id, + 'name': line.name, + 'date': line.date, + 'ref': line.ref, + 'amount': line.amount, + 'partner_id': line.partner_id, + 'journal_id': line.journal_id, + 'pos_statement_id': line.pos_statement_id, + 'qtd_payments': self._get_qtd_payments(line) + } + statements_lines.append(result) + if line.amount < 0: + lines_done.append(line.id) + else: + lines_done.extend( + line.pos_statement_id.statement_ids.ids + ) + lines_sorted = sorted( + statements_lines, + key=lambda lines_sorted: lines_sorted['qtd_payments'] + ) + return lines_sorted + + def __init__(self, cr, uid, name, context): + super(DetailsPosSessionReport, self).__init__(cr, uid, name, + context=context) + self.localcontext.update({ + 'get_account_bank_statement_lines': + self._get_account_bank_statement_lines, + }) + + +class PosSessionReport(models.AbstractModel): + _name = 'report.pos_session_report.pos_session_report' + _inherit = 'report.abstract_report' + _template = 'pos_session_report.pos_session_report' + _wrapped_report_class = DetailsPosSessionReport diff --git a/pos_session_report/report/pos_session_report.xml b/pos_session_report/report/pos_session_report.xml new file mode 100644 index 00000000..deaf2341 --- /dev/null +++ b/pos_session_report/report/pos_session_report.xml @@ -0,0 +1,184 @@ + + + + + + + + + + + +