Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Error When Created second records

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
3250 Vistas
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

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

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