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

Error When Created second records

Subscriure's

Get notified when there's activity on this post

This question has been flagged
3251 Vistes
Avatar
philip

Is there anyone can figure out what has to be done. When I created My first record,
everything is fine then created the second record I got error message below. and I don't know how to fix.
Is this a bug or something wrong with my module/code.

Thank you

python functions------

from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
import time
from osv import osv, fields

class xyz_product(osv.Model):
    _name = "xyz.product"

            ## Beginning Selling Area
    def totalbegsellingarea(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzprod in self.browse(cr, uid, ids, context):
            if xyzprod.begsellingareaboxpcs=='12':
                res[xyzprod.id] = xyzprod.begsellingarea * 12
            if xyzprod.begsellingareaboxpcs=='1':
                res[xyzprod.id] = xyzprod.begsellingarea * 1
            return res
            ## Beginning Warehouse
    def totalbegwarehouse(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzprod in self.browse(cr, uid, ids, context):
            if xyzprod.begwarehousboxpcs=='12':
                res[xyzprod.id] = xyzprod.begwarehouse * 12
            if xyzprod.begwarehousboxpcs=='1':
                res[xyzprod.id] = xyzprod.begwarehouse * 1
            return res
            
            ## Ending Selling Area
    def totalendsellingarea(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzprod in self.browse(cr, uid, ids, context):
            if xyzprod.endsellingareaboxpcs=='12':
                res[xyzprod.id] = xyzprod.endsellingarea * 12
            if xyzprod.endsellingareaboxpcs=='1':
                res[xyzprod.id] = xyzprod.endsellingarea * 1
            return res
            ## Ending Warehouse
    def totalendwarehouse(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzprod in self.browse(cr, uid, ids, context):
            if xyzprod.endwarehousboxpcs=='12':
                res[xyzprod.id] = xyzprod.endwarehouse * 12
            if xyzprod.endwarehousboxpcs=='1':
                res[xyzprod.id] = xyzprod.endwarehouse * 1
            return res

    def get_daysales1(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales1 in self.browse(cr, uid, ids, context):
            res[daysales1.id] = daysales1.price * daysales1.offtake1
            return res

    def get_daysales2(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales2 in self.browse(cr, uid, ids, context):
            res[daysales2.id] = daysales2.price * daysales2.offtake2
            return res

    def get_daysales3(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales3 in self.browse(cr, uid, ids, context):
            res[daysales3.id] = daysales3.price * daysales3.offtake3
            return res

    def get_daysales4(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales4 in self.browse(cr, uid, ids, context):
            res[daysales4.id] = daysales4.price * daysales4.offtake4
            return res

    def get_daysales5(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales5 in self.browse(cr, uid, ids, context):
            res[daysales5.id] = daysales5.price * daysales5.offtake5
            return res
    
    def get_daysales6(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales6 in self.browse(cr, uid, ids, context):
            res[daysales6.id] = daysales6.price * daysales6.offtake6
            return res

    def get_daysales7(self, cr, uid, ids, name, arg, context):
        res = {}
        for daysales7 in self.browse(cr, uid, ids, context):
            res[daysales7.id] = daysales7.price * daysales7.offtake7
            return res

    def get_totaldelivery(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzdelivery in self.browse(cr, uid, ids, context):
            res[xyzdelivery.id] = xyzdelivery.delivery1 + xyzdelivery.delivery2 + xyzdelivery.delivery3 + xyzdelivery.delivery4 + xyzdelivery.delivery5 + xyzdelivery.delivery6 + xyzdelivery.delivery7
            return res

    def get_totalreturn(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzreturn in self.browse(cr, uid, ids, context):
            res[xyzreturn.id] = xyzreturn.return1 + xyzreturn.return2 + xyzreturn.return3 + xyzreturn.return4 + xyzreturn.return5 + xyzreturn.return6 + xyzreturn.return7
            return res

    def get_totalpullout(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzpullout in self.browse(cr, uid, ids, context):
            res[xyzpullout.id] = xyzpullout.pullout1 + xyzpullout.pullout2 + xyzpullout.pullout3 + xyzpullout.pullout4 + xyzpullout.pullout5 + xyzpullout.pullout6 + xyzpullout.pullout7
            return res

    def get_totalofftake(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzofftake in self.browse(cr, uid, ids, context):
            res[xyzofftake.id] = ((xyzofftake.begwarehouse + xyzofftake.begsellingarea) + xyzofftake.totaldelivery + xyzofftake.totalreturn - (xyzofftake.endwarehouse + xyzofftake.endsellingarea)) - xyzofftake.totalpullout
            return res

    def get_totalweeklysales(self, cr, uid, ids, name, arg, context):
        res = {}
        for totalweeklysales in self.browse(cr, uid, ids, context):
            res[totalweeklysales.id] = totalweeklysales.price * totalweeklysales.totalofftake
            return res

    _columns = {

.......

}

error in ubuntu version OpenERP7/odoo7---------------

Client Traceback (most recent call last):
 

     File "/home/philip/ws/openerp/web/addons/web/http.py", line 204, in dispatch
        response["result"] = method(self, **self.params)
      File "/home/philip/ws/openerp/web/addons/web/controllers/main.py", line 1051, in search_read
        return self.do_search_read(req, model, fields, offset, limit, domain, sort)
      File "/home/philip/ws/openerp/web/addons/web/controllers/main.py", line 1086, in do_search_read
        records = Model.read(ids, fields or False, req.context)
      File "/home/philip/ws/openerp/web/addons/web/session.py", line 42, in proxy
        result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)
      File "/home/philip/ws/openerp/web/addons/web/session.py", line 30, in proxy_method
        result = self.session.send(self.service_name, method, *args)
      File "/home/philip/ws/openerp/web/addons/web/session.py", line 103, in send
        raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)


    Server Traceback (most recent call last):
      File "/home/philip/ws/openerp/web/addons/web/session.py", line 89, in send
        return openerp.netsvc.dispatch_rpc(service_name, method, args)
      File "/home/philip/ws/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc
        result = ExportService.getService(service_name).dispatch(method, params)
      File "/home/philip/ws/openerp/server/openerp/service/web_services.py", line 626, in dispatch
        res = fn(db, uid, *params)
      File "/home/philip/ws/openerp/server/openerp/osv/osv.py", line 190, in execute_kw
        return self.execute(db, uid, obj, method, *args, **kw or {})
      File "/home/philip/ws/openerp/server/openerp/osv/osv.py", line 132, in wrapper
        return f(self, dbname, *args, **kwargs)
      File "/home/philip/ws/openerp/server/openerp/osv/osv.py", line 199, in execute
        res = self.execute_cr(cr, uid, obj, method, *args, **kw)
      File "/home/philip/ws/openerp/server/openerp/osv/osv.py", line 187, in execute_cr
        return getattr(object, method)(cr, uid, *args, **kw)
      File "/home/philip/ws/openerp/server/openerp/osv/orm.py", line 3674, in read
        result = self._read_flat(cr, user, select, fields, context, load)
      File "/home/philip/ws/openerp/server/openerp/osv/orm.py", line 3798, in _read_flat
        record[f] = res2[record['id']]
    KeyError: 2

error in Windows version OpenERP7/odoo7-----------------

Client Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\http.py", line 204, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\controllers\main.py", line 1051, in search_read
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\controllers\main.py", line 1086, in do_search_read
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\session.py", line 42, in proxy
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\session.py", line 30, in proxy_method
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\session.py", line 103, in send


Server Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\session.py", line 89, in send
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\netsvc.py", line 296, in dispatch_rpc
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 190, in execute_kw
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 132, in wrapper
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 199, in execute
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 187, in execute_cr
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 3679, in read
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 3803, in _read_flat
KeyError: 2

But if I remove the folowing line:

    def get_totaldelivery(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzdelivery in self.browse(cr, uid, ids, context):
            res[xyzdelivery.id] = xyzdelivery.delivery1 + xyzdelivery.delivery2 + xyzdelivery.delivery3 + xyzdelivery.delivery4 + xyzdelivery.delivery5 + xyzdelivery.delivery6 + xyzdelivery.delivery7
            return res

    def get_totalreturn(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzreturn in self.browse(cr, uid, ids, context):
            res[xyzreturn.id] = xyzreturn.return1 + xyzreturn.return2 + xyzreturn.return3 + xyzreturn.return4 + xyzreturn.return5 + xyzreturn.return6 + xyzreturn.return7
            return res

    def get_totalpullout(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzpullout in self.browse(cr, uid, ids, context):
            res[xyzpullout.id] = xyzpullout.pullout1 + xyzpullout.pullout2 + xyzpullout.pullout3 + xyzpullout.pullout4 + xyzpullout.pullout5 + xyzpullout.pullout6 + xyzpullout.pullout7
            return res

    def get_totalofftake(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzofftake in self.browse(cr, uid, ids, context):
            res[xyzofftake.id] = ((xyzofftake.begwarehouse + xyzofftake.begsellingarea) + xyzofftake.totaldelivery + xyzofftake.totalreturn - (xyzofftake.endwarehouse + xyzofftake.endsellingarea)) - xyzofftake.totalpullout
            return res

    def get_totalweeklysales(self, cr, uid, ids, name, arg, context):
        res = {}
        for totalweeklysales in self.browse(cr, uid, ids, context):
            res[totalweeklysales.id] = totalweeklysales.price * totalweeklysales.totalofftake
            return res

even if i only add like below, I got desame  above error.

is there someone who can create to compute the following field in the different way but same result

    def get_totaldelivery(self, cr, uid, ids, name, arg, context):
        res = {}
        for xyzdelivery in self.browse(cr, uid, ids, context):
            res[xyzdelivery.id] = xyzdelivery.delivery1 + xyzdelivery.delivery2 + xyzdelivery.delivery3 + xyzdelivery.delivery4 + xyzdelivery.delivery5 + xyzdelivery.delivery6 + xyzdelivery.delivery7
            return res

 

0
Avatar
Descartar
philip
Autor

is there someone who can create to compute the following field in the different way of coding but same result in below code? ----def get_totaldelivery(self, cr, uid, ids, name, arg, context): --------res = {} --------for xyzdelivery in self.browse(cr, uid, ids, context): ------------res[xyzdelivery.id] = xyzdelivery.delivery1 + xyzdelivery.delivery2 + xyzdelivery.delivery3 + xyzdelivery.delivery4 + xyzdelivery.delivery5 + xyzdelivery.delivery6 + xyzdelivery.delivery7 ------------return res

philip
Autor

Hi all, my apologies to my last post, I found out that the error occurred when I add my functional field to my tree view, but in form view is working but I needto show in tree view
'totaldelivery': fields.function(get_totaldelivery, 'Total Delivery'), Thanks

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