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
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    Others
    • 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
  • Help

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

calculated field with new API attribute calculate

Odoberať

Get notified when there's activity on this post

This question has been flagged
apicalculate
5 Replies
8586 Zobrazenia
Avatar
Yves Goldberg

in my model.py, I have:

totFee = fields.Float(compute='_compute_totFee')


@api.depends('field1','field2')
def _compute_totFee(self): 
for rec in self: 
self.totFee = 44

I get an error message:

ERROR crc openerp.http: Exception during JSON request handling.

Traceback (most recent call last):

File "/opt/odoo/openerp/http.py", line 643, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "/opt/odoo/openerp/http.py", line 680, in dispatch

result = self._call_function(**self.params)

File "/opt/odoo/openerp/http.py", line 316, in _call_function

return checked_call(self.db, *args, **kwargs)

File "/opt/odoo/openerp/service/model.py", line 118, in wrapper

return f(dbname, *args, **kwargs)

File "/opt/odoo/openerp/http.py", line 309, in checked_call

result = self.endpoint(*a, **kw)

File "/opt/odoo/openerp/http.py", line 959, in __call__

return self.method(*args, **kw)

File "/opt/odoo/openerp/http.py", line 509, in response_wrap

response = f(*args, **kw)

File "/opt/enterprise-9/web/controllers/main.py", line 911, in call_kw

return self._call_kw(model, method, args, kwargs)

File "/opt/enterprise-9/web/controllers/main.py", line 903, in _call_kw

return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)

File "/opt/odoo/openerp/api.py", line 250, in wrapper

return old_api(self, *args, **kwargs)

File "/opt/odoo/openerp/models.py", line 3193, in read

result = BaseModel.read(records, fields, load=load)

File "/opt/odoo/openerp/api.py", line 248, in wrapper

return new_api(self, *args, **kwargs)

File "/opt/odoo/openerp/models.py", line 3239, in read

values[name] = field.convert_to_read(record[name], use_name_get)

File "/opt/odoo/openerp/models.py", line 5740, in __getitem__

return self._fields[key].__get__(self, type(self))

File "/opt/odoo/openerp/fields.py", line 829, in __get__

self.determine_value(record)

File "/opt/odoo/openerp/fields.py", line 936, in determine_value

self.compute_value(recs)

File "/opt/odoo/openerp/fields.py", line 891, in compute_value

self._compute_value(records)

File "/opt/odoo/openerp/fields.py", line 881, in _compute_value

getattr(records, self.compute)()

AttributeError: 'transactions' object has no attribute '_compute_totFee'



how would I write that function?

TIA



0
Avatar
Zrušiť
Yenthe Van Ginneken (Mainframe Monkey)

Hi Yves, Is your function above the fields.Float that has the compute field? If the function is under the fields.Float move it above the fields.Float. Regards, Yenthe

Prakash

check the indentation of method, it should be inside the class

Avatar
Vince
Best Answer

use compute field

0
Avatar
Zrušiť
Avatar
Yves Goldberg
Autor Best Answer

thank you a bunch Yenthe, Prakash and Nicolas!!

It works now :)

0
Avatar
Zrušiť
Avatar
Nicolas JEUDY
Best Answer

Hello, 

- without the complete file it is difficult to help you.

on note:


@api.depends('field1','field2')def _compute_totFee(self):      
for rec in self: 
self.totFee = 44

should be:

@api.depends('field1','field2')def _compute_totFee(self):      
for rec in self:
rec.totFee = 44


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
Has anyone integrated Helpdesk with Zoom for meeting scheduling?
api
Avatar
Avatar
1
aug 25
1250
Using API check if Odoo is using Odoo sh or on-premises hosting. Solved
api
Avatar
Avatar
1
aug 25
1615
External API XMLRPC Authentication Keeps Replying with false
api
Avatar
Avatar
Avatar
2
júl 25
4513
API xmlrpc - upload pdf bills to account Solved
api
Avatar
Avatar
Avatar
3
júl 25
1685
Odoo API connection credential - How to get these credentials?
api
Avatar
Avatar
1
jún 25
3545
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