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

Datetime Constarints

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
constraintodooV8odoo8.0odoo8
4 Replies
4843 Tampilan
Avatar
Logicious

i have one problem , i have one class named as room details and second one is room booking. we can go to book a room by room booking model. I want to create a constraint to it . Problem is that if one person can book one room at one date&time if second person can book that room may be after that time or before that time.previously i askd this question , and there are some answers also i got but i cant figure it out.I cant able to find out the solution fromr that, please help me.

i will give my code


class room_management(osv.Model):

_name = 'room.management'

_columns = {

'name': fields.char('Name',requierd=True, help='Put a Name for your Room example: Interview room,board room,conference Hall...etc '),

'location':fields.char('Location',requierd=True,help="give the location as city name or street name..etc"),

'floar':fields.char('Floor Details',help='Enter the Foar no or name,like Foar 4B6 or somthing should identification'),

'address':fields.text('Address',requierd=True,help='Detailed Address'),

'no_seats':fields.integer('No of Seats',requierd=True,help='Number of seats occupied in this room'),

'room_no':fields.char('Room No',requierd=True,help='Should be unique',),

}


class room_booking(osv.Model):

_name = 'room.booking'

_columns = {

'room_id' : fields.many2one('room.management', string="Room Booking"),

'duration': fields.integer('Duration'),

'reason': fields.char('Reason',requierd=True ,help="short deatails about booking,Example:Simons Hr interview"),

'start': fields.datetime('Start At',requierd=True),

'end': fields.datetime('End At',requierd=True),

}


1
Avatar
Buang
Avatar
Marvin Taboada
Jawaban Terbai

Hello Logicious,

This kind of constraints are applicable for creation but also for edition. If you really want to perform input validation overwriting `create` also overwrite `write` as well.

A cleaner solution to cover both cases is to create Python based constraints like the one you can see in `hr_holidays`, please see here:

* https://github.com/odoo/odoo/blob/8.0/addons/hr_holidays/hr_holidays.py#L208

* https://github.com/odoo/odoo/blob/8.0/addons/hr_holidays/hr_holidays.py#L152

Constraints are automatically invoked during creation or edition:

* https://github.com/odoo/odoo/blob/8.0/openerp/models.py#L3949 

* https://github.com/odoo/odoo/blob/8.0/openerp/models.py#L4273 

* https://github.com/odoo/odoo/blob/8.0/openerp/models.py#L1239 

Please also note tha Odoo 8 introduced a new way to declare constraints (and deprecated the above):

* https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model._inherits

* https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.api.constrains

Regards.

1
Avatar
Buang
Avatar
Prasanth ks
Jawaban Terbai

you just try this i think its will work fine as your wish :-

def create(self, cr, uid, vals, context=None):

all_room_ids=self.search(cr,uid,[('room_id','=',vals['room_id'])])

for room_id in all_room_ids     

       room_data=self.browse(cr,uid,room_id)          

                      if ((vals['start'] >= room_data.start) and (vals['end'] <= room_data.start)) or (vals['start'] >= room_data.end):

                                  print'yyyyyyyyyyyyy',room_data

                      else:

                              raise osv.except_osv(_('Error!'),_("Room Already booked."))

2
Avatar
Buang
Avatar
Akhilesh Gupta
Jawaban Terbai

Hi,

You should make room booking constraints on the basis of room status Or you can create warning if it already booked.

May it will help you.

0
Avatar
Buang
Avatar
Logicious
Penulis Jawaban Terbai

@prasanth: thanks prasanth. its working perfectly

0
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
High Availability Odoo 8.0 on Windows
odooV8 odoo8.0 odoo8
Avatar
0
Feb 21
4530
Product received Administrator in Odoo 8 purchase module
odooV8 odoo8.0 odoo8
Avatar
0
Feb 18
3272
blockUI requires jQuery v1.2.3 or later! You are using v1.11.1 error when installing Odoo 8 on Windows 10
odooV8 odoo8.0 odoo8
Avatar
Avatar
Avatar
3
Jun 17
6632
Values are reset on save
odooV8 odoo8.0 odoo8
Avatar
0
Jan 16
4362
How to change Error log window on "client"-side service of Odoo? Diselesaikan
odooV8 odoo8.0 odoo8 Odoo8
Avatar
Avatar
2
Agu 19
5583
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