diff --git a/beesdoo_report/__init__.py b/beesdoo_report/__init__.py new file mode 100644 index 0000000..9e06818 --- /dev/null +++ b/beesdoo_report/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import report \ No newline at end of file diff --git a/beesdoo_report/__openerp__.py b/beesdoo_report/__openerp__.py new file mode 100644 index 0000000..a65c423 --- /dev/null +++ b/beesdoo_report/__openerp__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +{ + 'name': "Beescoop Report Module", + + 'summary': """ + Module that generate report for Beescoop + """, + + 'description': """ + Beescoop Report + """, + + 'author': "Beescoop - Cellule IT", + 'website': "https://github.com/beescoop/Obeesdoo", + + # Categories can be used to filter modules in modules listing + # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml + # for the full list + 'category': 'Point Of Sale', + 'version': '0.1', + + 'depends': ['beesdoo_base', 'beesdoo_pos', 'board'], + + 'data': [ + #YOU PUT YOUR XML HERE + 'report/views/visits.xml', #Should remain the first one + + + 'report/views/board.xml', #Should be after the sql view's views + ], +} + diff --git a/beesdoo_report/report/__init__.py b/beesdoo_report/report/__init__.py new file mode 100644 index 0000000..a232dcd --- /dev/null +++ b/beesdoo_report/report/__init__.py @@ -0,0 +1 @@ +import report_visit diff --git a/beesdoo_report/report/report_visit.py b/beesdoo_report/report/report_visit.py new file mode 100644 index 0000000..60a81c0 --- /dev/null +++ b/beesdoo_report/report/report_visit.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +from openerp import tools +from openerp import models, fields, api + +#---------------- +class ReportVisit(models.Model): + _name = "beesdoo.report.visits" + _description = "Labo Market Visit" + _auto = False + _order = 'week desc' + + week = fields.Date("Week") + type = fields.Char() + visitors = fields.Integer("Visitors") + visits = fields.Integer("Visits") + #gross_sale = fields.Float("Gross Sales") + + def init(self, cr): + # self._table = account_invoice_report + tools.drop_view_if_exists(cr, self._table) + cr.execute("""CREATE or REPLACE VIEW beesdoo_report_visits as ( + select + row_number() over() as id, + week, + type, + visits + from( + select + date_trunc('WEEK', date_order )::date as week, + count (distinct partner_id) + sum (case when partner_id is null then 1 else 0 end ) - 1 as visits, + 'visites_uniques' as type + from + pos_order + group by + date_trunc('WEEK', date_order) + union + select + date_trunc('WEEK', date_order )::date as week, + count (distinct id) as visits, + 'visites' as type + from + pos_order + group by + date_trunc('WEEK', date_order) + ) t + + order by + week, type desc + + )""") \ No newline at end of file diff --git a/beesdoo_report/report/views/board.xml b/beesdoo_report/report/views/board.xml new file mode 100644 index 0000000..5d01f35 --- /dev/null +++ b/beesdoo_report/report/views/board.xml @@ -0,0 +1,41 @@ + + + + Report on visits + beesdoo.report.visits + graph + + + + + Beesdoo Dashboard + board.board + form + +
+ + + + + + + +
+
+
+ + + + Beescoop Dashboard + board.board + form + form + menu + + + + +
\ No newline at end of file diff --git a/beesdoo_report/report/views/visits.xml b/beesdoo_report/report/views/visits.xml new file mode 100644 index 0000000..27421be --- /dev/null +++ b/beesdoo_report/report/views/visits.xml @@ -0,0 +1,45 @@ + + + + + beesdoo.report.visits.pivot + beesdoo.report.visits + + + + + + + + + + + beesdoo.report.visits.graph + beesdoo.report.visits + + + + + + + + + + + + Report on visits + beesdoo.report.visits + pivot,graph + + + + + + + \ No newline at end of file