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

Set readonly on a button

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
readonlybuttons
2 Replies
12306 Tampilan
Avatar
Francisco Castro

Hi guys

I dont know what's going on here I tried to set as readonly two buttons when for example I click on it but this dont work.

I have 5 boolean fields to help and I store the True or False option on a database

I have a funtion to update the fields.

 

class account_invoice(osv.osv):
    _inherit = 'account.invoice'
    
    
    _columns = {
        'impressoori' : fields.boolean('Original ja foi impresso'),
        'impressodupl': fields.boolean('Duplicado Impresso'),
        'impressotri' : fields.boolean('Triplicado ja foi impresso'),
        'impressoall' : fields.boolean('Todas as vias ja foram impressas'),
        'impressoseg' : fields.boolean('Segunda via ja impressa')
    }
    
    _defaults = {
        'impressodupl': False,
        'impressoori': False,
        'impressotri': False,
        'impressoall': False,
        'impressoseg': False,
    }

def update_field_all(self, cr, uid, ids,context):
        for invoice in self.browse(cr, uid, ids):
             cr.execute("UPDATE account_invoice SET impressoall = True WHERE id = %d" %(invoice.id) )
             cr.execute("UPDATE account_invoice SET impressodupl = True WHERE id = %d" %(invoice.id) )
             cr.execute("UPDATE account_invoice SET impressotri = True WHERE id = %d" %(invoice.id) )
             cr.execute("UPDATE account_invoice SET impressoori = True WHERE id = %d" %(invoice.id) )
             
             #raise osv.except_osv(_('This is the error title'), _('This is the error message'))
        return True

My Xml file :

record model="ir.ui.view" id="account_invoice_rule_saft_inherit">
            <field name="name">account.invoice.rule.saft.inherit</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
            <field name="arch" type="xml">
        <notebook colspan="4" position="after">
            <!--<button name="%(account.account_invoices)d" position="replace">-->
        <group col="1">
                <field name="impressodupl" nolabel="0" invisible="False" />
                <field name="impressoori" nolabel="0" invisible="False" />
                <field name="impressotri" nolabel="0" invisible="False" />
                <field name="impressoall" nolabel="0" invisible="False" />
          <field name="impressoseg" nolabel="0" invisible="False" />
          
        </group>
     

                  <button name="%(account_invoices_tri_default)d" type="action" string="Triplicado" icon="gtk-print" states="open,paid,proforma,proforma2" attrs="{'readonly':[('impressoall', '=', True)]}"/>

                  <button name="account_invoices_all_default" type="action" string="Todas as Vias" icon="gtk-print" attrs="{'readonly':[('impressoall', '=', True)]}" states="open,paid,proforma,proforma2" />

                 
          </notebook>
               </field>
        </record>

0
Avatar
Buang
Avatar
Luis Filipe Castanheira
Jawaban Terbai

I don't know if it is possible to set the readonly attribute to a button. Why don't you try to make them invisible instead? If you don't want users to click on buttons, it would be less confusing not to show the buttons at all...

_____

Answering to your question. Working with the invisible attribute might be a little more chalenging (even more if you have a complex condition involving more fields). You have to think this way (it helps me): you previously wanted to lock a button when a condition was true. Now, what you want is to "not show" that same button. So, what you have to do to make it work, is to reverse your previous logic.

This way, where you had `attrs="{'readonly':[('impressoall', '=', True)]}"` you have to deny that and will have `attrs="{'invisible':[('impressoall', '!=', True)]}"` or `attrs="{'invisible':[('impressoall', '=', False)]}"

__________

Yep, you're right! Forgot that you have to remove the `states="open,paid,proforma,proforma2"` part (wich will transform into an 'invisible' attrs) and join that in your attrs declaration. It should look something like

`attrs="{'invisible':['|', ('impressoall', '=', False), ('state', 'not in', ['open','paid','proforma','proforma2'])]}"`

2
Avatar
Buang
Avatar
Francisco Castro
Penulis Jawaban Terbai

But How? I put ttrs="{'invisible':[('impressoall', '=', True)]}" and it dont work... strange

-----------------------------------------------------------------------------------------------------------------------------------

ok the problem was the state..... It force the buttons apear all the time...

I put the state inside the attrs thx by the way you help me too :)

0
Avatar
Buang
Alcaline

how did you add the states inside the attrs??

Alcaline

how did you add the states inside the attrs??

Luis Filipe Castanheira

@alcalinelee, read the final paragraph of my answer above. The `states="some_state` part will be converted into an invisible attribute, so you have to remove it from your button definition and insert it into the attrs part.

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 Sales
readonly
Avatar
Avatar
1
Okt 24
7825
Make field readonly after save it and only user creator and administrator can edit it.
field readonly buttons OdooStudio
Avatar
Avatar
Avatar
Avatar
4
Jun 24
4094
Custom stat button (eo_stat_button) for a custom field on a partner
buttons
Avatar
Avatar
Avatar
2
Mar 23
11076
Cacher le bouton "créer" d'une liste Diselesaikan
buttons
Avatar
Avatar
2
Mar 23
3198
Add class to button from function Diselesaikan
buttons
Avatar
Avatar
2
Mei 22
5420
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