Skip to content
Extraits de code Groupes Projets
Valider 4dea03ab rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[update] add links to zones

parent 8754bdfe
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -3,7 +3,7 @@
"summary": "Gestion des flux pour Festa",
"author": "Le Filament",
"website": "https://le-filament.com",
"version": "16.0.1.1.2",
"version": "16.0.1.2.2",
"development_status": "Beta",
"license": "AGPL-3",
"depends": ["api_whattheshop", "hall_flow", "queue_job"],
......
......@@ -8,9 +8,9 @@
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="model_id" ref="model_hall_flow_log" />
<field name="nextcall">01/05/2023 04:00:00</field>
<field name="nextcall">2023-05-03 04:00:00</field>
<field name="state">code</field>
<field name="code">model.cron_wts</field>
<field name="code">model.cron_wts()</field>
</record>
</odoo>
......@@ -18,6 +18,7 @@ class HallFlow(models.Model):
zone_ids = fields.One2many(
comodel_name="hall.flow.zone", inverse_name="hall_id", string="Zones"
)
zone_count = fields.Integer(compute="_compute_zone_count")
# ------------------------------------------------------
# SQL Constrains
......@@ -26,6 +27,9 @@ class HallFlow(models.Model):
# ------------------------------------------------------
# Compute functions
# ------------------------------------------------------
def _compute_zone_count(self):
for hall in self:
hall.zone_count = len(hall.zone_ids)
# ------------------------------------------------------
# Compute functions
......@@ -33,7 +37,8 @@ class HallFlow(models.Model):
def action_view_zones(self):
self.ensure_one()
action = self.env["ir.actions.actions"]._for_xml_id(
"hall_flow_whattheshop.hall_flow_zone_action")
"hall_flow_whattheshop.hall_flow_zone_action"
)
action["domain"] = [("id", "in", self.zone_ids.ids)]
return action
......
......@@ -5,6 +5,7 @@ from dateutil.relativedelta import relativedelta
from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.addons.api_connector.tools.date_utils import utc_to_local
TIMEZONE = "Europe/Paris"
......@@ -50,15 +51,15 @@ class HallFlow(models.Model):
def _check_duplicate(self):
for flow in self:
if flow.zone_id and not flow.sensor_id:
flow_count = self.search_count([
flow_count = self.search_count(
[
("zone_id", "=", flow.zone_id.id),
("flow_type", "=", flow.flow_type),
("date", "=", flow.date),
])
]
)
if flow_count > 1:
raise UserError(_(
"This data already exists."
))
raise UserError(_("This data already exists."))
# ------------------------------------------------------
# Compute functions
......@@ -70,6 +71,7 @@ class HallFlow(models.Model):
)
timezone = self._context.get("tz")
for flow in self:
if flow.date:
local_dt = utc_to_local(flow.date, timezone)
local_time = local_dt.hour + local_dt.minute / 60
if hour_start < local_time < 24.0:
......@@ -80,6 +82,7 @@ class HallFlow(models.Model):
@api.depends("date")
def _compute_slot_id(self):
for flow in self:
if flow.date:
flow.slot_id = flow.slot_id.get_slot(flow.date)
# ------------------------------------------------------
......
......@@ -9,8 +9,16 @@
<field name="inherit_id" ref="hall.hall_form_view" />
<field name="arch" type="xml">
<xpath expr="//button[@name='action_view_contract']" position="after">
<button type="object" class="oe_stat_button" icon="fa-users" name="action_view_zones">
<button
type="object"
class="oe_stat_button"
icon="fa-map-pin"
name="action_view_zones"
>
<div class="o_form_field o_stat_info">
<span class="o_stat_value">
<field name="zone_count" />
</span>
<span class="o_stat_text">Zones</span>
</div>
</button>
......
......@@ -8,7 +8,7 @@
<field name="name">hall.flow.log.tree</field>
<field name="model">hall.flow.log</field>
<field name="arch" type="xml">
<tree create="0" edit="0">
<tree create="0" editable="top">
<field name="date_log" />
<field name="hall_id" />
<field name="create_uid" />
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter