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
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    Others
    • 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
  • Help

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

Dataerror updating function field of one2many object using on_change event

Odoberať

Get notified when there's activity on this post

This question has been flagged
one2manyon_changefunction_field
5709 Zobrazenia
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
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
Related Posts Replies Zobrazenia Aktivita
How to use Onchange function in one2many
one2many on_change
Avatar
Avatar
1
mar 15
6519
key Error function field error for O2M field. when opening form view of employee got below error
one2many function_field v10
Avatar
1
máj 18
5663
create and edit items of a one2many field through on_change method
one2many on_change active_id
Avatar
0
jan 17
9570
How to write function fields for many2one or one2many?
many2one one2many function_field
Avatar
Avatar
2
máj 16
7424
Display fields.function on tree view Solved
treeview one2many function_field
Avatar
Avatar
Avatar
4
jan 24
13365
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