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 to give edit rights to form when it is in certain state?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
workflowformedit
1 Balas
7625 Tampilan
Avatar
samba

I am trying to add "approve" state to the invoices. I did these changes.

I have inherited "account.invoice" module and view also.

previously invoice has "draft" "open" states i have added "validate" in between draft and open.Just i am updating the state when the user click on "act_validate" signal. It's working fine but i unable to edit the form when it is in "validate" state. Please help me using below code snippet.

......................................... model.py file.......................................................................................

class account_invlice_extension(osv.osv):
    _inherit = "account.invoice"
    def _paid_amount_in_company_currency(self, cr, uid, ids, name, args, context=None):
        if context is None:
            context = {}
        res = {}
        ctx = context.copy()
        for v in self.browse(cr, uid, ids, context=context):
            voucher = self.browse(cr, uid, v.id, context=ctx)
            res[voucher.id] =  self.pool.get('res.currency').compute(cr, uid, voucher.currency_id.id, voucher.company_id.currency_id.id, voucher.amount_total, context=ctx)
        return res
    def approve(self, cr, uid, ids):
        self.write(cr, uid, ids, {'state': 'validate'})
        return True

    _columns = {
        'state': fields.selection([
            ('draft','Draft'),
            ('proforma','Pro-forma'),
            ('proforma2','Pro-forma'),
            ('validate','Validate'),
            ('open','Open'),
            ('paid','Paid'),
            ('cancel','Cancelled'),
            ],'Status', select=True, readonly=True, track_visibility='onchange',
            help=' * The \'Draft\' status is used when a user is encoding a new and unconfirmed Invoice. \
            \n* The \'Pro-forma\' when invoice is in Pro-forma status,invoice does not have an invoice number. \
            \n* The \'Open\' status is used when user create invoice,a invoice number is generated.Its in open status till user does not pay invoice. \
            \n* The \'Paid\' status is set automatically when the invoice is paid. Its related journal entries may or may not be reconciled. \
            \n* The \'Cancelled\' status is used when user cancel invoice.'),
       'amount_toatl_cc':fields.function(_paid_amount_in_company_currency, type='float', digits_compute=dp.get_precision('Account'), string='Amount in Home Cur.',digits=(12,6)),
    
    }

   ................................... end of model.py...............................................................

.........................................view file..........................................................................

<openerp>
  <data>
    <record model="ir.ui.view" id="account_invoice_customer_extension">
        <field name="name">account.invoice.form</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_form"/>
        <field name="arch" type="xml">
            <xpath expr="/form/header/button[@name='invoice_cancel']" position="after">
                <button name="invoice_cancel" states="validate" string="Cancel Invoice" groups="base.group_no_one"/>
            </xpath>
            <xpath expr="/form/header/button[@name='invoice_open']" position="replace">
                <button name="invoice_open" states="validate" string="Approve" class="oe_highlight" groups="base.group_user"/>
            </xpath>
            <xpath expr="/form/header/button[@name='invoice_cancel']" position="before">
                <button name="invoice_approve" states="draft" string="Validate" class="oe_highlight" groups="base.group_user"/>
            </xpath>
            <xpath expr="/form/header/field[@name='state']" position="replace">
                <field name="state" widget="statusbar" nolabel="1" statusbar_visible="draft,validate,open,paid" statusbar_colors='{"proforma":"blue","proforma2":"blue"}'/>
            </xpath>
            <xpath expr="/form/sheet/notebook/page/group/field[@name='amount_total']" position="after">
                <field name="amount_toatl_cc" widget="monetary" options="{'currency_field':'company_id.currency_id'}"/>
            </xpath>
        </field>
    </record>
    <record model="ir.ui.view" id="account_invoice_supplier_extension">
        <field name="name">account.invoice.form</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_supplier_form"/>
        <field name="arch" type="xml">
            <xpath expr="/form/sheet/group/group[2]/field[@name='journal_id']" position="replace">
                  <field name="journal_id" groups="account.group_account_user"
                                on_change="onchange_journal_id(journal_id, context)" widget="selection"/>
                
<!--                <field name="amount_toatl_cc" widget="monetary" options="{'currency_field': 'company_id.currency_id'}"/>-->
            </xpath>
        </field>
    </record>
    <record model="ir.ui.view" id="account_invoice_supplier_tree_extension">
        <field name="name">account.invoice.form</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_tree"/>
        <field name="arch" type="xml">
            <xpath expr="/tree/field[@name='amount_total']" position="after">
                <field name="amount_toatl_cc"/>
            </xpath>
        </field>
    </record>
<!--    work flow-->
    <record id="wkf" model="workflow">
            <field name="name">account.invoice.basic</field>
            <field name="osv">account.invoice</field>
            <field name="on_create">True</field>
        </record>
<!--    Activity-->

    <record model="workflow.activity" id="act_approve">
                    <field name="wkf_id" ref="wkf" />
                    <field name="name">approve</field>
                    <field name="action">approve()</field>
                    <field name="kind">function</field>
                    
   </record>
   <record id="act_draft" model="workflow.activity">
            <field name="wkf_id" ref="wkf"/>
            <field name="flow_start">True</field>
             <field name="split_mode">AND</field>
            <field name="name">draft</field>
        </record>
        <record id="act_open" model="workflow.activity">
            <field name="wkf_id" ref="wkf"/>
            <field name="name">open</field>
            <field name="action">action_date_assign()
action_move_create()
action_number()
invoice_validate()</field></record>

<!--    Transition-->
    <record model="workflow.transition" id="t256">
                    <field name="act_from" ref="act_draft" />
                    <field name="act_to" ref="act_approve" />
                    <field name="signal">invoice_approve</field>
    </record>
    <record id="t4" model="workflow.transition">
            <field name="act_from" ref="act_approve"/>
            <field name="act_to" ref="act_open"/>
            <field name="signal">invoice_open</field>
   </record>
    
  </data>
</openerp>

 

...................................................................END OF VIEW FILE ..........................................................

 

 

 

0
Avatar
Buang
Avatar
Ludo - 21South
Jawaban Terbai

Check the original field in the views or in the py files. I think they all have the "states" attribute added to them. This means that unless you change that, they will only be editable in a certain state (most likely only "draft"). 

Change that into ["draft","validate"] and see if it works.

1
Avatar
Buang
samba
Penulis

Thank you Ludo, this help me alot. But i unable to call parent class function in to model fields i.e . 'reference_type': fields.selection(super(account_invoice_extension, self)._get_reference_type, 'Payment Reference', required=True, readonly=True, states={'draft':[('readonly',False)]}), My class name is "account_invoice_extension". It is giving "NameError: name 'account_invoice_extension' is not defined " Error

Ludo - 21South

You forgot: _name = "account.invoice" (assuming you want your module to override the fields)

samba
Penulis

Thank you Ludo, I follow the same. My problem solved

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
Hide Edit button
xml form edit
Avatar
0
Des 19
7225
Field editing after create a form Diselesaikan
fields form create edit
Avatar
Avatar
1
Agu 23
2847
How to lock an object to users when there is another user who has opened a form to edit it? Diselesaikan
form user edit lock
Avatar
Avatar
1
Jul 21
11456
How to hide form Edit button depends on field value? Diselesaikan
form hide button edit
Avatar
Avatar
Avatar
Avatar
Avatar
4
Des 23
24213
multiple views in a single workflow
workflow views form v7
Avatar
Avatar
1
Mar 15
5737
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