コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

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

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

How to Debug python code in open erp

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
debugprint
16 返信
73726 ビュー
アバター
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
アバター
破棄
アバター
Thierry Godin
最善の回答

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
アバター
破棄
Anuradha
著作者

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
著作者
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
アバター
Serpent Consulting Services Pvt. Ltd.
最善の回答

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
アバター
破棄
アバター
Leonardo Donelli
最善の回答

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
アバター
破棄
Pascal Tremblay

Thanks I like it!

アバター
Oleg Orlov
最善の回答

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
アバター
破棄
アバター
Alejandro Perez Cosio
最善の回答

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
アバター
破棄
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'

アバター
Temur
最善の回答

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
アバター
破棄
Yulybaseball

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

アバター
最善の回答

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
アバター
破棄
Anuradha
著作者

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

アバター
Rodney Pantonial
最善の回答

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
アバター
破棄
アバター
Abegail Sanchez
最善の回答

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
アバター
破棄
アバター
eoin ahern
最善の回答

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

0
アバター
破棄
eoin ahern

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

アバター
Marvin Taboada
最善の回答

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
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
debugging python code
debug python print
アバター
アバター
アバター
2
3月 15
14341
Webhook. How can i send webhook by execute code?
debug
アバター
0
11月 25
5
Facing trouble with my appointment section
debug
アバター
0
10月 25
735
ValueError: Wrong value for ir.ui.view.type: 'tree'in Odoo18 解決済
debug
アバター
アバター
1
9月 25
1369
Custom Route splitting return transfers into two different returns.
debug
アバター
0
8月 25
1783
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة 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(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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