Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to give edit rights to form when it is in certain state?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
workflowformedit
1 Odpowiedz
7626 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
Ludo - 21South
Najlepsza odpowiedź

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
Awatar
Odrzuć
samba
Autor

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
Autor

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

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Hide Edit button
xml form edit
Awatar
0
gru 19
7225
Field editing after create a form Rozwiązane
fields form create edit
Awatar
Awatar
1
sie 23
2847
How to lock an object to users when there is another user who has opened a form to edit it? Rozwiązane
form user edit lock
Awatar
Awatar
1
lip 21
11456
How to hide form Edit button depends on field value? Rozwiązane
form hide button edit
Awatar
Awatar
Awatar
Awatar
Awatar
4
gru 23
24213
multiple views in a single workflow
workflow views form v7
Awatar
Awatar
1
mar 15
5737
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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