Browse Source

[ADD] first dashboard

pull/14/head
Thibault Francois 8 years ago
parent
commit
4c88c2d4ec
  1. 2
      beesdoo_report/__init__.py
  2. 32
      beesdoo_report/__openerp__.py
  3. 1
      beesdoo_report/report/__init__.py
  4. 50
      beesdoo_report/report/report_visit.py
  5. 41
      beesdoo_report/report/views/board.xml
  6. 45
      beesdoo_report/report/views/visits.xml

2
beesdoo_report/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import report

32
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
],
}

1
beesdoo_report/report/__init__.py

@ -0,0 +1 @@
import report_visit

50
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
)""")

41
beesdoo_report/report/views/board.xml

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.actions.act_window" id="beesdoo_report_visits_action_board">
<field name="name">Report on visits</field>
<field name="res_model">beesdoo.report.visits</field>
<field name="view_mode">graph</field>
</record>
<record model="ir.ui.view" id="board_pos_beesdoo_form">
<field name="name">Beesdoo Dashboard</field>
<field name="model">board.board</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Dashboard">
<board style="1-1">
<column>
<action string="Visits"
name="%(beesdoo_report_visits_action_board)d" />
</column>
<column>
</column>
</board>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="open_board_pos_beesdoo">
<field name="name">Beescoop Dashboard</field>
<field name="res_model">board.board</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="usage">menu</field>
<field name="view_id" ref="board_pos_beesdoo_form" />
</record>
<menuitem name="General Dashboard" parent="base.menu_reporting_dashboard"
action="open_board_pos_beesdoo" sequence="1"
id="beesdoo_general_dashboard" />
</odoo>

45
beesdoo_report/report/views/visits.xml

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- vue -->
<record model="ir.ui.view" id="beesdoo_report_visits_pivot">
<field name="name">beesdoo.report.visits.pivot</field>
<field name="model">beesdoo.report.visits</field>
<field name="arch" type="xml">
<pivot>
<field name="week" />
<field name="type" type="column"/>
<field name="visits" type="measure"/>
</pivot>
</field>
</record>
<record model="ir.ui.view" id="beesdoo_report_visits_graph">
<field name="name">beesdoo.report.visits.graph</field>
<field name="model">beesdoo.report.visits</field>
<field name="arch" type="xml">
<graph type="bar" stacked="False">
<field name="week" />
<field name="type" />
<field name="visits" type="measure"/>
</graph>
</field>
</record>
<!-- Action -->
<record model="ir.actions.act_window" id="beesdoo_report_visits_action">
<field name="name">Report on visits</field>
<field name="res_model">beesdoo.report.visits</field>
<field name="view_mode">pivot,graph</field>
</record>
<!-- ir.ui.menu -->
<menuitem id="beesdoo_report"
parent="base.menu_reporting_config"
name="Beesdoo report" />
<menuitem id="beesdoo_report_visit"
parent="beesdoo_report"
name="Visits report"
action="beesdoo_report_visits_action" />
</odoo>
Loading…
Cancel
Save