Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
B
bluemind4-connector
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
bluemind4-connector
Validations
25aefeac
Valider
25aefeac
rédigé
Il y a 3 ans
par
Rémi - Le Filament
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[ADD] Manager organizer and extra fields
parent
4d8dee24
Aucune branche associée trouvée
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
README.rst
+24
-4
24 ajouts, 4 suppressions
README.rst
models/calendar_event.py
+25
-3
25 ajouts, 3 suppressions
models/calendar_event.py
models/res_users.py
+28
-13
28 ajouts, 13 suppressions
models/res_users.py
avec
77 ajouts
et
20 suppressions
README.rst
+
24
−
4
Voir le fichier @
25aefeac
...
@@ -22,10 +22,30 @@ At user lever, you need to define :
...
@@ -22,10 +22,30 @@ At user lever, you need to define :
- login user (e.g. michel@example.org)
- login user (e.g. michel@example.org)
- login password or API key
- login password or API key
Exemple
Limitations
=======
===========
Currently, from all the fields in Bluemind event
- the following are filled with default value :
- priority = 5
- status = Confirmed
- sequence = 0
- draft = False
- transparency = Opaque
- the following are not filled (and therefore removed from Bluemind when updated from Odoo):
- alarm
- attendees
- categories
- exdate
- rdate
- conference
- attachments
Exceptions on recurrencies are not managed, nor are attendees for now.
In order to avoid having multiple events in Odoo for the same event, it is only created if :
- user in Odoo = Organizer from Bluemind
- or Organizer from Bluemind is not part of Odoo users (and in this case, the first user to create the event is set as reponsible in Odoo)
Credits
Credits
=======
=======
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
models/calendar_event.py
+
25
−
3
Voir le fichier @
25aefeac
...
@@ -12,11 +12,15 @@ from netbluemind.calendar.api.VEventChanges import VEventChanges
...
@@ -12,11 +12,15 @@ from netbluemind.calendar.api.VEventChanges import VEventChanges
from
netbluemind.calendar.api.VEventChangesItemAdd
import
VEventChangesItemAdd
from
netbluemind.calendar.api.VEventChangesItemAdd
import
VEventChangesItemAdd
from
netbluemind.calendar.api.VEventChangesItemModify
import
VEventChangesItemModify
from
netbluemind.calendar.api.VEventChangesItemModify
import
VEventChangesItemModify
from
netbluemind.calendar.api.VEventSeries
import
VEventSeries
from
netbluemind.calendar.api.VEventSeries
import
VEventSeries
from
netbluemind.calendar.api.VEventTransparency
import
VEventTransparency
from
netbluemind.core.api.date.BmDateTime
import
BmDateTime
from
netbluemind.core.api.date.BmDateTime
import
BmDateTime
from
netbluemind.core.api.date.BmDateTimePrecision
import
BmDateTimePrecision
from
netbluemind.core.api.date.BmDateTimePrecision
import
BmDateTimePrecision
from
netbluemind.icalendar.api.ICalendarElementClassification
import
(
from
netbluemind.icalendar.api.ICalendarElementClassification
import
(
ICalendarElementClassification
,
ICalendarElementClassification
,
)
)
from
netbluemind.icalendar.api.ICalendarElementOrganizer
import
(
ICalendarElementOrganizer
,
)
from
netbluemind.icalendar.api.ICalendarElementRRule
import
ICalendarElementRRule
from
netbluemind.icalendar.api.ICalendarElementRRule
import
ICalendarElementRRule
from
netbluemind.icalendar.api.ICalendarElementRRuleFrequency
import
(
from
netbluemind.icalendar.api.ICalendarElementRRuleFrequency
import
(
ICalendarElementRRuleFrequency
,
ICalendarElementRRuleFrequency
,
...
@@ -24,6 +28,7 @@ from netbluemind.icalendar.api.ICalendarElementRRuleFrequency import (
...
@@ -24,6 +28,7 @@ from netbluemind.icalendar.api.ICalendarElementRRuleFrequency import (
from
netbluemind.icalendar.api.ICalendarElementRRuleWeekDay
import
(
from
netbluemind.icalendar.api.ICalendarElementRRuleWeekDay
import
(
ICalendarElementRRuleWeekDay
,
ICalendarElementRRuleWeekDay
,
)
)
from
netbluemind.icalendar.api.ICalendarElementStatus
import
ICalendarElementStatus
from
netbluemind.python.client
import
ServerFault
from
netbluemind.python.client
import
ServerFault
from
pytz
import
timezone
from
pytz
import
timezone
...
@@ -44,7 +49,7 @@ PRIVACY_CONVERTER_O2B = {
...
@@ -44,7 +49,7 @@ PRIVACY_CONVERTER_O2B = {
}
}
# TODO: manage attendee_ids,
organizer, alarm_ids, priority, statu
s, categories, attachments ?
# TODO: manage attendee_ids,
alarm_id
s, categories, attachments ?
# TODO: check if recurrency properly working without exceptions
# TODO: check if recurrency properly working without exceptions
# TODO: manage exceptions in recurrencies
# TODO: manage exceptions in recurrencies
class
CalendarEvent
(
models
.
Model
):
class
CalendarEvent
(
models
.
Model
):
...
@@ -53,10 +58,12 @@ class CalendarEvent(models.Model):
...
@@ -53,10 +58,12 @@ class CalendarEvent(models.Model):
"""
"""
This inheriting class adds 1 field to calendar.event table :
This inheriting class adds 1 field to calendar.event table :
* bluemind_id = Unique identifier of event in Bluemind
* bluemind_id = Unique identifier of event in Bluemind
* url = URL from event in Bluemind
It also adds a number of methods to transform events between Bluemind and Odoo formats
It also adds a number of methods to transform events between Bluemind and Odoo formats
"""
"""
bluemind_id
=
fields
.
Char
(
"
Bluemind Event ID
"
)
bluemind_id
=
fields
.
Char
(
"
Bluemind Event ID
"
)
url
=
fields
.
Char
(
"
URL
"
)
def
_bm_to_odoo_values
(
self
,
bm_event
):
def
_bm_to_odoo_values
(
self
,
bm_event
):
"""
"""
...
@@ -73,8 +80,7 @@ class CalendarEvent(models.Model):
...
@@ -73,8 +80,7 @@ class CalendarEvent(models.Model):
),
),
"
location
"
:
bm_event
.
value
.
main
.
location
,
"
location
"
:
bm_event
.
value
.
main
.
location
,
"
description
"
:
bm_event
.
value
.
main
.
description
,
"
description
"
:
bm_event
.
value
.
main
.
description
,
"
user_id
"
:
self
.
env
.
user
.
id
,
"
url
"
:
bm_event
.
value
.
main
.
url
,
"
create_uid
"
:
self
.
env
.
user
.
id
,
}
}
# Dates handling, with timezones
# Dates handling, with timezones
...
@@ -152,6 +158,22 @@ class CalendarEvent(models.Model):
...
@@ -152,6 +158,22 @@ class CalendarEvent(models.Model):
bm_event
.
main
.
classification
=
ICalendarElementClassification
(
bm_event
.
main
.
classification
=
ICalendarElementClassification
(
PRIVACY_CONVERTER_O2B
.
get
(
event
.
privacy
)
PRIVACY_CONVERTER_O2B
.
get
(
event
.
privacy
)
)
)
bm_event
.
main
.
status
=
ICalendarElementStatus
(
"
Confirmed
"
)
bm_event
.
main
.
organizer
=
ICalendarElementOrganizer
()
bm_event
.
main
.
organizer
.
commonName
=
event
.
user_id
.
partner_id
.
name
bm_event
.
main
.
organizer
.
mailto
=
event
.
user_id
.
partner_id
.
mail
if
event
.
user_id
.
bluemind_user_id
:
bm_event
.
main
.
organizer
.
dir
=
(
"
bm://
"
+
event
.
user_id
.
company_id
.
bluemind_domain
+
"
/users/
"
+
event
.
user_id
.
bluemind_user_id
)
bm_event
.
main
.
url
=
event
.
url
or
""
bm_event
.
main
.
priority
=
5
bm_event
.
main
.
sequence
=
0
bm_event
.
main
.
draft
=
False
bm_event
.
main
.
transparency
=
VEventTransparency
(
"
Opaque
"
)
# These fields are required (although not marked as such in doc / code)
# These fields are required (although not marked as such in doc / code)
# Otherwise you get a NullPointerException
# Otherwise you get a NullPointerException
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
models/res_users.py
+
28
−
13
Voir le fichier @
25aefeac
...
@@ -130,6 +130,14 @@ class ResUser(models.Model):
...
@@ -130,6 +130,14 @@ class ResUser(models.Model):
is recreated in Odoo with organizer = user
is recreated in Odoo with organizer = user
"""
"""
self
.
ensure_one
()
self
.
ensure_one
()
# Retrieve emails from all internal & active Odoo users
odoo_users_emails
=
(
self
.
sudo
()
.
env
[
"
res.users
"
]
.
search
([(
"
share
"
,
"
=
"
,
False
),
(
"
active
"
,
"
=
"
,
True
)])
.
mapped
(
"
partner_id.email
"
)
)
# TODO: add checks and error handling
# TODO: add checks and error handling
# Retrieve all events modified since last sync (followed by self.bluemind_id_version)
# Retrieve all events modified since last sync (followed by self.bluemind_id_version)
bm_calendar
=
self
.
bluemind_auth
().
calendar
(
self
.
bluemind_calendar_id
)
bm_calendar
=
self
.
bluemind_auth
().
calendar
(
self
.
bluemind_calendar_id
)
...
@@ -141,12 +149,10 @@ class ResUser(models.Model):
...
@@ -141,12 +149,10 @@ class ResUser(models.Model):
bm_deleted_uids
=
bm_changeset
.
deleted
bm_deleted_uids
=
bm_changeset
.
deleted
bm_last_version
=
bm_changeset
.
version
bm_last_version
=
bm_changeset
.
version
# Retrieve all events from Odoo
organized by the current user
# Retrieve all events from Odoo
with a bluemind_id
#
and with a bluemind_id
(= already synced at least once with Bluemind)
# (= already synced at least once with Bluemind)
Calendar
=
self
.
env
[
"
calendar.event
"
]
Calendar
=
self
.
env
[
"
calendar.event
"
]
odoo_events_bm_linked
=
Calendar
.
search
(
odoo_events_bm_linked
=
Calendar
.
search
([(
"
bluemind_id
"
,
"
!=
"
,
False
)])
[(
"
user_id
"
,
"
=
"
,
self
.
id
),
(
"
bluemind_id
"
,
"
!=
"
,
False
)]
)
odoo_events_bm_uids
=
odoo_events_bm_linked
.
mapped
(
"
bluemind_id
"
)
odoo_events_bm_uids
=
odoo_events_bm_linked
.
mapped
(
"
bluemind_id
"
)
# Calendar entries created on Bluemind side, not already in Odoo
# Calendar entries created on Bluemind side, not already in Odoo
...
@@ -159,7 +165,14 @@ class ResUser(models.Model):
...
@@ -159,7 +165,14 @@ class ResUser(models.Model):
bm_events_to_create
=
bm_calendar
.
multipleGet
(
bm_events_to_create_uids
)
bm_events_to_create
=
bm_calendar
.
multipleGet
(
bm_events_to_create_uids
)
# Create corresponding events in Odoo
# Create corresponding events in Odoo
for
bm_event
in
bm_events_to_create
:
for
bm_event
in
bm_events_to_create
:
# Only if Organizer is the same as Odoo user or if is not linked to
# any active Odoo internal user
if
(
bm_event
.
value
.
main
.
organizer
.
mailto
==
self
.
partner_id
.
email
or
bm_event
.
value
.
main
.
organizer
.
mailto
not
in
odoo_users_emails
):
events_to_create
.
append
(
Calendar
.
_bm_to_odoo_values
(
bm_event
))
events_to_create
.
append
(
Calendar
.
_bm_to_odoo_values
(
bm_event
))
if
events_to_create
:
Calendar
.
create
(
events_to_create
)
Calendar
.
create
(
events_to_create
)
# Calendar entries that have been updated on Bluemind
# Calendar entries that have been updated on Bluemind
...
@@ -170,18 +183,20 @@ class ResUser(models.Model):
...
@@ -170,18 +183,20 @@ class ResUser(models.Model):
odoo_event
=
odoo_events_bm_linked
.
filtered
(
odoo_event
=
odoo_events_bm_linked
.
filtered
(
[(
"
bluemind_id
"
,
"
=
"
,
bm_event
.
uid
)]
[(
"
bluemind_id
"
,
"
=
"
,
bm_event
.
uid
)]
)
)
# If event exists in Odoo update it
# If
related
event exists in Odoo
and belongs to the user,
update it
if
odoo_event
:
if
odoo_event
:
if
odoo_event
.
user_id
==
self
:
odoo_event
.
update_odoo_event_from_bm
(
bm_event
)
odoo_event
.
update_odoo_event_from_bm
(
bm_event
)
#
Otherwise
log an
error
#
If event does not exist in Odoo
log an
info
else
:
else
:
_logger
.
error
(
_logger
.
info
(
"
Event %s updated in Bluemind d
id
not exist in Odoo
"
,
bm_event
.
uid
"
Event %s updated in Bluemind d
oes
not exist in Odoo
"
,
bm_event
.
uid
)
)
# Calendar entries that have been deleted on Bluemind to be deleted on Odoo
# Calendar entries that have been deleted on Bluemind to be deleted on Odoo
# (only if belongs to user)
odoo_events_to_delete
=
odoo_events_bm_linked
.
filtered
(
odoo_events_to_delete
=
odoo_events_bm_linked
.
filtered
(
[(
"
bluemind_id
"
,
"
in
"
,
bm_deleted_uids
)]
[(
"
bluemind_id
"
,
"
in
"
,
bm_deleted_uids
)
,
(
"
user_id
"
,
"
=
"
,
self
.
id
)
]
)
)
odoo_events_to_delete
.
unlink
(
from_bluemind
=
True
)
odoo_events_to_delete
.
unlink
(
from_bluemind
=
True
)
...
...
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