コンテンツへスキップ
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
このフォーラムについて
ヘルプ

NameError: name 'o' is not defined

購読

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

この質問にフラグが付けられました
pythonrmlopenerp7
3 返信
13240 ビュー
アバター
Rihene

I have this function in my python file:


    def get_employee_lines(self, cr, uid, ids, company_id, date_start, date_end):
print ('--------------------MOMO----------------------')
payslip_line = self.pool.get('hr.payslip')
print payslip_line
print company_id
print date_start
print date_end
obj_ids = payslip_line.search(cr, uid,ids, [ ('date_from', '=', date_start), ('date_to', '=', date_end)])
res = obj.read( obj_ids, ['employee_id'], context)
print res['employee_id']
return res


And, i have called it in my RML:

[[ repeatIn (get_employee_lines ( example.company_id, example.date_start, example.date_end), 'o') ]] 

And in front of the cell:

[[ o.employee_id]]

But, i have gotten this error:


2015-08-26 09:23:22,979 4118 ERROR company openerp.tools.safe_eval: Cannot eval "repeatIn (get_employee_lines ( example.company_id, example.date_start, example.date_end), 'o')"
Traceback (most recent call last):
File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval
return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
File "", line 1, in <module>
TypeError: get_employee_lines() takes exactly 7 arguments (4 given)
2015-08-26 09:23:22,980 4118 ERROR company openerp.tools.safe_eval: Cannot eval 'o.employee_id'
Traceback (most recent call last):
File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval
return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
File "", line 1, in <module>
NameError: name 'o' is not defined

Any tips?



0
アバター
破棄
Rihene
著作者

Buy why!!!!! Really i need an answer why dont you help me instead of this

アバター
Pawan
最善の回答

Drees,

try this:
1) take a list, res_list=[] in you py file

2) After "res = obj.read( obj_ids, ['employee_id'], context)", add,

         'res_list.append(res)'

3) and then replace [return res], with  [return res_list]

3) in your rml, replace "o.employee_id" wih "o['employee_id']"

Hope it helps....

2
アバター
破棄
アバター
Rihene
著作者 最善の回答

 Thanks a lot to Pawan :)

Here is the answer friends!!

Python:


def get_employee_lines(self, company_id, date_start, date_end, context=None):

print ('--------------------MOMO----------------------')

res_list=[]

payslip_line = self.pool.get('hr.payslip')

print payslip_line

print company_id

print date_start

print date_end

obj_ids = payslip_line.search(self.cr, self.uid, [ ('date_from', '=', date_start), ('date_to', '=', date_end)])

print obj_ids

for res in payslip_line.read(self.cr, self.uid, obj_ids, ['id', 'employee_id'], context=False):

res_list.append(res['employee_id'][1])

return res_list

RML:

[[ repeatIn (get_employee_lines ( example.company_id, example.date_start, example.date_end), 'o') ]]

[[ o['employee_id'] ]]

Regards.




0
アバター
破棄
Pawan

Drees,
In,
, 2015-08-26 10:28:44,730 5779 ERROR company openerp.tools.safe_eval: Cannot eval "repeatIn (get_employee_lines ( example.company_id, example.date_start, example.date_end, 'o') )"
you have wrongly called the function, it should be like:
"repeatIn (get_employee_lines( example.company_id, example.date_start, example.date_end), 'o' )
[NOTE: 'o' should be out of the function brackets...]

Rihene
著作者

Pawan please need your help: I have corrected it again and i have gotton the same error

Pawan

Please update your error.... Drees

Rihene
著作者

I have updated it after modifying all what you said

Rihene
著作者

Python: def get_employee_lines(self, cr, uid, ids, company_id, date_start, date_end): print ('--------------------MOMO----------------------') res_list=[ payslip_line = self.pool.get('hr.payslip') print payslip_line print company_id print date_start print date_end obj_ids = payslip_line.search(cr, uid,ids, [ ('date_from', '=', date_start), ('date_to', '=', date_end)]) res = obj.read( obj_ids, ['employee_id'], context) res_list.append(res) return res_list

Pawan

Ok dress, update your py function defination with:
"def get_employee_lines(self, company_id, date_start, date_end):"
and remove space in "o ['employee_id']"...

Rihene
著作者

Here is a link to the rml: http://www.zupimages.net/viewer.php?id=15/35/31mj.png

Rihene
著作者

Pawan when i have eliminated cr, uid, and ids i got this: 2015-08-26 10:59:40,994 8469 INFO company werkzeug: 127.0.0.1 - - [26/Aug/2015 10:59:40] "POST /web/action/load HTTP/1.1" 200 - ----------------------test-------------------------- --------------------MOMO---------------------- browse_record(res.company, 1) 01/08/2015 31/08/2015 2015-08-26 10:59:41,305 8469 ERROR company openerp.tools.safe_eval: Cannot eval "repeatIn (get_employee_lines ( example.company_id, example.date_start, example.date_end), 'o')" Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in File "/opt/openerp/v7/addons/seetek_example/report/journal_paie.py", line 46, in get_employee_lines obj_ids = payslip_line.search(cr, id, ids, [ ('date_from', '=', date_start), ('date_to', '=', date_end)]) NameError: global name 'cr' is not defined 2015-08-26 10:59:41,306 8469 ERROR company openerp.tools.safe_eval: Cannot eval "o['employee_id']" Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in NameError: name 'o' is not defined

Pawan

Dress, in py now everywhere in place of cr and uid, you have to use self.cr, self.uid...........

Pawan

and in search(), we don't need "ids" anyway...

Rihene
著作者
browse_record(res.company, 1) 01/08/2015 31/08/2015 2015-08-26 11:05:17,811 8574 ERROR company openerp.tools.safe_eval: Cannot eval "repeatIn (get_employee_lines ( example.company_id, example.date_start, example.date_end), 'o')" Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in File "/opt/openerp/v7/addons/seetek_example/report/journal_paie.py", line 46, in get_employee_lines obj_ids = payslip_line.search(self.cr, self.uid, self.ids, [ ('date_from', '=', date_start), ('date_to', '=', date_end)]) File "/opt/openerp/v7/server/openerp/osv/orm.py", line 2372, in search return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count) File "/opt/openerp/v7/server/openerp/osv/orm.py", line 4935, in _search query = self._where_calc(cr, user, args, context=context) File "/opt/openerp/v7/server/openerp/osv/orm.py", line 4761, in _where_calc e = expression.expression(cr, user, domain, self, context) File "/opt/openerp/v7/server/openerp/osv/expression.py", line 646, in __init__ self.parse(cr, uid, context=context) File "/opt/openerp/v7/server/openerp/osv/expression.py", line 746, in parse self.stack = [ExtendedLeaf(leaf, self.root_model) for leaf in self.expression] File "/opt/openerp/v7/server/openerp/osv/expression.py", line 532, in __init__ self.check_leaf() File "/opt/openerp/v7/server/openerp/osv/expression.py", line 588, in check_leaf raise ValueError("Invalid leaf %s" % str(self.leaf)) ValueError: Invalid leaf 5 2015-08-26 11:05:17,880 8574 ERROR company openerp.tools.safe_eval: Cannot eval "o['employee_id']" Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in NameError: name 'o' is not defined
Pawan

Drees, NO "ids" should be passed to search() method, it doesn't accept ids nor self.ids...

Rihene
著作者
browse_record(res.company, 1) 01/08/2015 31/08/2015 2015-08-26 11:18:02,951 9606 ERROR company openerp.tools.safe_eval: Cannot eval "repeatIn (get_employee_lines ( example.company_id, example.date_start, example.date_end), 'o')" Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in File "/opt/openerp/v7/addons/seetek_example/report/journal_paie.py", line 47, in get_employee_lines res = payslip_line.read( obj_ids, ['employee_id'], context=False) TypeError: read() takes at least 4 arguments (4 given) 2015-08-26 11:18:02,953 9606 ERROR company openerp.tools.safe_eval: Cannot eval "o['employee_id']" Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in NameError: name 'o' is not defined
Rihene
著作者

Pawan please you still there??

Pawan

please replace your "payslip_line.read( obj_ids, ['employee_id'], context=False)" with:
for res in payslip_line.read(self.cr, self.uid, obj_ids, ['id', 'employee_id'], context=False):
res_list.append(res)
remove res_list.append() which you added earlier
This loop is added because you may have more than one id returned from search method.
and cause of error was , you didn't passed self.cr and self.uid.

Rihene
著作者

Pawan, it works but i got this in the terminal: browse_record(res.company, 1) 01/08/2015 31/08/2015 [1] 2015-08-26 11:31:05,767 10372 ERROR company openerp.tools.safe_eval: Cannot eval "o['employee_id']" Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in NameError: name 'o' is not defined and in the report: [{'o': {'employee_id': (2, u'Abdelwahed Rihene'), 'id': 1}}] but i need only Abdelwahed Rihene

Rihene
著作者

Pawan i get this : [{'o': u'Abdelwahed Rihene'}] !!! how can i change it to this: Abdelwahed Rihene please

Pawan

use this 'o' key to get this value, as a dictionary...

Rihene
著作者

Pawan my friend you still here??

Rihene
著作者

Please pawan my friend i need your help extremely: In my field employee_id i have this result: [{'o': u'Abdelwahed Rihene'}, {'o': u'Amine Msakni'}] wben i want to get ABdelwahed Rihene in a cell and amine msakni in an other cell please friend how can i get the name in that json and how can i create automatically a new td please please help me

Pawan

Drees, you can try by keeping,
o['employee_id'][0]['o'] in one cell and
o['employee_id'][1]['o'] in nother one...

Rihene
著作者

Pawan please it doesnt work nothing had changed

Pawan

Drees, can u pls show what you are getting in return statement from python function.?

Rihene
著作者

Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in NameError: name 's' is not defined

Rihene
著作者

sorry i have changed the o to s

Pawan

i m not getting you, can u pls show me res_list values...

Rihene
著作者

here is my function pawan: def get_employee_lines(self, company_id, date_start, date_end, context=None): print ('--------------------MOMO----------------------') res_list=[] payslip_line = self.pool.get('hr.payslip') print payslip_line print company_id print date_start print date_end obj_ids = payslip_line.search(self.cr, self.uid, [ ('date_from', '=', date_start), ('date_to', '=', date_end)]) print obj_ids for res in payslip_line.read(self.cr, self.uid, obj_ids, ['id', 'employee_id'], context=False): print res['employee_id'][1] res_list.append(res['employee_id'][1]) return res_list

Pawan

can u print res_list before return and show your result here....

Rihene
著作者

[u'Abdelwahed Rihene', u'Amine Msakni']

Pawan

then in rml, instead of putting, o['employee_id'], try putting [[ o ]] only .

Rihene
著作者

It doesnt work pawan :/

Pawan

ok, do this,
at py replace "res_list.append(res['employee_id'][1])", with :
res['employee_id'] = res['employee_id][1], and then
res_list.append(res), under loop only
and at rml, keep: [[ o['employee_id'] ]]

Rihene
著作者

I have gotten this: [{'s': {'employee_id': (2, u'Abdelwahed Rihene'), 'id': 1}}, {'s': {'employee_id': (3, u'Amine Msakni'), 'id': 3}}]. What i didnt understand is why it is adding [{'s'...

Pawan

its because, the list n from python function, is again been moulded by rml template parser, and uses its 'o', 's', to refer the data now, ... so every record turns into a dictionary with key selected in repeatIn ...
anyway did u kept: res['employee_id'] = res['employee_id][1], before "res_list.append(res)"
if not please keep it....
n in rml... [[ o['employee_id'] ]] if not work.... then [[ o['o']['employee_id'] ]],
where o/s is your variable in repeatln.....

Rihene
著作者

Am doing all things that you have told me friend :/

Rihene
著作者

It is telling me that 2015-08-27 12:29:21,380 13947 ERROR company openerp.tools.safe_eval: Cannot eval "o['o']['employee_id']" NameError: name 'o' is not defined

Pawan

u have to replace 'o' with variable u took in "repeatln", :
repeatIn (get_employee_lines ( example.company_id, example.date_start, example.date_end), 'o'),
hope its clear....
please print res_list value and show the same here,
and also what you are getting by just keeping [[ o['employee_id'] ]] in rml file....

Rihene
著作者

2015-08-27 13:11:36,231 16322 ERROR company openerp.tools.safe_eval: Cannot eval "o['employee_id']" Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/tools/safe_eval.py", line 285, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in NameError: name 'o' is not defined

Rihene
著作者

res_list : Abdelwahed Rihene Amine Msakni

Pawan

Drees, did you kept "res_list.append(res['employee_id'])",
if yes then pleaseeee change it to "res_list.append(res)" after "res['employee_id'] = res['employee_id]"
i have mentioned this is above comments also.... please refer them....

Rihene
著作者

I have kept everything as you told mme but i have the same error: NameError: name 'o' is not defined

Pawan

hehe....it seeming we are making small thing complicated .... can u please update ur latest codes..... py n rml..

Rihene
著作者

Pawan i think that my openerp addons are making this wrong :/

Rihene
著作者

hey pawan my friend u still there. please can you help me my friend i want to create a new cell to every new record please

Pawan

Drees, if you are still looking for help, then please can u post your requirement and wat have you done till now in detail.... and is previous one sorted?

Rihene
著作者

Pawan my fried i have asked a new question.here is the link: https://www.odoo.com/forum/help-1/question/how-to-make-each-result-in-a-cell-90226

Rihene
著作者

Pawan are here please ?? need your help

ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

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

登録
関連投稿 返信 ビュー 活動
Spliting rml intotwo halves
rml openerp7
アバター
0
4月 18
3371
How to add condation in rml
rml openerp7
アバター
0
2月 18
4425
How to send email in openerp by python code 解決済
python openerp7
アバター
アバター
アバター
アバター
アバター
4
10月 16
32053
How to divide a data into x caracters to be displayed in a field?
python openerp7
アバター
アバター
1
9月 15
4654
How to realise a page break or specify number of columns in rml for openerp 解決済
rml openerp7
アバター
1
9月 15
4500
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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