Skip to content
Snippets Groups Projects
Commit 2b06ea1c authored by Benjamin - Le Filament's avatar Benjamin - Le Filament
Browse files

[IMP] visitors and passerby overview

parent 07574202
No related branches found
No related tags found
No related merge requests found
...@@ -75,9 +75,50 @@ class HallContract(models.Model): ...@@ -75,9 +75,50 @@ class HallContract(models.Model):
"hall_ids": self.mapped("hall_id"), "hall_ids": self.mapped("hall_id"),
"company_id": self.env.company, "company_id": self.env.company,
"sales": self.get_overview_sales(), "sales": self.get_overview_sales(),
"flow": self.get_overview_flow(),
"job_ids": job_ids, "job_ids": job_ids,
} }
def get_overview_flow(self):
"""
Get visitor & Passerby data
"""
yesterday = date.today() - relativedelta(days=1)
start_year = date(yesterday.year, 1, 1)
date(yesterday.year, yesterday.month, 1)
flow_ids = self.env["hall.flow"].search(
[
("hall_id", "in", self.mapped("hall_id").ids),
("date", ">=", start_year),
]
)
visitor_ids = flow_ids.filtered(lambda f: f.flow_type == "visitor")
passerby_ids = flow_ids.filtered(lambda f: f.flow_type == "passerby")
return {
"visitor_ids": visitor_ids,
"passerby_ids": passerby_ids,
}
#
#
# {
# "visitor": sum(visitor_ids.filtered(
# lambda f: f.date >= yesterday).mapped("count")),
# "passerby": sum(passerby_ids.filtered(
# lambda f: f.date >= yesterday).mapped("count")),
# },
# "this_month": {
# "visitor": sum(visitor_ids.filtered(
# lambda f: f.date >= start_month).mapped("count")),
# "passerby": sum(passerby_ids.filtered(
# lambda f: f.date >= start_month).mapped("count")),
# },
# "this_year": {
# "visitor": sum(visitor_ids.mapped("count")),
# "passerby": sum(passerby_ids.mapped("count")),
# },
# }
def get_overview_sales(self): def get_overview_sales(self):
""" """
Retourne les datas pour la vue QWEB Retourne les datas pour la vue QWEB
......
...@@ -59,10 +59,15 @@ class AccountInvoiceReport(models.Model): ...@@ -59,10 +59,15 @@ class AccountInvoiceReport(models.Model):
_depends = { _depends = {
"account.move": [ "account.move": [
"contract_id", "period_start", "month_revenue", "month_b2b_revenue", "contract_id",
"period_start",
"month_revenue",
"month_b2b_revenue",
"month_ref_revenue", "month_ref_revenue",
], ],
"account.move.line": ["virtuous_discount_id",], "account.move.line": [
"virtuous_discount_id",
],
"hall.contract": ["hall_id", "commercial_name", "type_job"], "hall.contract": ["hall_id", "commercial_name", "type_job"],
"hall.contract.discount": ["date_discount", "date_discount"], "hall.contract.discount": ["date_discount", "date_discount"],
} }
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
<!-- Global Values --> <!-- Global Values -->
<div class="col-12"> <div class="col-12">
<div class="row"> <div class="row">
<!-- Main KPI -->
<div class="col-12"> <div class="col-12">
<h3 <h3
class="text-uppercase fw-bolder o_horizontal_separator mb-4" class="text-uppercase fw-bolder o_horizontal_separator mb-4"
...@@ -124,6 +125,15 @@ ...@@ -124,6 +125,15 @@
t-set="currency_id" t-set="currency_id"
t-value="values['company_id'].currency_id" t-value="values['company_id'].currency_id"
/> />
<!-- Flow -->
<t
t-set="visitor_ids"
t-value="sum(values['flow']['visitor_ids'].filtered(lambda f: f.date >= date.today() - relativedelta(days=1)).mapped('count'))"
/>
<t
t-set="passerby_ids"
t-value="sum(values['flow']['passerby_ids'].filtered(lambda f: f.date >= date.today() - relativedelta(days=1)).mapped('count'))"
/>
</t> </t>
<!-- Last month --> <!-- Last month -->
<t <t
...@@ -161,6 +171,15 @@ ...@@ -161,6 +171,15 @@
t-set="currency_id" t-set="currency_id"
t-value="values['company_id'].currency_id" t-value="values['company_id'].currency_id"
/> />
<!-- Flow -->
<t
t-set="visitor_ids"
t-value="sum(values['flow']['visitor_ids'].filtered(lambda f: f.date >= date.today().replace(day=1)).mapped('count'))"
/>
<t
t-set="passerby_ids"
t-value="sum(values['flow']['passerby_ids'].filtered(lambda f: f.date >= date.today().replace(day=1)).mapped('count'))"
/>
</t> </t>
<!-- Last Year --> <!-- Last Year -->
<t <t
...@@ -198,6 +217,15 @@ ...@@ -198,6 +217,15 @@
t-set="currency_id" t-set="currency_id"
t-value="values['company_id'].currency_id" t-value="values['company_id'].currency_id"
/> />
<!-- Flow -->
<t
t-set="visitor_ids"
t-value="sum(values['flow']['visitor_ids'].mapped('count'))"
/>
<t
t-set="passerby_ids"
t-value="sum(values['flow']['passerby_ids'].mapped('count'))"
/>
</t> </t>
</div> </div>
</div> </div>
...@@ -508,6 +536,35 @@ ...@@ -508,6 +536,35 @@
t-options='{"widget": "monetary", "display_currency": currency_id}' t-options='{"widget": "monetary", "display_currency": currency_id}'
/> />
</p> </p>
<hr />
<table class="table align-middle table-sm">
<tr>
<td>
<span class="h5">Visiteurs</span>
</td>
<td>
<span class="lead">
<t
t-out="visitor_ids"
t-options='{"widget": "float", "precision": 0}'
/>
</span>
</td>
</tr>
<tr>
<td>
<span class="h5">Passants</span>
</td>
<td>
<span class="lead">
<t
t-out="passerby_ids"
t-options='{"widget": "float", "precision": 0}'
/>
</span>
</td>
</tr>
</table>
</div> </div>
</template> </template>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment