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

calling other model method in a computed field shows 0/no value until save

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
python2.7Odoo10.0
3 Replies
10282 Rodiniai
Portretas
Samo Arko

I have a one2many relation where the many end model has a selection field and a method that computes a value from the selection and some other values and then returns the computed value and uses it for calculation with the values of dependent fields. (tried onchange, same result)

The problem is when I get values this way for my computed fields in my tree view with option editable="bottom" it computes the correct value when I press save, but when edit the record fields of any dependent field the value just becomes 0, until I save it again and only then the correct value is displayed.

I want it to show the the computed value when changing the dependent fields just like if I only use field values and not methods.

Is this possible? If yes an example would be nice, if not... at least I don't waste my time with it and have to try different approach.

And getting the value from fields and calculate it in the same model is a NO GO, the method uses some stuff that cannot be hard coded but it has to be dependant on user input.

0
Portretas
Atmesti
Portretas
Samo Arko
Autorius Best Answer

Did a work around. Now it works but I have to have 2 nearly identical functions that do the exactly same thing in two models.

The main problem was that I haven't found a way to pass the object state to other module. So every time the dependent fields triggered the the compute method that called the method in the other model that method fetched the data form the database record so that's why the the computed field didn't change or had a 0 value and it showed the correct value only after saving.

Now I call the record with the selection and stored expression from the 1st model, change the variables that are in the expression with the appropriate values and then I call the 2nd models method for calculating. Before the method for calculation changed the variables with values.

0
Portretas
Atmesti
Portretas
Hilar Andikkadavath
Best Answer

You can use the @api.depends , it will do the onchange function too. whenever a change in the field specified in depends function, it will trigger the defined function and returns the result.

@api.multi
@api.depends('name', 'state')
def name_get(self):
result = []
for move in self:
if move.state == 'draft':
name = '* ' + str(move.id)
else:
name = move.name
result.append((move.id, name))
return result


Here is an example, here if ther is any change in the fields name, state will trigger the function. Here you can also use the fields names as 

@api.depends('debit', 'credit', 'move_id.matched_percentage', 'move_id.journal_id')

Here move_id can be a many2x or one2x field



3
Portretas
Atmesti
Samo Arko
Autorius

Nope... this is not the answer. As I stated in the 1st paragraph "calculation with the values of dependent fields" that means that I used @api.depends. The "dependant" fields are the ones that are in the brackets "@api.depends( in here )". The method is in the other model. I know how to do such simple methods that you put into the example and as I stated the data is in different models that has to be collected by the method in the One2Many (on the many end side of relation) model. Thank you for trying to help but I see that you didn't read the whole question or didn't understand it. So please deselect your answer as the correct one!

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
How to connect two odoo 10 servers.
python2.7 Odoo10.0
Portretas
Portretas
Portretas
2
gruod. 23
3485
How to call JavaScript function from Python model.py oodo 10.0
javascript python2.7 Odoo10.0
Portretas
Portretas
1
liep. 18
9417
Error occurred during the installation of loan management(V6.1) module in V7.0
python2.7
Portretas
Portretas
Portretas
Portretas
3
spal. 23
6813
Readonly field disappears when saved in odoo 10.
Odoo10.0
Portretas
Portretas
1
kov. 23
3238
How to write a python function called automatically?
python2.7
Portretas
Portretas
Portretas
2
saus. 23
6255
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