Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
H
hall_flow_whattheshop
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Le Filament
Hall management
hall_flow_whattheshop
Validations
33d7674c
Valider
33d7674c
rédigé
Il y a 2 ans
par
Benjamin - Le Filament
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[add] cron import datas
parent
1647744f
Branches
Branches contenant la validation
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
__manifest__.py
+1
-1
1 ajout, 1 suppression
__manifest__.py
data/cron_import_data_wts.xml
+14
-15
14 ajouts, 15 suppressions
data/cron_import_data_wts.xml
models/hall_flow_log.py
+111
-1
111 ajouts, 1 suppression
models/hall_flow_log.py
avec
126 ajouts
et
17 suppressions
__manifest__.py
+
1
−
1
Voir le fichier @
33d7674c
...
...
@@ -3,7 +3,7 @@
"
summary
"
:
"
Gestion des flux pour Festa
"
,
"
author
"
:
"
Le Filament
"
,
"
website
"
:
"
https://le-filament.com
"
,
"
version
"
:
"
16.0.1.
0
.0
"
,
"
version
"
:
"
16.0.1.
1
.0
"
,
"
development_status
"
:
"
Beta
"
,
"
license
"
:
"
AGPL-3
"
,
"
depends
"
:
[
"
api_whattheshop
"
,
"
hall_flow
"
,
"
queue_job
"
],
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
data/cron_import_data_wts.xml
+
14
−
15
Voir le fichier @
33d7674c
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data
noupdate=
"1"
>
<record
id=
"$CronName$_cron"
forcecreate=
'True'
model=
"ir.cron"
>
<field
name=
"name"
>
$CronName$
</field>
<odoo
noupdate=
"1"
>
<record
id=
"wtz_import_datas_cron"
forcecreate=
'True'
model=
"ir.cron"
>
<field
name=
"name"
>
What The Shop: import des données
</field>
<field
eval=
"True"
name=
"active"
/>
<field
name=
"user_id"
ref=
"base.user_root"
/>
<field
name=
"interval_number"
>
5
</field>
<field
name=
"interval_type"
>
minute
s
</field>
<field
name=
"interval_number"
>
1
</field>
<field
name=
"interval_type"
>
day
s
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"model_id"
ref=
"model_$ProjectName$_$ModelName$"
/>
<field
name=
"model_id"
ref=
"model_hall_flow_log"
/>
<field
name=
"nextcall"
>
01/05/2023 04:00:00
</field>
<field
name=
"state"
>
code
</field>
<field
name=
"code"
>
model.
$MethodName$()
</field>
<field
name=
"code"
>
model.
cron_wts
</field>
</record>
$END$
</data>
</odoo>
Ce diff est replié.
Cliquez pour l'agrandir.
models/hall_flow_log.py
+
111
−
1
Voir le fichier @
33d7674c
...
...
@@ -28,11 +28,121 @@ class HallFlowLog(models.Model):
# ------------------------------------------------------
# Business functions
# ------------------------------------------------------
@api.model
def
import_wts_data
(
self
,
hall_ids
=
None
,
start_date
=
None
,
end_date
=
None
):
"""
Import data for specified halls and period
:param object hall_ids: hall object if specified else all
:param datetime start_date: UTC start period
:param datetime end_date: UTC end period
"""
if
not
hall_ids
:
hall_ids
=
self
.
env
[
"
hall.hall
"
].
search
([])
log_ids
=
self
for
hall
in
hall_ids
:
if
hall
.
zone_ids
:
last_import
=
self
.
_get_last_import
(
hall
)
if
start_date
and
last_import
and
start_date
<
last_import
:
raise
UserError
(
_
(
"
Un import existe déjà pour cette date %s
"
)
%
(
fields
.
Date
.
to_string
(
start_date
)))
if
not
start_date
:
start_date
=
last_import
+
relativedelta
(
days
=
1
)
if
not
end_date
:
end_date
=
fields
.
Date
.
today
()
-
relativedelta
(
days
=
1
)
log_id
=
self
.
create
({
"
date_log
"
:
fields
.
Datetime
.
now
(),
"
date_start
"
:
start_date
,
"
date_end
"
:
end_date
,
"
hall_id
"
:
hall
.
id
})
for
zone
in
hall
.
zone_ids
:
# Retrieve visitor datas
visit_desc
=
log_id
.
hall_id
.
name
+
"
-
"
+
zone
.
name
+
"
- Visiteurs
"
zone
.
with_delay
(
description
=
visit_desc
).
_wts_create_visitor
(
start_date
,
end_date
,
log_id
)
# Retrieve passer_by datas
delta_days
=
(
end_date
-
start_date
).
days
pass_desc
=
log_id
.
hall_id
.
name
+
"
-
"
+
zone
.
name
+
"
- Passants
"
if
delta_days
>
0
:
start_passerby
=
start_date
for
day
in
range
(
0
,
delta_days
):
zone
.
with_delay
(
description
=
pass_desc
).
_wts_create_passerby
(
start_passerby
,
end_date
,
log_id
)
start_passerby
=
start_passerby
+
relativedelta
(
days
=
1
,
hours
=
1
)
else
:
zone
.
with_delay
(
description
=
pass_desc
).
_wts_create_passerby
(
start_date
,
end_date
,
log_id
)
# Retrieve In/Out datas
for
sensor
in
zone
.
sensor_ids
.
filtered
(
lambda
s
:
s
.
sensor_type
==
"
sensor
"
):
description
=
log_id
.
hall_id
.
name
+
"
-
"
+
sensor
.
name
sensor
.
with_delay
(
description
=
description
).
_wts_create_inout
(
start_date
,
end_date
,
log_id
)
log_ids
+=
log_id
return
log_ids
# ------------------------------------------------------
#
API
function
#
CRON
function
s
# ------------------------------------------------------
def
cron_wts
(
self
,
days
=
None
,
interval
=
None
):
"""
WTS datas retrieve CRON
:param integer days: days before today if specified
:param integer interval: number of days to retrieve
"""
now
=
fields
.
Datetime
.
now
()
day_end
=
float
(
self
.
env
[
"
ir.config_parameter
"
].
sudo
().
get_param
(
"
hall.day_end
"
)
)
hour_end
=
int
(
day_end
)
minute_end
=
int
((
day_end
-
hour_end
)
*
60
)
day_start
=
float
(
self
.
env
[
"
ir.config_parameter
"
].
sudo
().
get_param
(
"
hall.day_start
"
)
)
hour_start
=
int
(
day_start
)
minute_start
=
int
((
day_start
-
hour_start
)
*
60
)
timezone
=
self
.
_context
.
get
(
"
tz
"
)
if
self
.
_context
.
get
(
"
tz
"
)
else
"
Europe/Paris
"
end_date
=
local_to_utc
(
now
.
replace
(
hour
=
hour_end
+
1
,
minute
=
minute_end
,
second
=
0
),
timezone
)
if
now
<
end_date
:
end_date
=
end_date
-
relativedelta
(
days
=
1
)
if
days
:
end_date
=
end_date
-
relativedelta
(
days
=
days
)
start_date
=
(
end_date
-
relativedelta
(
days
=
1
)).
replace
(
hour
=
hour_start
,
minute
=
minute_start
)
start_date
=
local_to_utc
(
start_date
,
timezone
)
if
interval
and
interval
>
1
:
start_date
=
start_date
-
relativedelta
(
days
=
interval
)
end_date
=
end_date
-
relativedelta
(
days
=
interval
)
for
day
in
range
(
0
,
interval
):
self
.
import_wts_data
(
start_date
=
start_date
,
end_date
=
end_date
)
start_date
=
start_date
+
relativedelta
(
days
=
1
)
end_date
=
end_date
+
relativedelta
(
days
=
1
)
else
:
self
.
import_wts_data
(
start_date
=
start_date
,
end_date
=
end_date
)
# ------------------------------------------------------
# Common functions
# ------------------------------------------------------
def
_get_last_import
(
self
,
hall_id
):
last_log_id
=
self
.
search
(
[(
"
hall_id
"
,
"
=
"
,
hall_id
.
id
)],
order
=
"
date_end desc
"
,
limit
=
1
)
return
last_log_id
.
date_end
if
last_log_id
else
False
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter