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

Dataerror updating function field of one2many object using on_change event

S'inscrire

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

Cette question a été signalée
one2manyon_changefunction_field
5728 Vues
Avatar
Alexei R. Acosta

Hello I'm updating a function field of one2many object using on_change event. I pass the one2many object as a parameter of on_change function , and then I return it updated. Every it's ok, but when I create a new one2many object, Openerp show this error:

Client Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/addons/web/common/http.py", line 180, in dispatch response["result"] = method(controller, self, **self.params) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/addons/web/controllers/main.py", line 882, in get return self.do_get(req, model, ids, fields) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/addons/web/controllers/main.py", line 904, in do_get records = Model.read(ids, fields, req.session.eval_context(req.context)) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/addons/web/common/openerplib/main.py", line 250, in proxy args, kw) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/addons/web/common/openerplib/main.py", line 117, in proxy result = self.connector.send(self.service_name, method, *args) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/addons/web/common/http.py", line 611, in send raise fault

Server Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/addons/web/common/http.py", line 592, in send result = openerp.netsvc.dispatch_rpc(service_name, method, args) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/netsvc.py", line 360, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/service/web_services.py", line 572, in dispatch res = fn(db, uid, params) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/osv/osv.py", line 167, in execute_kw return self.execute(db, uid, obj, method, *args, *kw or {}) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/osv/osv.py", line 121, in wrapper return f(self, dbname, args, *kwargs) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/osv/osv.py", line 176, in execute res = self.execute_cr(cr, uid, obj, method, args, *kw) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/osv/osv.py", line 164, in execute_cr return getattr(object, method)(cr, uid, args, *kw) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/osv/orm.py", line 3381, in read result = self._read_flat(cr, user, select, fields, context, load) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/osv/orm.py", line 3440, in _read_flat cr.execute(query, (tuple(sub_ids),)) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/sql_db.py", line 152, in wrapper return f(self, args, *kwargs) File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_1-py2.7.egg/openerp/sql_db.py", line 212, in execute res = self._obj.execute(query, params) DataError: invalid input syntax for integer: "one2many_v_id_1027" LINE 1: ..._obra_evacuacion" WHERE df_obra_evacuacion.id IN ('one2many_...

here is my code:

In conjunto_hidraulico.py class:

_columns = {
   .....
    # Obras de evacuacion
    'obra_evacuacion_ids': fields.one2many('df.obra.evacuacion', 'conjunto_hidraulico_id',
                                           string='Evacuation works', required=False),
    ......
}    

def onchange_obra_evacuacion(self, cr, uid,ids,obra_evacuacion_ids,context=None):
    if context==None:
        context={}
    if(obra_evacuacion_ids):
        ##### update tree view with calculated values ###
        compuerta_obj = self.pool.get('df.compuerta')   #objeto que tiene todas las compuertas creadas hasta ahora
        for evacuation_work in obra_evacuacion_ids:
            cant = 0
            count = 0
            text = ""
            if evacuation_work[0] == 0 or (evacuation_work[0] == 1 and evacuation_work[2].has_key('compuerta_ids')):
                for gate in evacuation_work[2]['compuerta_ids']:
                    mode = gate[0]
                    if mode == 0 or mode == 1 or mode == 4:
                        cant = cant + 1     #calculate number of gates
                        if gate[2] and gate[2].has_key('numero'):       #create working order string
                            if count == 0:
                                text += str(gate[2]['numero'])
                            else:
                                text += "-" + str(gate[2]['numero'])
                        else:
                            gate_aux = compuerta_obj.browse(cr, uid, gate[1], context=context)
                            if count == 0:
                                text += str(gate_aux.numero)
                            else:
                                text += "-" + str(gate_aux.numero)
                    elif mode == 5:
                        cant = 0
                    count += 1
                evacuation_work[2]['cantidad_compuertas'] = cant
                evacuation_work[2]['regimen_trabajo'] = text

        return {'value':{
            'obra_evacuacion_ids': obra_evacuacion_ids
        }}

In conjunto_hidraulico_view.xml:

<field colspan="4" name="obra_evacuacion_ids" nolabel="1" on_change="onchange_obra_evacuacion(obra_evacuacion_ids)"/>

In obra_evacuacion.py class:

    _columns = {
        .....        
    'compuerta_ids': fields.one2many('df.compuerta', 'obra_evacuacion_id', 'Gates', required=False),
    'cantidad_compuertas': fields.function(gates_count, type='string', method=True, string="Amount of gates",
                                           help="Quantity of gates in case of 'Spillway' category"),
    'regimen_trabajo': fields.function(working_order, type='string', method=True, string="Gates's working regime",
                                       help="Working regime of the gates in case of 'Spillway' category"),
   }

Thanks is advanced.

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
Publications associées Réponses Vues Activité
How to use Onchange function in one2many
one2many on_change
Avatar
Avatar
1
mars 15
6551
key Error function field error for O2M field. when opening form view of employee got below error
one2many function_field v10
Avatar
1
mai 18
5677
create and edit items of a one2many field through on_change method
one2many on_change active_id
Avatar
0
janv. 17
9589
How to write function fields for many2one or one2many?
many2one one2many function_field
Avatar
Avatar
2
mai 16
7435
Display fields.function on tree view Résolu
treeview one2many function_field
Avatar
Avatar
Avatar
4
janv. 24
13386
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