diff --git a/pos_report_order_payment/__init__.py b/pos_report_order_payment/__init__.py new file mode 100644 index 00000000..4c4f242f --- /dev/null +++ b/pos_report_order_payment/__init__.py @@ -0,0 +1 @@ +from . import report diff --git a/pos_report_order_payment/__manifest__.py b/pos_report_order_payment/__manifest__.py new file mode 100644 index 00000000..e1840bab --- /dev/null +++ b/pos_report_order_payment/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2020 Iván Todorovich +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Point of Sale Payment Report', + 'summary': 'Analyze point of sale payments', + 'category': 'Point of Sale', + 'version': '12.0.1.0.0', + 'author': 'Druidoo, ' + 'Moka Tourisme, ' + 'Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'website': 'https://github.com/OCA/pos', + 'depends': [ + 'point_of_sale', + ], + 'data': [ + 'security/ir.model.access.csv', + 'report/pos_order_payment_report.xml', + ], +} diff --git a/pos_report_order_payment/i18n/fr.po b/pos_report_order_payment/i18n/fr.po new file mode 100644 index 00000000..b34b8fb6 --- /dev/null +++ b/pos_report_order_payment/i18n/fr.po @@ -0,0 +1,192 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_report_order_payment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-09-04 15:28+0000\n" +"PO-Revision-Date: 2020-09-04 15:28+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_report_order_payment +#: selection:report.pos.order.payment,state:0 +msgid "Cancelled" +msgstr "Annulé" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__company_id +msgid "Company" +msgstr "Société" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__partner_id +msgid "Customer" +msgstr "Client" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: pos_report_order_payment +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Group By" +msgstr "Regrouper par" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__id +msgid "ID" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__invoiced +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +#: selection:report.pos.order.payment,state:0 +msgid "Invoiced" +msgstr "Facturé" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__journal_id +msgid "Journal" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__location_id +msgid "Location" +msgstr "Lieu" + +#. module: pos_report_order_payment +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "My Sales" +msgstr "Mes ventes" + +#. module: pos_report_order_payment +#: selection:report.pos.order.payment,state:0 +msgid "New" +msgstr "Nouveau" + +#. module: pos_report_order_payment +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Not Invoiced" +msgstr "Non facturée" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__order_id +msgid "Order" +msgstr "Commande" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__date +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Order Date" +msgstr "Date de la commande" + +#. module: pos_report_order_payment +#: model:ir.ui.menu,name:pos_report_order_payment.menu_report_pos_order_payment +msgid "Order Payments" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.actions.act_window,name:pos_report_order_payment.action_report_pos_order_payment +msgid "Order Payments Analysis" +msgstr "" + +#. module: pos_report_order_payment +#: selection:report.pos.order.payment,state:0 +msgid "Paid" +msgstr "Payé" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__payment_amount +msgid "Payment Amount" +msgstr "Montant du paiement" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__payment_journal_id +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Payment Journal" +msgstr "Journal des Paiements" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__pos_categ_id +msgid "PoS Category" +msgstr "Catégorie du PdV" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__config_id +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Point of Sale" +msgstr "Point de vente" + +#. module: pos_report_order_payment +#: model:ir.model,name:pos_report_order_payment.model_report_pos_order_payment +msgid "Point of Sale Order Payments Report" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model,name:pos_report_order_payment.model_report_pos_order +msgid "Point of Sale Orders Report" +msgstr "Rapport sur les commandes au point de vente" + +#. module: pos_report_order_payment +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_graph +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_pivot +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Point of Sale Payment Analysis" +msgstr "" + +#. module: pos_report_order_payment +#: selection:report.pos.order.payment,state:0 +msgid "Posted" +msgstr "Comptabilisé" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__pricelist_id +msgid "Pricelist" +msgstr "Liste de prix" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__product_id +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Product" +msgstr "Article" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__product_categ_id +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Product Category" +msgstr "Catégorie d'article" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__product_tmpl_id +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__user_id +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Salesperson" +msgstr "Vendeur" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__session_id +msgid "Session" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__state +msgid "Status" +msgstr "Statut" + diff --git a/pos_report_order_payment/i18n/pos_report_order_payment.pot b/pos_report_order_payment/i18n/pos_report_order_payment.pot new file mode 100644 index 00000000..58a5d8f5 --- /dev/null +++ b/pos_report_order_payment/i18n/pos_report_order_payment.pot @@ -0,0 +1,192 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_report_order_payment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-09-04 15:27+0000\n" +"PO-Revision-Date: 2020-09-04 15:27+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_report_order_payment +#: selection:report.pos.order.payment,state:0 +msgid "Cancelled" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__company_id +msgid "Company" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__partner_id +msgid "Customer" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__display_name +msgid "Display Name" +msgstr "" + +#. module: pos_report_order_payment +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Group By" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__id +msgid "ID" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__invoiced +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +#: selection:report.pos.order.payment,state:0 +msgid "Invoiced" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__journal_id +msgid "Journal" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment____last_update +msgid "Last Modified on" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__location_id +msgid "Location" +msgstr "" + +#. module: pos_report_order_payment +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "My Sales" +msgstr "" + +#. module: pos_report_order_payment +#: selection:report.pos.order.payment,state:0 +msgid "New" +msgstr "" + +#. module: pos_report_order_payment +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Not Invoiced" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__order_id +msgid "Order" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__date +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Order Date" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.ui.menu,name:pos_report_order_payment.menu_report_pos_order_payment +msgid "Order Payments" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.actions.act_window,name:pos_report_order_payment.action_report_pos_order_payment +msgid "Order Payments Analysis" +msgstr "" + +#. module: pos_report_order_payment +#: selection:report.pos.order.payment,state:0 +msgid "Paid" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__payment_amount +msgid "Payment Amount" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__payment_journal_id +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Payment Journal" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__pos_categ_id +msgid "PoS Category" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__config_id +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Point of Sale" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model,name:pos_report_order_payment.model_report_pos_order_payment +msgid "Point of Sale Order Payments Report" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model,name:pos_report_order_payment.model_report_pos_order +msgid "Point of Sale Orders Report" +msgstr "" + +#. module: pos_report_order_payment +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_graph +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_pivot +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Point of Sale Payment Analysis" +msgstr "" + +#. module: pos_report_order_payment +#: selection:report.pos.order.payment,state:0 +msgid "Posted" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__pricelist_id +msgid "Pricelist" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__product_id +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Product" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__product_categ_id +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Product Category" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__product_tmpl_id +msgid "Product Template" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__user_id +#: model_terms:ir.ui.view,arch_db:pos_report_order_payment.view_report_pos_order_payment_search +msgid "Salesperson" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__session_id +msgid "Session" +msgstr "" + +#. module: pos_report_order_payment +#: model:ir.model.fields,field_description:pos_report_order_payment.field_report_pos_order_payment__state +msgid "Status" +msgstr "" + diff --git a/pos_report_order_payment/readme/CONTRIBUTORS.rst b/pos_report_order_payment/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..330c90f2 --- /dev/null +++ b/pos_report_order_payment/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* `Druidoo `_: + * Iván Todorovich + +* `Moka Tourisme `_: + * Grégory Schreiner diff --git a/pos_report_order_payment/readme/DESCRIPTION.rst b/pos_report_order_payment/readme/DESCRIPTION.rst new file mode 100644 index 00000000..f7ab8aa8 --- /dev/null +++ b/pos_report_order_payment/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +Adds views to analyze point of sale payments + +.. figure:: ../static/description/graph.png + +.. figure:: ../static/description/pivot.png diff --git a/pos_report_order_payment/readme/USAGE.rst b/pos_report_order_payment/readme/USAGE.rst new file mode 100644 index 00000000..af228130 --- /dev/null +++ b/pos_report_order_payment/readme/USAGE.rst @@ -0,0 +1 @@ +Go to Point of Sale > Analysis > Order Payments diff --git a/pos_report_order_payment/report/__init__.py b/pos_report_order_payment/report/__init__.py new file mode 100644 index 00000000..0a802d2e --- /dev/null +++ b/pos_report_order_payment/report/__init__.py @@ -0,0 +1 @@ +from . import pos_order_payment_report diff --git a/pos_report_order_payment/report/pos_order_payment_report.py b/pos_report_order_payment/report/pos_order_payment_report.py new file mode 100644 index 00000000..d1154f74 --- /dev/null +++ b/pos_report_order_payment/report/pos_order_payment_report.py @@ -0,0 +1,182 @@ +# Copyright 2020 Iván Todorovich +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models, fields, tools + + +class PosOrderPaymentReport(models.Model): + _name = 'report.pos.order.payment' + _description = "Point of Sale Order Payments Report" + _auto = False + _order = 'date desc' + + date = fields.Datetime( + string='Order Date', + readonly=True, + ) + state = fields.Selection( + [ + ('draft', 'New'), + ('paid', 'Paid'), + ('done', 'Posted'), + ('invoiced', 'Invoiced'), + ('cancel', 'Cancelled'), + ], + string='Status', + readonly=True, + ) + order_id = fields.Many2one( + 'pos.order', + string='Order', + readonly=True, + ) + session_id = fields.Many2one( + 'pos.session', + string='Session', + readonly=True, + ) + partner_id = fields.Many2one( + 'res.partner', + string='Customer', + readonly=True, + ) + pricelist_id = fields.Many2one( + 'product.pricelist', + string='Pricelist', + readonly=True, + ) + user_id = fields.Many2one( + 'res.users', + string='Salesperson', + readonly=True, + ) + location_id = fields.Many2one( + 'stock.location', + string='Location', + readonly=True, + ) + company_id = fields.Many2one( + 'res.company', + string='Company', + readonly=True, + ) + journal_id = fields.Many2one( + 'account.journal', + string='Journal', + readonly=True, + ) + config_id = fields.Many2one( + 'pos.config', + string='Point of Sale', + readonly=True, + ) + pos_categ_id = fields.Many2one( + 'pos.category', + string='PoS Category', + readonly=True, + ) + product_id = fields.Many2one( + 'product.product', + string='Product', + readonly=True, + ) + product_tmpl_id = fields.Many2one( + 'product.template', + string='Product Template', + readonly=True, + ) + product_categ_id = fields.Many2one( + 'product.category', + string='Product Category', + readonly=True, + ) + payment_journal_id = fields.Many2one( + "account.journal", + string="Payment Journal", + readonly=True, + ) + payment_amount = fields.Float( + string="Paid Amount", + readonly=True, + ) + invoiced = fields.Boolean( + readonly=True, + ) + + def _select(self): + return """ + SELECT + ROW_NUMBER() OVER() AS id, + s.date_order AS date, + s.id as order_id, + s.partner_id AS partner_id, + s.state AS state, + s.user_id AS user_id, + s.location_id AS location_id, + s.company_id AS company_id, + s.sale_journal AS journal_id, + l.product_id AS product_id, + pt.categ_id AS product_categ_id, + p.product_tmpl_id, + ps.config_id, + pt.pos_categ_id, + s.pricelist_id, + s.session_id, + s.invoice_id IS NOT NULL AS invoiced, + st.journal_id AS payment_journal_id, + st.amount AS payment_amount + """ + + def _from(self): + return """ + FROM pos_order_line AS l + LEFT JOIN pos_order s ON (s.id = l.order_id) + LEFT JOIN product_product p ON (l.product_id = p.id) + LEFT JOIN product_template pt ON (p.product_tmpl_id = pt.id) + LEFT JOIN uom_uom u ON (u.id = pt.uom_id) + LEFT JOIN pos_session ps ON (s.session_id = ps.id) + INNER JOIN (%s) st ON (st.pos_line_id = l.id) + """ % (self._payment_query()) + + def _payment_query(self): + """ + Returns a query that distributes the pos.order payments + among the pos.order.lines + """ + return """ + SELECT + pol.id AS pos_line_id, + sl.id AS statement_line_id, + st.journal_id AS journal_id, + ( + sl.amount / po.amount_total * pol.price_subtotal_incl + ) AS amount + FROM pos_order_line AS pol + INNER JOIN pos_order AS po + ON pol.order_id = po.id + INNER JOIN account_bank_statement_line AS sl + ON pol.order_id = sl.pos_statement_id + INNER JOIN account_bank_statement AS st + ON st.id = sl.statement_id + """ + + def _group_by(self): + return "" + + def _having(self): + return "" + + @api.model_cr + def init(self): + tools.drop_view_if_exists(self._cr, self._table) + self._cr.execute(""" + CREATE OR REPLACE VIEW %s AS ( + %s + %s + %s + %s + ) + """ % ( + self._table, + self._select(), self._from(), self._group_by(), self._having(), + )) diff --git a/pos_report_order_payment/report/pos_order_payment_report.xml b/pos_report_order_payment/report/pos_order_payment_report.xml new file mode 100644 index 00000000..ad81049d --- /dev/null +++ b/pos_report_order_payment/report/pos_order_payment_report.xml @@ -0,0 +1,67 @@ + + + + + report.pos.order.payment + + + + + + + + + + + report.pos.order.payment + + + + + + + + + + report.pos.order.payment + + + + + + + + + + + + + + + + + + + + + + + + + + + Order Payments Analysis + report.pos.order.payment + form + graph,pivot + {'group_by_no_leaf': 1, 'group_by': []} + + + + + diff --git a/pos_report_order_payment/security/ir.model.access.csv b/pos_report_order_payment/security/ir.model.access.csv new file mode 100644 index 00000000..c6723204 --- /dev/null +++ b/pos_report_order_payment/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_report_pos_order_payment,report.pos.order.payment,model_report_pos_order_payment,point_of_sale.group_pos_user,1,1,1,1 diff --git a/pos_report_order_payment/static/description/graph.png b/pos_report_order_payment/static/description/graph.png new file mode 100644 index 00000000..7b2d9cf2 Binary files /dev/null and b/pos_report_order_payment/static/description/graph.png differ diff --git a/pos_report_order_payment/static/description/pivot.png b/pos_report_order_payment/static/description/pivot.png new file mode 100644 index 00000000..ca25d19c Binary files /dev/null and b/pos_report_order_payment/static/description/pivot.png differ