Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar 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
  • Proyecto
  • 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

Need to raise the Exception based on my Traceback

Suscribirse

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

Se marcó esta pregunta
pythonpython2.7python3odoo8odoo-v9
1 Responder
9215 Vistas
Avatar
Dasadiya Chaitanya

I am working on for generate the request and response on httplib class. In this case I am working on request and response string xml file so that I will send some request to my API server and server reply back to me. the request and response in based on sting xml format.

When I am sending my data with wrong URL format then its gives me an error I need to raise exception based on that below Traceback :

2016-01-07 11:27:40,443 12180 ERROR dynaweld_15_09_15 openerp.netsvc: mismatched tag: line 1, column 959
Traceback (most recent call last):
  File "/home/best/workspace/dynaweld/server/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/best/workspace/dynaweld/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/home/best/workspace/dynaweld/server/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/best/workspace/dynaweld/server/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/best/workspace/dynaweld/server/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/best/workspace/dynaweld/server/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/best/workspace/dynaweld/prod_4/r3x_securepay/model/securepay_login.py", line 147, in test_secure_pay
    doc = minidom.parseString(data)
  File "/usr/lib/python2.7/xml/dom/minidom.py", line 1930, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
ExpatError: mismatched tag: line 1, column 959



I had tried the below way for raise my exception but its not working well.

from xml.parsers.expat import ExpatError
from openerp.osv import fields, osv, orm
from openerp.tools.translate import _
from openerp import netsvc
import httplib, ConfigParser, urlparse
import xmlrpclib
from xml.dom import minidom
from xml.parsers.expat import ExpatError
from datetime import datetime
import pytz

login_request="""<?xml version='1.0' encoding='UTF-8'?>
                    <SecurePayMessage>
                            <MessageInfo>
                                <messageID>%s_000000000000000</messageID>
                                <messageTimestamp>%s</messageTimestamp>
                                <timeoutValue>%d</timeoutValue>
                                <apiVersion>xml-4.2</apiVersion>
                            </MessageInfo>
                            <MerchantInfo>
                                <merchantID>%s</merchantID>
                                <password>%s</password>
                            </MerchantInfo>
                            <RequestType>Echo</RequestType>
                    </SecurePayMessage>"""%(timestamp_string[:14],timestamp_string,login_data.get('time_out',60),login_data.get('merchant_id',''),login_data.get('password',''))
try:
    urldat = urlparse.urlparse(login_data.get('url'))
    conn = httplib.HTTPSConnection(urldat[1])
    length  = len(login_request)
    GenerateHeaders = {"Content-Type":"text/xml","Content-Length":str(length)}
    conn.request("POST", urldat[2],login_request, GenerateHeaders)
    response = conn.getresponse()
    data = response.read()
except ExpatError:
    raise osv.except_osv(_('Error!'), _('Invalid Server URL from the API Configuration for SecurePay .!'))
except httplib.socket.error:    
    raise osv.except_osv(_('Error!'), _('Internet connection is not available !\t\n please try to test again using enabled Internet connection.'))
finally:
    conn.close()
return data
                                                                                                       

Any help really appreciated :)

         

1
Avatar
Descartar
Avatar
Pawan
Mejor respuesta

Chaitanya,

While rendering an xml view, you cannot raise an exception as we are doing in normal odoo flow.

For that what you can do is to return some unique flag from your controller function to the xml template, which is going to be rendered and then handle it in xml as you want to(normal way is to show that error in your customized way on form/ or raise alert using jquery)

For ex: in your above code, under 'except' inspite of raising an exception, try returning some unique flag to denote error and then in the xml template<t> which is going to be rendered check for that unique flag and show your customized error.

Hope it helps!  

0
Avatar
Descartar
Dasadiya Chaitanya
Autor

@pavan you are not understand my question properly .please try to check again and then after u can post it.

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

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

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
DISPLAYING THE SAME ORDER OF KEY WHICH HAVE IN MY LIST OF DICTIONARY KEYS IN MY OUTPUT Resuelto
python python2.7 openerp7 python3 odoo
Avatar
Avatar
4
may 16
6836
Pivot view does not display in odoo 8 Resuelto
python2.7 odoo8
Avatar
Avatar
1
oct 22
6284
How to hide bugs and error message for users in odoo
python2.7 odoo-v9
Avatar
Avatar
1
mar 22
8398
How to make tree of dictionary? Resuelto
python python2.7
Avatar
Avatar
1
ene 24
5218
How can i calculate the selling price of a product according to the supplier price ?
python2.7 odoo-v9
Avatar
Avatar
1
jun 18
8721
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información 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 totalmente integrado.

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