Skip to content

Commit

Permalink
[FIX] e_t_s_travel: has_travel
Browse files Browse the repository at this point in the history
  • Loading branch information
remytms committed Sep 19, 2024
1 parent bff75c3 commit 3a62f2f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
24 changes: 18 additions & 6 deletions event_track_speaker_travel/models/event_track_speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions event_track_speaker_travel/views/event_track_speaker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,20 @@
</field>
</record>

<record model="ir.ui.view" id="view_event_track_speaker_tree">
<field name="name">event.track.speaker.tree</field>
<field name="model">event.track.speaker</field>
<field
name="inherit_id"
ref="event_track_multi_speaker.view_event_track_speaker_tree"
/>
<field name="arch" type="xml">
<field name="event_id" position="after">
<field name="need_travel" />
<field name="has_travel" />
<field name="travel_cost" />
</field>
</field>
</record>

</odoo>

This file was deleted.

File renamed without changes.

0 comments on commit 3a62f2f

Please sign in to comment.