Thibault Francois
8 years ago
6 changed files with 171 additions and 0 deletions
-
2beesdoo_report/__init__.py
-
32beesdoo_report/__openerp__.py
-
1beesdoo_report/report/__init__.py
-
50beesdoo_report/report/report_visit.py
-
41beesdoo_report/report/views/board.xml
-
45beesdoo_report/report/views/visits.xml
@ -0,0 +1,2 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
import report |
@ -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 |
||||
|
], |
||||
|
} |
||||
|
|
@ -0,0 +1 @@ |
|||||
|
import report_visit |
@ -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 |
||||
|
|
||||
|
)""") |
@ -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> |
@ -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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue