Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to make a fields.function NOT readonly?

Odoberať

Get notified when there's activity on this post

This question has been flagged
functionfieldsreadonlyfuntion
2 Replies
11464 Zobrazenia
Avatar
Anabela Damas

Hi,

I am trying to have a fields.function that have a default value for res_partner if it is a contact of a company, or if it is a company. But this value can be changed.

So I try this:

    def _passiv(self, cr, uid, ids, field_names, arg,  context):
            res = {}
            for partner in self.browse(cr, uid, ids, context):
                res[partner.id] = False
                if partner.parent_id:
                    res[partner.id] = True
                if partner.is_company:
                    res[partner.id] = True
            return res

        def _set_passiv(self, cr, uid, ids, name, value, arg, context=None):
            if not value: return False
            if type(ids)!=type([]):
                ids=[ids]

            for partner in self.browse(cr, uid, ids, context=context):
                cr.execute("""update res_partner set
                        passiv=%s where id=%s""", (value, partner.id))
            return True


_columns = {
    'passiv': fields.function(_passiv, fnct_inv = _set_passiv, store = True, string='Passiv', type='boolean', help="Check if it is a passiv"),
}

This code give me right values to default, but if I edit my field and save it this doesn't save my choice. I can't access to vals or any other variable that have the value that the user gave to the field.

So, I have it not readonly but I can never change the value.

Any ideas?

1
Avatar
Zrušiť
Pooja Zankhariya

Hello Anabela, Have you found any solution? If yes, can you please post it as i am facing same problem in case of function field. Regards,

Avatar
Miku Laitinen
Best Answer

I was struggling with the same problem. readonly=False on the model side didn't seem to affect anything.

In my case the solution was to add readonly="0" on the view side. Here's the field tag:

<field name="note_template" class="oe_edit_only" readonly="0" nolabel="1" />
0
Avatar
Zrušiť
Avatar
Ximo
Best Answer

Maybe if you change you field to boolean and on defaults, get the partner is a company or not...

def _get_company(self,cr,uid,context=None):
     result="(get if is a company and return True or False)"
     return result

     _columns = {
        'passiv': fields.boolean('Passiv', help="Check if it is a passiv"),
    }

    _defaults = {
       'passiv': _get_company,
}
0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
readonly option in fields? Solved
fields readonly
Avatar
Avatar
Avatar
Avatar
3
dec 23
93099
How can I prevent a user from editing a field after it's set? Solved
fields readonly
Avatar
Avatar
Avatar
3
sep 21
6315
Read only field for certain user groups
fields readonly
Avatar
Avatar
1
sep 15
9851
TypeError: luong_dc() takes at most 6 arguments (7 given)
function fields
Avatar
Avatar
1
mar 15
4905
How to make a field readonly in odoo 17 based on groups of the user Solved
fields readonly Odoo17
Avatar
Avatar
Avatar
Avatar
4
aug 25
8329
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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