Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

How do I check for overlapping dates?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
datereservation
4 Replies
13782 Tampilan
Avatar
Martin King

I've created my first module (a campsite reservation module) and have everything functioning as I'd like except I haven't been able to figure out how to make a constraint to prevent date overlap on a campsite booking.

I have two models, Campsite and Booking.  I've linked to Sales for customer information.  Booking contains start_date, end_date, site_id, customer_id and duration fields.  When making a new booking, I'd like a constraint that checks to see if the requested campsite is already booked for the requested date range.  I have some basic Python and SQL knowledge but I can't figure out a constraint that checks "incoming" dates against "existing" dates in the database.  I know we're supposed to be concise, but thanks for any help!

0
Avatar
Buang
Martin King
Penulis

Baiju's answer below solved my problem! Thanks very much, Baiju! I don't have enough karma yet to reply to his post. I've been using the Odoo 8 module building tutorial and the constraint syntax is different to what Baiju offered. I'm guessing this is from the Openerp 7 API?

Martin King
Penulis

Using your original answer, I managed to get this working using the new API: @api.one @api.constrains('start_date', 'end_date') def _check_date_overlap(self): for date in self: date_ids = self.search([('start_date', '=', date.start_date), ('site_id', '=', date.site_id.id), ('id', '', date.id)]) if date_ids: raise exceptions.ValidationError("Dates overlap, please choose different dates.") Thanks again for your help!

Avatar
Baiju KS
Jawaban Terbai

Hi Martin,

You can use this script:-

    _constraints = [
        (_check_date, 'You can not book  same day!', ['start_date','end_date']),
    ]

    def _check_date(self, cr, uid, ids):
        for item in self.browse(cr, uid, ids):
            item_ids = self.search(cr, uid, [('start_date', '<=', item.end_date), ('end_date', '>=', item.start_date),       ('site_id', '=', item.site_id.id), ('id', '<>', item.id)])
            if item_ids:
                return False
        return True

Hope this helps. If any querys please let me know.

3
Avatar
Buang
Avatar
Tsegaye Bekele
Jawaban Terbai

https://github.com/odoo/odoo/blob/12.0/addons/account/models/account_fiscal_year.py

def _check_dates(self) givies good example

2
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
odoo 16 dashboard select specific date range Diselesaikan
date
Avatar
Avatar
Avatar
3
Jun 25
2266
How to get Creation Date for created Customer? Diselesaikan
date
Avatar
Avatar
1
Jan 25
18841
MANUAL PRODUCT RESERVATION
reservation
Avatar
Avatar
2
Mar 24
1756
Create a new reservation module through Odoo 15 studio
date reservation Studio v15
Avatar
Avatar
1
Mei 22
2000
Create a new reservation module through Odoo 15 studio
date reservation Studio v15
Avatar
Avatar
1
Feb 22
3029
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now