Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Avoid CORS Error (WebApp Cordova)

Odebírat

Get notified when there's activity on this post

This question has been flagged
webservicesaccessoriginallowCORS
7 Odpovědi
37179 Zobrazení
Avatar
Fernando La Chica Mera

Hi, I'm developing an App with Cordova with which I intend to consume services Odoo. If launched the App with an emulator of Cordova as "ripple emulate" gives me error 404. Doing a little research I see that is related to that default CORS not allowed. I have the same problem if I want to consume the webservice from a web page installed in a different domain of Odoo. I have no problems in playing with the application if I have it installed on the device but I always try to compile and install and that is time consuming.

Have you got enabled CORS in Odoo? How I can do to add the allow-access-from domain * a werkzug header? Thank you.

0
Avatar
Zrušit
Fernando La Chica Mera
Autor

No one has faced the problem of access to external web via webservice to Odoo?

Avatar
Fernando La Chica Mera
Autor Nejlepší odpověď

I managed to consume the XML-RPC service from a Web App. I use https://github.com/timheap/jquery-xmlrpc

To make it work I had to modify the file <Odoo> /openerp/service/wsgi_server.py in the following procedures


def xmlrpc_return(start_response, service, method, params, string_faultcode=False):

"""

Helper to call a service's method with some params, using a wsgi-supplied

``start_response`` callback.

This is the place to look at to see the mapping between core exceptions

and XML-RPC fault codes.

"""

# Map OpenERP core exceptions to XML-RPC fault codes. Specific exceptions

# defined in ``openerp.exceptions`` are mapped to specific fault codes;

# all the other exceptions are mapped to the generic

# RPC_FAULT_CODE_APPLICATION_ERROR value.

# This also mimics SimpleXMLRPCDispatcher._marshaled_dispatch() for

# exception handling.

try:

result = openerp.http.dispatch_rpc(service, method, params)

response = xmlrpclib.dumps((result,), methodresponse=1, allow_none=False, encoding=None)

except Exception, e:

if string_faultcode:

response = xmlrpc_handle_exception_string(e)

else:

response = xmlrpc_handle_exception_int(e)

start_response("200 OK", [

('Content-Type','text/xml'),('Content-Length', str(len(response))),

('Access-Control-Allow-Origin','*'),

('Access-Control-Allow-Methods','POST, GET, OPTIONS'),

('Access-Control-Max-Age',1000),

('Access-Control-Allow-Headers','origin, x-csrftoken, content-type, accept'),

]

)

return [response]

def wsgi_xmlrpc(environ, start_response):

""" Two routes are available for XML-RPC

/xmlrpc/<service> route returns faultCode as strings. This is a historic

violation of the protocol kept for compatibility.

/xmlrpc/2/<service> is a new route that returns faultCode as int and is

therefore fully compliant.

"""

if environ['REQUEST_METHOD'] == "OPTIONS":

response = werkzeug.wrappers.Response('OPTIONS METHOD DETECTED')

response.headers['Access-Control-Allow-Origin'] = '*'

response.headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'

response.headers['Access-Control-Max-Age'] = 1000

# note that '*' is not valid for Access-Control-Allow-Headers

response.headers['Access-Control-Allow-Headers'] = 'origin, x-csrftoken, content-type, accept'

return response(environ, start_response)

if environ['REQUEST_METHOD'] == 'POST' and environ['PATH_INFO'].startswith('/xmlrpc/'):

length = int(environ['CONTENT_LENGTH'])

data = environ['wsgi.input'].read(length)

# Distinguish betweed the 2 faultCode modes

string_faultcode = True

if environ['PATH_INFO'].startswith('/xmlrpc/2/'):

service = environ['PATH_INFO'][len('/xmlrpc/2/'):]

string_faultcode = False

else:

service = environ['PATH_INFO'][len('/xmlrpc/'):]

params, method = xmlrpclib.loads(data)

return xmlrpc_return(start_response, service, method, params, string_faultcode)



Would you know tell me how to take these changes into an installable module? Would I have to go into the core?

1
Avatar
Zrušit
El mehdi EL OUALI

hi Fernando

I want to make ionic app to get data from odoo 12 server and i have been blocked by CORS policy, you have any solution for my issue

Fernando La Chica Mera
Autor

I'm sorry I can't help you. This solution I implemented was used in older versions of Odoo and I don't think it works in a current one. Surely someone knows what settings they should apply to not be blocked by CORS. If not, doing something similar should serve you.

Avatar
Choosak Songsawang
Nejlepší odpověď

Hello

I researched on internet for a while, here are information and solution I would like to share:

1) I have modified "odoo\http.py" and also "odoo\service\wsgi_server.py" but had no luck.

2) I installed chrome plug-in to bypass "Cross-Origin Resource Sharing" also not working.

3) I also built ".apk" package and ran on real mobile device, also not working

Finally :)

4) I call odoo api through proxy server running nginx, no cors error anymore.

Hope this help.


0
Avatar
Zrušit
Avatar
Ravi Gadhia
Nejlepší odpověď

Hi

To enable CORS for a particular route/endpoint you can pass cors params on a route like

@http.route('/my/route', type='json', auth='none', cors='*')  

def my_route(self):      

        ........

if you want to enable CORS for all the routes(not recommended) here are few options​

  • override werkzeug Response wrapper class ref \https://github.com/odoo/odoo/blob/12.0/odoo/http.py#L1245  

  • Nginx configuration can enable CORS

  • you can create werkzeug middleware for it

0
Avatar
Zrušit
Mohamed Mamdouh Shehata

Hello, I am building an odoo 13 app for my graduation project, can anyone help please

Avatar
Carlos
Nejlepší odpověď

I Want to make the same in Angular 7 i need somthing to avoid cors ¿any help?

0
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
(^_-)Contacto~Volaris~Directo(-_^)¿Cómo hablar directamente en Volaris?
webservices
Avatar
0
lis 25
7
How to assign a user to admin on sales, customer invoices and inventory
access
Avatar
Avatar
1
bře 25
2396
Granting Payslip Access to a Portal User: Troubleshooting Custom Group Permissions
access
Avatar
0
srp 25
2231
How to change existing access right of some model in a ir.model.access.csv? Vyřešeno
access
Avatar
Avatar
Avatar
2
dub 23
27685
Where is my design on website of odoo stored?
webservices
Avatar
Avatar
Avatar
2
říj 21
4514
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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