Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Functional fields

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
3 Réponses
7750 Vues
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
Ignorer
Avatar
Emipro Technologies Pvt. Ltd.
Meilleure réponse

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
Ignorer
Avatar
Alcaline
Meilleure réponse

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

0
Avatar
Ignorer
Avatar
Marek Jan-Alexander
Auteur Meilleure réponse

easy solution & works great. Thanks!

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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