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
    • Discuss
    • 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 to do search method compare currentdate with str format date field

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
1 Balas
22958 Tampilan
Avatar
gpkarthick

search method compare of current date which is date format with date_open is crm_lead field which is string format how to do that

def get_name(self, form):       
    crm_obj = self.pool.get('crm.lead')
    sale_obj=self.pool.get('hr.employee')
    line=[]
    d = datetime.now().date()
    currentdate=time.strftime('%Y-%m-%d')
    cur_date=datetime.strptime(currentdate,'%Y-%m-%d')
    line=crm_obj.browse(self.cr, self.uid, self.ids)
    targetselect=form['target_selection']
    for val in line:
        nameop=val.date_open
        cdate=datetime.strptime(nameop,'%Y-%m-%d %H:%M:%S').date()                      
        gval=val.id
    print type(nameop),cdate,type(cdate),gval,cur_date,targetselect,d,"hhhhhhhhhhhhhhhhhhhhhhhhhhh"
    if targetselect=='daily':
        print cdate,d,"111111111111111111111111111111"          
        lines=crm_obj.search(self.cr, self.uid, [('date_open','==',d)])
        print lines
    else:
        raise osv.except_osv(_('Info'),_('There is no entry for today'))    
        print x
0
Avatar
Buang
Sudhir Arya (ERP Harbor Consulting Services)

So what is the issue?

gpkarthick
Penulis

lines=crm_obj.search(self.cr, self.uid, [('date_open','==',d)]) if i do that error gives as object of type 'datetime.date' has no len() date_open-->string of date time field and d->currentdate

Sudhir Arya (ERP Harbor Consulting Services)

date_open is a datetime type or only date type?

gpkarthick
Penulis

date_open is a string type and time.strftime("%Y-%m-%d") is a datetime.date type, will the compare happen(i check your updated code it still loading the web page no result produced)

Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Jawaban Terbai

If date_open is date type field:

lines = crm_obj.search(self.cr, self.uid, [('date_open','=',time.strftime("%Y-%m-%d"))])

If date_open is datetime type field:

d = datetime.now().date()
#Convert date type from datetime.date type into string
d1 = datetime.strftime(d, "%Y-%m-%d %H:%M:%S")
d2 = datetime.strftime(d, "%Y-%m-%d 24:59:59")
lines = crm_obj.search(self.cr, self.uid, [('date_open','>=',d1), ('date_open','<=',d2)])

You have to search it between current date+start time of the day (2013-05-06 00:00:00) and current date+end time of the day (2013-05-06 24:59:59) because you have date as datetime.

7
Avatar
Buang
Sudhir Arya (ERP Harbor Consulting Services)

See my updated code. It will work.

gpkarthick
Penulis

you really great it's working fine arya i have a another one how to browse all user record , if i browse record only i can get who entered, a lot of thanks to you

venugopal voraganti

I think it should be d2 = datetime.strftime(d, "%Y-%m-%d 23:59:59")

Gregory Dover

worked perfectly. Thank you.

Menikmati diskusi? Jangan hanya membaca, ikuti!

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

Daftar
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