Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Functional fields

Subscriure's

Get notified when there's activity on this post

This question has been flagged
3 Respostes
7745 Vistes
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
Descartar
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
Descartar
Avatar
Alcaline
Best Answer

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

0
Avatar
Descartar
Avatar
Marek Jan-Alexander
Autor Best Answer

easy solution & works great. Thanks!

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

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

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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