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

Need to raise the Exception based on my Traceback

Subscriure's

Get notified when there's activity on this post

This question has been flagged
pythonpython2.7python3odoo8odoo-v9
1 Respondre
9207 Vistes
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
Best Answer

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.

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
DISPLAYING THE SAME ORDER OF KEY WHICH HAVE IN MY LIST OF DICTIONARY KEYS IN MY OUTPUT Solved
python python2.7 openerp7 python3 odoo
Avatar
Avatar
4
de maig 16
6834
Pivot view does not display in odoo 8 Solved
python2.7 odoo8
Avatar
Avatar
1
d’oct. 22
6280
How to hide bugs and error message for users in odoo
python2.7 odoo-v9
Avatar
Avatar
1
de març 22
8393
How to make tree of dictionary? Solved
python python2.7
Avatar
Avatar
1
de gen. 24
5214
How can i calculate the selling price of a product according to the supplier price ?
python2.7 odoo-v9
Avatar
Avatar
1
de juny 18
8715
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