Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
7 Trả lời
5794 Lượt xem

I am using odoo.sh.


Since Odoo.sh is providing editor(Python and Odoo shell) to run python code.

How can I run an import script using this?

I can import my xls file data and I can use the path as ell


I have tried the following code but didn't work!

Can someone help me with this?


import odoorpc

import xmlrpc

import sys

import csv



FILE_NAME = "src/import_customer_invoice_data.csv"

HOST_NAME = 'myshurl.odoo.com'

PORT_NUMBER = 443

DB_NAME = 'myshdatabase'

USER_NAME = 'admin'

PASSWORD = 'MyPass'


src_odoo = False

try:

    src_odoo = odoorpc.ODOO(HOST_NAME, port=PORT_NUMBER)

    print(src_odoo)

    

except:

    print("Connection Error : ", sys.exc_info()[0])



if src_odoo:

    try:

        src_odoo.login(DB_NAME, USER_NAME, PASSWORD)

    except:

        print("Login Error")

    else:

        print("Connection Done!! ", src_odoo)


Ảnh đại diện
Huỷ bỏ

"Didn't work?" - can you provided details. Error? Wrong result?

Can you try with the xmlrpc instead of odoorpc and see

Tác giả

@Ray Carnes: It gives me connection error.

@Niya Raphy: I have also tried with xmlrpc, still getting connection error.

Can you show the code that you have tried using xmlrpc and also nice if you share the error message

Tác giả

import xmlrpc

import sys

import csv

FILE_NAME = "src/import_customer_invoice_data.csv"

DB_NAME = 'mydb'

USER_NAME = 'admin'

PASSWORD = 'mypass@123'

src_odoo = False

try:

sock_common = xmlrpclib.ServerProxy('https://myurl:8069/xmlrpc/common', allow_none=True)

except:

print("Connection Error : ", sys.exc_info()[0])

Its giving following error.

Connection Error : <class 'NameError'>

Tác giả Câu trả lời hay nhất

It worked with the following code.

==================================

import xmlrpc

from xmlrpc import client #xmlrpclib


url = 'https://myinstnce.odoo.com' #this is without port number.

username = 'admin' #the user

password = 'mypss123'      #the password of the user

dbname = 'Mydb'    #the database



common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))

common.version()

uid = common.authenticate(dbname, username, password, {})

print("user:>>>>",uid)

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
1937
4
thg 4 25
12382
1
thg 2 25
3727
1
thg 1 25
1528
1
thg 1 25
5129