Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • 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 Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & 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
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Need to raise the Exception based on my Traceback

Subscribe

Get notified when there's activity on this post

This question has been flagged
pythonpython2.7python3odoo8odoo-v9
1 Reply
9206 Views
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
Discard
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
Discard
Dasadiya Chaitanya
Author

@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!

Sign up
Related Posts Replies Views Activity
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
May 16
6834
Pivot view does not display in odoo 8 Solved
python2.7 odoo8
Avatar
Avatar
1
Oct 22
6279
How to hide bugs and error message for users in odoo
python2.7 odoo-v9
Avatar
Avatar
1
Mar 22
8393
How to make tree of dictionary? Solved
python python2.7
Avatar
Avatar
1
Jan 24
5213
How can i calculate the selling price of a product according to the supplier price ?
python2.7 odoo-v9
Avatar
Avatar
1
Jun 18
8715
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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