Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

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

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

How to Debug python code in open erp

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
debugprint
16 Trả lời
73756 Lượt xem
Ảnh đại diện
Anuradha

I want to debug my python code in open erp i had given print statement but its not showing in log I check in tail -f /var/log/openerp/openerp-server.log any one please help?

5
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Thierry Godin
Câu trả lời hay nhất

Hi,

I use this for debugging :

import logging
_logger = logging.getLogger(__name__)

class my_class(osv.osv):

    # in the code when needed :
    _logger.error("my variable : %r", my_var)

    # Or
    msg = "This is my error message : " % my_var
    _logger.error(msg)

and in the log file , I'll have a line containing : my variable: + value of my_var

or : This is my error message + value of my_var

Of course, debug must be enabled in openerp-server.conf

Best regards

4
Ảnh đại diện
Huỷ bỏ
Anuradha
Tác giả

i enabled debug mode by setting debug_mode = true in /etc/openerp/openerp-server.conf and checking log tail -f /var/log/openerp/openerp-server.log but still its not showing print

Anuradha
Tác giả
import logging
from openerp.osv import fields, osv
import time
import pdb

_logger = logging.getLogger(__name__)
class calldata_print_report_wiz(osv.osv_memory):
    _name = "calldata.print.report.wiz"

    def _sel_func(self, cr, uid, context=None):

     print "hello"*100
     _logger.debug('helooooooooooooooooooooo')
     obj = self.pool.get('calldata1')
     ids = obj.search(cr, uid, [])
     res = obj.read(cr, uid, ids, ['Caller'], context)
     res = [r['Caller'] for r in res]
     return res
Ảnh đại diện
Serpent Consulting Services Pvt. Ltd.
Câu trả lời hay nhất

Follow the given steps to debug your python code in eclipse:

1) Go to '/openerp/server/openerp-server' and select openerp-server file, then right click on that file and select Debug As -> Python Run which will start the server.

2) After creating new debug configuration Go to 'Run -> Debug Configuration' and follow the given steps: 

    2.1: In "Arguments" tab under "Program Arguments", click on button "Variables" and new window will appear. 

    2.2: Then create new "Variable" by clicking on "Edit Variables" button and new window will appear.

    2.3: Press on "New" button and give your addons path as value. Ex: --addons ../addons,../your_module_path

     2.4: Press Ok in all the opened windows and then "Apply".

3) Now into "PyDev Package Explorer" view go to 6.1/server and right click on "openerp-server" file, Select 'Debug As --> Python Run'.

4) Now in "Console" you can see your server has been started.

5) Now open your .py file which you want to debug and set a breakpoint.

6) Now start your module's form from 'gtk' or 'web-client' and execution will stop when execution will reach to breakpoint.

7) Now debug your code by pressing "F5, F6, F7" and you can see value of your variables.

Thanks & regards,

Serpent Consulting Services Pvt. Ltd.

3
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Leonardo Donelli
Câu trả lời hay nhất

A non IDE-specific way to debug Python code is to import the pdb module (Python Debugger) and call pdb.set_trace() in your code where you want the debugger to open, it basically sets a breakpoint. Once in the debugger you can do a lot of things, like printing variables values, moving in the call stack, etc. see the pdb module documentation.
 

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

Thanks I like it!

Ảnh đại diện
Oleg Orlov
Câu trả lời hay nhất

Simple howto debugging openerp7 with intellij idea on windows.

Prerequests:

  • installed IntelliJ Idea 12 (www.jetbrains.com/idea/download/)
  • installed Openerp7 openerp-allinone-setup-7.0-latest.exe (www.openerp.com/start?download)

Step by step:

  • install intellij python plugin file->settings->plugins->install jetbrains plugins->python->install
  • download and install python 2.6 (i prefere portable version) portablepython.com/wiki/PortablePython1.1Py2.6.1/
  • copy listed files from portable python (F:\PortableApps\PortablePython_1.1_py2.6.1\App) to openerp (F:\OpenERP 7.0-20130731-231106\Server\server): python.exe Lib\site.py Lib\Queue.py Lib\trace.py
  • create new python project (openerp7debug) and configure python sdk file->new project->python module->openerp7debug->next->Python Interpreter->Configure-> + ->Python SDK->local->F:\OpenERP 7.0-20130731-231106\Server\server\python.exe->next->finish
  • right click openerp7debug->new->python file->openerp-server.py->add content

    import openerp if __name__ == "__main__": openerp.cli.main()

  • create debug configuration Edit configuration...-> + -> Python->Name: Debug openerp7->Script: F:\Users\orlov\YandexDisk\Work\openerp7debug\openerp-server.py-> Script parameters: "--config=F:\OpenERP 7.0-20130731-231106\Server\server\openerp-server.conf"-> Working directory: F:\OpenERP 7.0-20130731-231106\Server\server->OK

  • add breakpoint (on line openerp.cli.main() for example) and click debug, test breakpoints, inspect vars, test UI from browser
  • Happy debugging!
0
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Alejandro Perez Cosio
Câu trả lời hay nhất

You can try with ipdb, it's a python debugger available from pip. 

​pip install ipdb

To use it, just import it somewhere on your code, set the trace and use your module (you should be running odoo NOT as a service)

# python code ...
import ipdb; ipdb.set_trace()
# python code ...

Start your server

<openerp_path>$ ./openerp-server

When the line with ipdb is executed, you will notice your process stops, and your terminal is ready to debug.
Some keywords:

  • c (continue): will quit from debugging mode and continue with the execution
  • n (next): will do a step forward on your debugged code

Hope it helps you!

Regards

 

0
Ảnh đại diện
Huỷ bỏ
Sah Vinay Mahabir

I got this error when i added in called function in odoo

also i have install ipdb

Traceback (most recent call last):

File "/var/lib/odoo10/odoo/addons/base/ir/ir_cron.py", line 119, in _callback

getattr(model, method_name)(*args)

File "/var/lib/odoo/addons/10.0/allip_provu_phone/models/mac_address.py", line 116, in syncMacAddressProvuOrder

updateResponse = baseClass().updateInventoryForProvuPhoneOrder(product_itemlist, item_mac)

File "/var/lib/odoo/addons/10.0/allip_provu_phone/base/base_class.py", line 180, in updateInventoryForProvuPhoneOrder

import ipdb; ipdb.set_trace()

File "/usr/lib/python2.7/site-packages/ipdb/__main__.py", line 93, in set_trace

p = _init_pdb(context).set_trace(frame)

File "/usr/lib/python2.7/site-packages/ipdb/__main__.py", line 76, in _init_pdb

p = Pdb(def_colors)

File "/usr/lib/python2.7/site-packages/IPython/terminal/debugger.py", line 15, in __init__

self.pt_init()

File "/usr/lib/python2.7/site-packages/IPython/terminal/debugger.py", line 38, in pt_init

self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self.shell._eventloop)

AttributeError: 'TerminalInteractiveShell' object has no attribute '_eventloop'

Ảnh đại diện
Temur
Câu trả lời hay nhất

There is several ways to debug and I see you've got some good tips on the topic, but I'll narrow down your question to get worked print statement in python code as it's what you've tried, maybe it's your preferred way...

Instead of redirecting logs to logfile (to the /var/log/openerp/openerp-server.log in your case) and then read them from there using "tail -f" you can simply run openerp server from command line and you'll get printed stuff (including simple "print" command in python code) directly in the terminal from where you'll run the server. If you've installed nightly version and/or you're running openerp server in daemon mode, then you've to shutdown your server instance first ( something like: "/etc/init.d/openerp stop" or whatever is correct for your case). Then start the server from the terminal (you've to figure out what's path to the openep startup script, the odoo.py for v8 or openerp.py/openerp-server.py for v7), using command line options, at least use "--config=/path/to/your/config/file" option for reuse your config file. lets say server path is /usr/bin/openerp-server and config file is: /etc/openerp/openerp-server.conf, then you'll run it as "/usr/bin/openerp-server --config=/etc/openerp/openerp-server.conf" ( here you can use other options as well, including  --logfile=/var/log/openerp/openerp-server.log if you like) from terminal. Then in your python code you can

print "whatever" 

and you'll get whatever printed to the terminal.

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

Is this for versions 7 and 8 only? I'm using version 11; Had to use logging module, ```python print() ``` doesn't work.

Ảnh đại diện
Câu trả lời hay nhất

Print statements should appear in log, if not- maybe your print statement is after some error and does not get executed?

For OpenERP debugging tool and its usage, look at this question and answer

0
Ảnh đại diện
Huỷ bỏ
Anuradha
Tác giả

I dont have any error before print.i enabled debug mode by setting debug_mode = true in /etc/openerp/openerp-server.conf and checking log tail -f /var/log/openerp/openerp-server.log but still its not showing print

Ảnh đại diện
Rodney Pantonial
Câu trả lời hay nhất

I have solved remote debugging to my remote ubuntu server by doing the following:

On your remote server, run: pip install cython pydevd

IMPORTANT: Make sure that your computer is visible to server's IP by pinging your computer's IP

On your computer, configure a Python Remote Debug in run configurations.

Set Local Host Name: The IP of your computer. Yes, that computer with the pycharm installed.

Set the Port: 7999. Actually, any port will do as long as its above 1000.

Make sure to check the box, SINGLE INSTANCE ONLY

On File>Settings>Execution>Deployment, create an SFTP Server Connection.

Set the SFTP host to the server's IP. set the root path to the installation directory of your odoo server. In my case, its located at /opt/odoo

Set the username and password.

On the mappings tab,

Set the Local Path to your project's directory root

Set the deployment path to "\" or backslash.

Set the web path to "/" or forwardslash.

Test the SFTP connection.

On the server, open the file /opt/odoo/openerp-server (It's a python file without the extension)

Add these statements after the "import openerp"

import pydevd

pydevd.settrace('YOUR COMPUTER IP', port=7999, stdoutToServer=True,stderrToServer=True)

TODO EVERYTIME YOU MODIFY YOUR CODE AND DEBUG THATNow to start the debug, add a breakpoint in your code.

Run the remote debug to start listening from the server.

Restart the openerp instance you got running in your server. In my case, I force restart the init.d/odoo-server file:

/etc/init.d/odoo-server restart

If successful, pycharm will light up in the menu bar and ask you to set the path mappings. Just click the autodetect and press Save forever.

Notice that if you visit the odoo server website, it just won't load. Actually, pycharm sets a "virtual" breakpoint after the settrace command you have provided so you have to press the play button thing at the debug(or F8)

Viola! Now it works and any breakpoint you set will stop odoo from executing and let you analyze everything.

Test it by adding a breakpoint in your code and try to run that code. Try the @api.onchange ones since they are more predictable to run.

0
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Abegail Sanchez
Câu trả lời hay nhất

As mentioned above, eclipse will work. You can debug sql query also.

There you can see your cron running

SELECT * FROM ir_cron
                              WHERE numbercall != 0
                                  AND active AND nextcall <= (now() at time zone 'UTC')
                              ORDER BY priority None
SELECT 1 FROM ir_module_module WHERE name=%s AND latest_version=%s ('base', '7.0.1.3')
SELECT * FROM ir_cron
                              WHERE numbercall != 0
                                  AND active AND nextcall <= (now() at time zone 'UTC')
                              ORDER BY priority None
SELECT 1 FROM ir_module_module WHERE name=%s AND latest_version=%s ('base', '7.0.1.3')
SELECT * FROM ir_cron
                              WHERE numbercall != 0
                                  AND active AND nextcall <= (now() at time zone 'UTC')
                              ORDER BY priority None
SELECT 1 FROM ir_module_module WHERE name=%s AND latest_version=%s ('base', '7.0.1.3')
SELECT * FROM ir_cron
                              WHERE numbercall != 0
                                  AND active AND nextcall <= (now() at time zone 'UTC')
                              ORDER BY priority None
SELECT 1 FROM ir_module_module WHERE name=%s AND latest_version=%s ('base', '7.0.1.3')
SELECT * FROM ir_cron
                              WHERE numbercall != 0
                                  AND active AND nextcall <= (now() at time zone 'UTC')
                              ORDER BY priority None

0
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
eoin ahern
Câu trả lời hay nhất

doesnt seem to be a Lib/Queue.py file in python 2.7 ??

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

oh, actually i found it so it is there!! my mistake

Ảnh đại diện
Marvin Taboada
Câu trả lời hay nhất

Hello Anuradha,

I personally prefer to pass the command line argument "--log-level=debug", to the "openerp-server" script, in order to set the log level, instead of using the configuration file.

Several useful options can be passed as command line arguments as well, run "./openerp-server  --help", from the appropriate directory, in order to get the complete list of options and values it accepts if applicable, e.g.: available log levels.

The Python interpreter won't reload your code changes automatically, you will require to restart OpenERP after adding additional logging statements into your code.

I hope this helps.

0
Ảnh đại diện
Huỷ bỏ
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
debugging python code
debug python print
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 3 15
14355
Webhook. How can i send webhook by execute code?
debug
Ảnh đại diện
0
thg 11 25
5
Facing trouble with my appointment section
debug
Ảnh đại diện
0
thg 10 25
755
ValueError: Wrong value for ir.ui.view.type: 'tree'in Odoo18 Đã xử lý
debug
Ảnh đại diện
Ảnh đại diện
1
thg 9 25
1393
Custom Route splitting return transfers into two different returns.
debug
Ảnh đại diện
0
thg 8 25
1792
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة 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 là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

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