Hello I am make meeting room app so I have query I have six conference room so how to make sure that Two people not book one Conference Room on same Date and time .
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Consider that you have created a model(meeting.room) for meeting room where it has one2many field(booking_ids of room.booking.line) for take bookings for perticular room.So, in room.booking.line you can add constrains on date and time.Check below example:
@api.constrains('booking_date','start_time','end_time')
def check_booking(self):
bookings = self.env['meeting.room'].search([('room_id','=',self.room_id),('id','!=',self.id)])
if bookings:
for booking in bookings:
if booking.booking_date == self.booking_date:
if (booking.start_time <= self.start_time and booking.end_time >= self.start_time) \
or (booking.start_time <= self.end_time and booking.end_time >= self.end_time) :
raise ValidationError('Room is already booked')
Thanks, (Siddharth Tarpada)
Hello Prince,
You can try the code below to see if it helps you,
Find Code in Comment.
Please do not hesitate to contact us if you want further customisation !!
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
def create(self, vals):
# Try with create method, anytime a user tries to reserve a conference room; if the conference room is available, let the user to create; otherwise, raise a warning.
conference_room_ids = self.search([('conference_room_field', '=',vals['conference_room_field'])])
for room_id in conference_room_ids:
room_data = self.browse(room_id)
# If condition to check availability of conference room
if ((vals['start_date']>= room_data.start_date) and (vals['end_date'] <= room_data.start_date)) or (vals['start_date'] >= room_data.end_date):
print(room_data)
# Hence raise warning that conference room is already booked
else:
raise Warning('Conference Room is Already Booked !!')
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
Sql constraint for boolean field
Đã xử lý
|
|
2
thg 9 18
|
7174 | |
|
9
thg 3 16
|
61101 | ||
|
1
thg 3 15
|
4934 | ||
|
1
thg 3 15
|
5654 | ||
|
2
thg 3 15
|
4670 |