Skip to content

Commit

Permalink
Merge PR #48 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by alexis-via
  • Loading branch information
OCA-git-bot committed Sep 25, 2024
2 parents fb327d8 + 60da1cf commit 23a6656
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
40 changes: 25 additions & 15 deletions stay/models/stay.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
"evening": "20:00",
"unknown": "08:00",
}
TIME2CODE = {
"morning": _("Mo"),
"afternoon": _("Af"),
"evening": _("Ev"),
}


class StayStay(models.Model):
Expand Down Expand Up @@ -746,14 +741,29 @@ class StayRoomAssign(models.Model):
# The field group_id_integer is used for colors in timeline view
group_id_integer = fields.Integer(related="room_id.group_id.id", string="Group ID")
user_id = fields.Many2one(related="room_id.group_id.user_id", store=True)
arrival_date = fields.Date(related="stay_id.arrival_date", store=True)
arrival_time = fields.Selection(related="stay_id.arrival_time", store=True)
arrival_date = fields.Date(
related="stay_id.arrival_date", store=True, readonly=False
)
arrival_time = fields.Selection(
related="stay_id.arrival_time", store=True, readonly=False
)
arrival_datetime = fields.Datetime(related="stay_id.arrival_datetime", store=True)
departure_date = fields.Date(related="stay_id.departure_date", store=True)
departure_time = fields.Selection(related="stay_id.departure_time", store=True)
arrival_note = fields.Char(
related="stay_id.arrival_note", store=True, readonly=False
)
departure_date = fields.Date(
related="stay_id.departure_date", store=True, readonly=False
)
departure_time = fields.Selection(
related="stay_id.departure_time", store=True, readonly=False
)
departure_datetime = fields.Datetime(
related="stay_id.departure_datetime", store=True
)
departure_note = fields.Char(
related="stay_id.departure_note", store=True, readonly=False
)
notes = fields.Text(related="stay_id.notes", store=True, readonly=False)
partner_id = fields.Many2one(related="stay_id.partner_id", store=True)
partner_name = fields.Text(related="stay_id.partner_name", store=True)
company_id = fields.Many2one(related="stay_id.company_id", store=True)
Expand Down Expand Up @@ -927,18 +937,18 @@ def name_get(self):
2: 25,
3: 50,
}
with_room = self._context.get("display_name_with_room")
for assign in self:
max_name_size = 30
if assign.arrival_date and assign.departure_date:
days = (assign.departure_date - assign.arrival_date).days + 1
max_name_size = days2size.get(days, 120)
name = "[%s] %s, %s, %d [%s]" % (
TIME2CODE[assign.arrival_time],
shorten(assign.partner_name, max_name_size, placeholder="..."),
assign.room_id.code or assign.room_id.name,
assign.guest_qty,
TIME2CODE[assign.departure_time],
partner_name = shorten(
assign.partner_name, max_name_size, placeholder="..."
)
name = f"{partner_name} ({assign.guest_qty})"
if with_room:
name = f"{name} {assign.room_id.code or assign.room_id.name}"
res.append((assign.id, name))
return res

Expand Down
3 changes: 3 additions & 0 deletions stay/views/stay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,11 @@ So I use the form view below by default -->
<field name="partner_name" />
<field name="arrival_date" />
<field name="arrival_time" />
<field name="arrival_note" />
<field name="departure_date" />
<field name="departure_time" />
<field name="departure_note" />
<field name="notes" />
<field name="room_id" />
<field name="guest_qty" />
<field name="room_domain_ids" invisible="1" />
Expand Down

0 comments on commit 23a6656

Please sign in to comment.