Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Dynamic formula in user friendly manner ?

Odebírat

Get notified when there's activity on this post

This question has been flagged
technicalodoov14
2 Odpovědi
3604 Zobrazení
Avatar
Saif Kazi

Greetings, I am familiar with the ability to create custom functions within a model in Odoo, however, I am inquiring if there is a user-friendly method for adding dynamic formulas directly from the form, such as inputting a short Python code that contains formula logic and executing it within the form. Has anyone had experience or knowledge of a solution for this within the Odoo platform? Any suggestions would be highly appreciated.

0
Avatar
Zrušit
Avatar
S.M Firoz Ahmed ( Daffodil Software Limited )
Nejlepší odpověď

It is possible to add dynamic formulas directly from the form in Odoo by using the "Computed Fields" feature. Computed Fields allow you to define a custom function that will be called when certain fields in the form are changed, and the result of that function will be stored in a specific field in the model.

You can create a computed field by going to the developer mode in Odoo and navigate to the desired model and fields. In the fields you can create a new field and select "computed" as the type. Then you will have to write a python function that will be called when the field is computed, this function can make use of other fields in the form to calculate the final value.

Alternatively, you can also use the "onchange" method on fields, this method is called when the value of the field is changed by the user, you can use this method to update other fields with the new value.

It's worth mentioning that both solutions require knowledge of python programming, and it's recommended to test the code before implementing it on the live system.

0
Avatar
Zrušit
Saif Kazi
Autor

Hey
thanks a lot for the reply .. actually I already tried this . but I had a one2many field . And the calculation is dependent on other records and not the same record

Avatar
MUHAMMAD Imran
Nejlepší odpověď

In Odoo, it is possible to create dynamic formulas and calculations directly from the form using the compute attribute. The compute attribute allows you to specify a method that will be called when the field's value is needed. This method can contain any logic or calculations you need to perform, including the use of Python code.


The method should be decorated with @api.depends and should have the same name as the field that you want to calculate. The depends attribute should contain a list of fields that are used in the calculation.


Here is an example of how you might use the compute attribute to create a dynamic formula in an Odoo model:


python

Copy code

class MyModel(models.Model):

    _name = 'my.model'


    x = fields.Integer()

    y = fields.Integer()

    result = fields.Integer(compute='_compute_result')


    @api.depends('x', 'y')

    def _compute_result(self):

        for record in self:

            record.result = record.x + record.y

In this example, the result field is calculated by adding the values of the x and y fields, and the calculation is performed whenever one of those fields changes.


It's worth noting that you can also use compute attribute with the function fields, and you can use them in the form view and in the tree view, it also could be used in the search view.


Keep in mind that the method decorated with @api.depends should be on the same model that the fields it depends on, otherwise, it will not work as expected

0
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How to hide odoo from Wappalyzer
technical odoo
Avatar
Avatar
1
kvě 24
3162
Odoo - Add a dynamic <filter domain="xxxxx"
odoo v14
Avatar
Avatar
1
kvě 24
4062
Add files in the website form
technical odoo
Avatar
Avatar
Avatar
2
čvn 23
3543
How to use a custom domain with Odoo v14?
odoo v14
Avatar
Avatar
1
dub 24
28605
auto filled record field in another page when create new record
odoo v14
Avatar
Avatar
1
lis 22
3372
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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