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
    Supply Chain
    • 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
    • Kecerdasan Buatan
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • 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
    • Manajemen Properti
    • 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
    • Konsultasi
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan
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 create a function onchange Odoo Community Version 12

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
functionpythonurgentodooV12
1 Balas
10845 Tampilan
Avatar
Ramla
Hi, I need a help :

if date_fin == date.today :

I want the cycle statut change (activer to desactiver) and all the rest of the fields to be in readonly mode.


class ProductionCycle(models.Model):
  _name = 'production.cycle'
  _description ="Les cycle de production"
  _inherit = ['mail.thread']

  name = fields.Char(string='Nom du cycle de production', required=True, track_visibility='always')
  description = fields.Text(string='Description', track_visibility='onchange')
  date_debut = fields.Date(string='Date de début', default=fields.Date.context_today, track_visibility='onchange')
  date_fin = fields.Date(string='Date de fin', required=True, track_visibility='onchange')
  statut = fields.Selection([('activer', 'Activer'), ('desactiver', 'Desactiver')], string='Statut', default='activer', required=True, track_visibility='onchange')
  batiment_id = fields.Many2one('technique.batiment', string='Bâtiment', ondelete='cascade', required=True, track_visibility='onchange')
  souche_id = fields.Many2one('animale.souche', string='Souche', ondelete='cascade', required=True, track_visibility='onchange')
 
  _sql_constraints = [
('name_uniq', 'unique (name)', "Le nom du cycle existe déjà !"),
]


Thanks

0
Avatar
Buang
Avatar
Ring, Antonio Condez
Jawaban Terbai

Hi Ramla,

To create an onchange function, in your <models>.py file add

@api.onchange('date_fin')
def _method_name(self):    
    if self.date_fin:
        if self.date_fin == date.today():    #assuming that date is a datetime object
            self.statut = 'desactiver' 

And to make the fields set to readonly in your xml file, i suggest you use 

<field name="field_name" attrs="{'readonly':[('statut', '=', 'desactiver')]} />

Just work around on this and I'm sure you'll get what you want.. 

Hope it helps. :)

1
Avatar
Buang
Ramla
Penulis

Thank you so much ^_^

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
Function Onchange Odoo Community Version 12
function python urgent onchange odooV12
Avatar
0
Apr 19
5449
How to correct a function onchange Odoo Community Version 12 Diselesaikan
function urgent onchange odooV12
Avatar
Avatar
Avatar
4
Mei 19
6429
How to correct the function onchange : compute age Odoo Community 12
function urgent onchange odooV12
Avatar
Avatar
Avatar
2
Mei 19
5242
How to correct a function onchange Odoo Community Version 12 Diselesaikan
function urgent onchange odooV12
Avatar
Avatar
Avatar
2
Apr 19
5724
How to compute the sum of the values Odoo Community 12 ?
function urgent onchange compute odooV12
Avatar
Avatar
1
Apr 19
6496
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
  • Karir
  • 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo adalah software terintegrasi dengan 70+ aplikasi seperti CRM, Akuntansi, Inventaris, Sales, eCommerce, Marketing, POS; plus fitur lokal Indonesia!

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