Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

Understanding old API, what does store in fields.function actually do?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
sale.orderfields.functionodooV8oldAPI
1 Atsakyti
8895 Rodiniai
Portretas
E.M.

I would like to understand when this field changes. It is part of sale.py model.

I have added a field "global discount" to sale.order model and  I would like amount_untaxed to change when field "global discount" changes, what should I do?


'amount_untaxed': fields.function(_amount_all_wrapper, 
  digits_compute=dp.get_precision('Account'), 
  string='Untaxed Amount',
              store={
                    'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
     'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
              },
  multi='sums', 
  help="The amount without tax.", 
  track_visibility='always'),


Thanks

0
Portretas
Atmesti
Portretas
Qutechs, Ahmed M.Elmubarak
Best Answer

Hello,

The store keyword used to enhance the performance; since the functional field will be computed each time it'll be visible to the user.

without the store keyword [store=False], the functional field will not be stored in the database [e.g you can just access it by a browse record].

If you use store=True [the default is False]; your functional field will be stored in the DB and will be calculated for just one time.

- To tell the server when to recompute this filed you'll use a dictionary as

store={'model_name': (trigger_ids, [trigger_fields], priority), ...}

as in your example:

'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),

the means: the field amount_untaxed will be recomputed whenever there is a changes in the 'order_line' field of the sale.order and

'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),

To recompute the field whenever there is a changes in the fields: 'price_unit', 'tax_id', 'discount', 'product_uom_qty' of the sale.order.line ...

the _get_order function: will return the [id] of parent sale order of the sale.order.line


For your question, I think you need to update the line as:

 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'global_discount'], 10),

I hope this could helps ...
1
Portretas
Atmesti
E.M.
Autorius

It really helps, I managed to discover that adding global_discount triggered the field update, but I did not manage to fully understand how it fully worked. Your explanation is comprehensive and clear, thanks a lot.

Asmita Chavan

'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),

Does this mean, if order_line field of any sale_order is changed, then this functional field will get triggered;

'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),

And in above functional field, if mentioned fields of sale_order id returned by _get_order is changed , then field will get triggered.

Sorry for a stupid doubt; but how does the field knows that , record of sale_order class is modified?

Enjoying the discussion? Don't just read, join in!

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

Registracija
Related Posts Replies Rodiniai Veikla
Retrieving a field from self in old API, how does it work? Solved
sale.order.line sale.order odooV8 oldAPI
Portretas
Portretas
1
rugp. 24
4641
How to access sale.order fields from sale.order.line onchange?
odooV8 oldAPI
Portretas
1
vas. 20
1560
Adding a global discount to sale.order, how?
sale.order odooV8
Portretas
Portretas
Portretas
3
kov. 18
6848
Read all sale.order objects on draft state from a custom module - Odoo v8 Solved
many2one sale.order odooV8
Portretas
Portretas
1
rugp. 17
4901
How to create a new model inherit from sale.order.line ? Solved
sale.order.line sale.order odooV8
Portretas
Portretas
Portretas
3
bal. 17
9437
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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