From 3a62f2f5deff154deb4ffadf17bbd6532be34b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Thu, 19 Sep 2024 02:54:32 +0200 Subject: [PATCH] [FIX] e_t_s_travel: has_travel --- .../models/event_track_speaker.py | 24 ++++++++++++++----- .../views/event_track_speaker.xml | 16 +++++++++++++ .../odoo/addons/event_speaker_travel | 1 - .../odoo/addons/event_track_speaker_travel | 1 + .../setup.py | 0 5 files changed, 35 insertions(+), 7 deletions(-) delete mode 120000 setup/event_speaker_travel/odoo/addons/event_speaker_travel create mode 120000 setup/event_track_speaker_travel/odoo/addons/event_track_speaker_travel rename setup/{event_speaker_travel => event_track_speaker_travel}/setup.py (100%) diff --git a/event_track_speaker_travel/models/event_track_speaker.py b/event_track_speaker_travel/models/event_track_speaker.py index 8f64d2267..25045548d 100644 --- a/event_track_speaker_travel/models/event_track_speaker.py +++ b/event_track_speaker_travel/models/event_track_speaker.py @@ -20,12 +20,24 @@ class EventTrackSpeaker(models.Model): @api.depends("travel_booking_ids.cost", "travel_expense_ids.cost") def _compute_travel_cost(self): - self.travel_cost = 0 - for booking in self.travel_booking_ids: - self.travel_cost += booking.cost - for expense in self.travel_expense_ids: - self.travel_cost += expense.cost + for speaker in self: + speaker.travel_cost = 0 + for booking in speaker.travel_booking_ids: + if booking.status != "draft": + speaker.travel_cost += booking.cost + for expense in speaker.travel_expense_ids: + if expense.status != "draft": + speaker.travel_cost += expense.cost @api.depends("travel_booking_ids", "travel_expense_ids") def _compute_has_travel(self): - self.has_travel = self.travel_booking_ids or self.travel_expense_ids + for speaker in self: + booking_ok = not speaker.travel_booking_ids + for booking in speaker.travel_booking_ids: + booking_ok = booking.status == "payed" + + expense_ok = not speaker.travel_expense_ids + for expense in speaker.travel_expense_ids: + expense_ok = expense.status != "draft" + + speaker.has_travel = booking_ok and expense_ok diff --git a/event_track_speaker_travel/views/event_track_speaker.xml b/event_track_speaker_travel/views/event_track_speaker.xml index 2e55ee702..a7c33bd48 100644 --- a/event_track_speaker_travel/views/event_track_speaker.xml +++ b/event_track_speaker_travel/views/event_track_speaker.xml @@ -40,4 +40,20 @@ + + event.track.speaker.tree + event.track.speaker + + + + + + + + + + diff --git a/setup/event_speaker_travel/odoo/addons/event_speaker_travel b/setup/event_speaker_travel/odoo/addons/event_speaker_travel deleted file mode 120000 index ee7a0d75c..000000000 --- a/setup/event_speaker_travel/odoo/addons/event_speaker_travel +++ /dev/null @@ -1 +0,0 @@ -../../../../event_speaker_travel \ No newline at end of file diff --git a/setup/event_track_speaker_travel/odoo/addons/event_track_speaker_travel b/setup/event_track_speaker_travel/odoo/addons/event_track_speaker_travel new file mode 120000 index 000000000..db0b9750d --- /dev/null +++ b/setup/event_track_speaker_travel/odoo/addons/event_track_speaker_travel @@ -0,0 +1 @@ +../../../../event_track_speaker_travel \ No newline at end of file diff --git a/setup/event_speaker_travel/setup.py b/setup/event_track_speaker_travel/setup.py similarity index 100% rename from setup/event_speaker_travel/setup.py rename to setup/event_track_speaker_travel/setup.py