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

Dataerror updating function field of one2many object using on_change event

Subscriure's

Get notified when there's activity on this post

This question has been flagged
one2manyon_changefunction_field
5730 Vistes
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
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
Related Posts Respostes Vistes Activitat
How to use Onchange function in one2many
one2many on_change
Avatar
Avatar
1
de març 15
6556
key Error function field error for O2M field. when opening form view of employee got below error
one2many function_field v10
Avatar
1
de maig 18
5681
create and edit items of a one2many field through on_change method
one2many on_change active_id
Avatar
0
de gen. 17
9592
How to write function fields for many2one or one2many?
many2one one2many function_field
Avatar
Avatar
2
de maig 16
7439
Display fields.function on tree view Solved
treeview one2many function_field
Avatar
Avatar
Avatar
4
de gen. 24
13392
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