Przejdź do zawartości
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
    • Wiedza
    • 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
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

Function field method is not called for tree view

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
treeviewopenerp7function_fieldfunctionfieldodoo-update
2 Odpowiedzi
8299 Widoki
Awatar
Eric

Hello,  I have a function field in a tree view that is supposed to display a calculated field, but for some reason the field is not being recalculated whenever I go to the tree view.  I know the function that calculates the field is not being called because I put a breakpoint in the beginning of the method, and it never stops on that breakpoint.  Does anyone know why a method for a functional field would not be called?  

Here is my field definition:

'days_remaining_func': fields.function(_get_days_remaining_func, method=True, type="integer", string="Days Remaining", store=True),


Here is my method:

def _get_days_remaining_func(self, cr, uid, ids, field_name, arg, context={}):

    # calculate the remaining days by subtracting the exp_date - todays date

    res = {}

    for rec in self.browse(cr, uid, ids):

        if not rec.support_exp_date:

            res.update({rec.id:{ field_name: None }})

            continue

        exp_date = datetime.strptime(rec.support_exp_date, "%Y-%m-%d")

        todays_date = datetime.now()

        days_remaining = exp_date - todays_date

        days_remaining = days_remaining.days

        res.update({rec.id:{ field_name: days_remaining }})

    return res

0
Awatar
Odrzuć
Awatar
Axel Mendoza
Najlepsza odpowiedź

The field does not recalculate because of it's defined with store=True

1
Awatar
Odrzuć
Awatar
Anil Kesariya
Najlepsza odpowiedź

HI Eric,

The issue suspected from your code is if your function method is call for only one field.

Than you can directly assigned return value to ID, you don't need to pass value with field. If your method is called for any new records means this is the fault.

Currently you did this.

 res.update({rec.id:{ field_name: None }}) 

Instead try this

res[rec.id] = your_val or None  

Or if your method is not called for already calculated record it means its store=true issue.

Here is the explanation of store=true..

When you define any functional field. than you will have

these possibilities :

when you set store=True it once the value of this will calculated will be stored in database and so ID of that record will not pass in list to recalculate if it is already calculated.

when  you haven't applied store=True than all the that ID will be pass to recalculate if any changes made on that record.

or

If you want to reconsecrate your information after storing in database than you can use store = {} (dictionary option)

Here in dictionary you pass the number of model and fields based on that your fields values is going to update and it will store as well.

The real example of store you will find in account module with account.invoice model. functional field with store= {}.

Any one who knows more about functional field than can improve my Answer.

Hope this will help.

Rgds,

Anil.








0
Awatar
Odrzuć
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ść
[SOLVED] OpenERP 7: Tree view - Order by date of creation and not by name Rozwiązane
treeview openerp7
Awatar
Awatar
Awatar
9
cze 15
14106
openerp7 - Return tree view from class with no new fields
treeview openerp7 return
Awatar
0
cze 18
3504
Display fields.function on tree view Rozwiązane
treeview one2many function_field
Awatar
Awatar
Awatar
4
sty 24
13899
Functional fields not update on write() -- for sales.order.line (price_subtotal) Rozwiązane
sale.order.line function_field functionfield
Awatar
Awatar
1
mar 15
8085
how to save functional fields in openerp7?
store openerp7 function_field store=False
Awatar
0
lip 19
4023
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 Svenska ภาษาไทย 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