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
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • 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
    Iní
    • 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
  • Pomoc

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

Functional fields

Odoberať

Get notified when there's activity on this post

This question has been flagged
3 Replies
7747 Zobrazenia
Avatar
Marek Jan-Alexander

Hi,

i would like to add some fields to account.move and get them calculated. Let´s say I would like to add two fields - tax_base, tax_amount:

_columns = {
        'tax_base': fields.function(
            _tax_balance, method=True,
            string='Tax base',
            store=True),
        'tax_amount': fields.function(
            _tax_balance, method=True,
            string="Amount Tax",
            store=True),

However, when I try to use following function to calculate these fields (this just should throw zeros, but not functioning) for all account.move objects:

def _tax_balance(self, cr, uid, ids, field_name, arg, context=None):
        res = {}

        for move in self.read(cr, uid, ids, context=context):
            res[move['id']] = {
                'tax_base': 0.0,
                'tax_amount': 0.0,
            }      
        return res

This error appears:

Server Traceback (most recent call last): File "E:\erp7\addons\web\session.py", line 90, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "E:\erp7\openerp\netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "E:\erp7\openerp\service\web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "E:\erp7\openerp\osv\osv.py", line 188, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "E:\erp7\openerp\osv\osv.py", line 131, in wrapper return f(self, dbname, *args, **kwargs) File "E:\erp7\openerp\osv\osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "E:\erp7\openerp\osv\osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "E:\erp7\addons\base\module\module.py", line 426, in button_immediate_install return self._button_immediate_function(cr, uid, ids, self.button_install, context=context) File "E:\erp7\addons\base\module\module.py", line 473, in _button_immediate_function _, pool = pooler.restart_pool(cr.dbname, update_module=True) File "E:\erp7\openerp\pooler.py", line 39, in restart_pool registry = RegistryManager.new(db_name, force_demo, status, update_module) File "E:\erp7\openerp\modules\registry.py", line 233, in new openerp.modules.load_modules(registry.db, force_demo, status, update_module) File "E:\erp7\openerp\modules\loading.py", line 354, in load_modules loaded_modules, update_module) File "E:\erp7\openerp\modules\loading.py", line 256, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "E:\erp7\openerp\modules\loading.py", line 165, in load_module_graph init_module_models(cr, package.name, models) File "E:\erp7\openerp\modules\module.py", line 385, in init_module_models t[1](cr, *t[2]) File "E:\erp7\openerp\osv\orm.py", line 2807, in _update_store cr.execute(update_query, (ss[1](val), key)) File "E:\erp7\openerp\osv\fields.py", line 1092, in <lambda> self._symbol_set = ('%s', lambda x: float_repr(float_round(__builtin__.float(x or 0.0), TypeError: float() argument must be a string or a number

 

Thanks for help!

0
Avatar
Zrušiť
Avatar
Emipro Technologies Pvt. Ltd.
Best Answer

Hi,

If you are use one function to calculate more then one field then you have to use multi attribute into field defination. So, first of all put multi attribute into your code as like below.

_columns = {
        'tax_base': fields.function(
            _tax_balance, method=True,
            string='Tax base',
            store=True, multi=True),
        'tax_amount': fields.function(
            _tax_balance, method=True,
            string="Amount Tax",
            store=True, multi=True),

3
Avatar
Zrušiť
Avatar
Alcaline
Best Answer

Got the same problem. but it doesn't work the multi = True on my codes..

0
Avatar
Zrušiť
Avatar
Marek Jan-Alexander
Autor Best Answer

easy solution & works great. Thanks!

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
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