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

Odoo JSON Filter and Offset Parameter

購読

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

この質問にフラグが付けられました
jsonpython3jsonrpc
5 返信
11031 ビュー
アバター
shirsendudas.2011@gmail.com
i am developing a json rpc based attendance system. so fer i got this below code working as planned except one thing, when searching for last attendance entry id i'm getting full list of ids associated with the related user, this is how search function works, but i want only the last entry id, i thing this can be achieve by using FILTER and OFFSET (maybe), which i'm unable include in my code. can anybody look at this python code and guide me. getting the full list is not an option for me, as i will use arduino later, so memory is limited. and i wanna know how to include this parameters.
import json
import random
import urllib.request
import datetime
import sys

CODE = sys.argv[1] HOST = 'localhost' PORT = 8069 DB = 'ezp' USER = 'root' PASS = 'toor' url = "http://%s:%s/jsonrpc" % (HOST, PORT) date_time = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
def call(url, service, method, *args): id = random.randint(0, 1000000000) data = {"jsonrpc": "2.0", "params": {"args": args, "method": method,"service":service,}, "id": id, "method": "call",} req = urllib.request.Request(url=url, data=json.dumps(data).encode(), headers={"Content-Type":"application/json",}) reply = json.loads(urllib.request.urlopen(req).read().decode('UTF-8')) if reply.get("error"): raise Exception(reply["error"]) return reply temp = call(url, "common", "login", DB, USER, PASS) uid = temp["result"] print('Login ID: ' + str(uid))
temp = call(url, "object", "execute", DB, uid, PASS, 'hr.employee', 'search', [['barcode', '=', CODE]]) eid = str(temp["result"])[1:-1] if(eid == ''):   print('Employee not exists')   exit()
temp = call(url, "object", "execute", DB, uid, PASS, 'hr.employee', 'read', int(eid), ['name']) for x in temp["result"]: e_name = x['name'] print('Employee Name: ' +str(e_name))
# below rpc list all the attendance ids associated with this user temp = call(url, "object", "execute", DB, uid, PASS, 'hr.attendance', 'search', [['employee_id','=', int(eid)]]) # how can i insart FILTER PARAMETER so thet only the last entry id returns instead of full list?????? attn = temp["result"]
print('All attendances: ' + str(attn))
def fn_check_in(): attn_record = {'employee_id': eid, 'check_in': date_time} result = call(url, "object", "execute", DB, uid, PASS, 'hr.attendance', 'create', attn_record) print('Checked In : ' + str(e_name), ' At: ' + date_time)
def fn_check_out(id): attn_record = {'check_out': date_time} result = call(url, "object", "execute", DB, uid, PASS, 'hr.attendance', 'write', int(id), attn_record) print('Checked Out : ' + str(e_name), ' At: ' + date_time)
def attendance(): if(len(attn) == 0): fn_check_in() else: last_id = attn[0] for i in range(0, len(attn)): if(attn[i] > last_id): last_id = attn[i] print('Last Entry ID: ' + str(last_id)) is_out = call(url, "object", "execute", DB, uid, PASS, 'hr.attendance', 'read', int(last_id), ['check_out']) if('False' in str(is_out)): fn_check_out(last_id) else: fn_check_in() attendance()
0
アバター
破棄
shirsendudas.2011@gmail.com
著作者

Mihran Thalhath i tried your solution and got this server error message

Exception: {'code': 200, 'message': 'Odoo Server Error', 'data': {'name': 'builtins.ValueError', 'debug': 'Traceback (most recent call last):\n File "/odoo/odoo-server/odoo/http.py", line 619, in _handle_exception\n return super(JsonRequest, self)._handle_exception(exception)\n File "/odoo/odoo-server/odoo/http.py", line 309, in _handle_exception\n raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])\n File "/odoo/odoo-server/odoo/tools/pycompat.py", line 14, in reraise\n raise value\n File "/odoo/odoo-server/odoo/http.py", line 664, in dispatch\n result = self._call_function(**self.params)\n File "/odoo/odoo-server/odoo/http.py", line 345, in _call_function\n return checked_call(self.db, *args, **kwargs)\n File "/odoo/odoo-server/odoo/service/model.py", line 93, in wrapper\n return f(dbname, *args, **kwargs)\n File "/odoo/odoo-server/odoo/http.py", line 338, in checked_call\n result = self.endpoint(*a, **kw)\n File "/odoo/odoo-server/odoo/http.py", line 909, in __call__\n return self.method(*args, **kw)\n File "/odoo/odoo-server/odoo/http.py", line 510, in response_wrap\n response = f(*args, **kw)\n File "/odoo/odoo-server/odoo/addons/base/controllers/rpc.py", line 71, in jsonrpc\n return dispatch_rpc(service, method, args)\n File "/odoo/odoo-server/odoo/http.py", line 138, in dispatch_rpc\n result = dispatch(method, params)\n File "/odoo/odoo-server/odoo/service/model.py", line 40, in dispatch\n res = fn(db, uid, *params)\n File "/odoo/odoo-server/odoo/service/model.py", line 93, in wrapper\n return f(dbname, *args, **kwargs)\n File "/odoo/odoo-server/odoo/service/model.py", line 175, in execute\n res = execute_cr(cr, uid, obj, method, *args, **kw)\n File "/odoo/odoo-server/odoo/service/model.py", line 164, in execute_cr\n return odoo.api.call_kw(recs, method, args, kw)\n File "/odoo/odoo-server/odoo/api.py", line 391, in call_kw\n result = _call_kw_model(method, model, args, kwargs)\n File "/odoo/odoo-server/odoo/api.py", line 364, in _call_kw_model\n result = method(recs, *args, **kwargs)\n File "/odoo/odoo-server/odoo/models.py", line 4825, in search_read\n result = records.read(fields)\n File "/odoo/odoo-server/odoo/models.py", line 2879, in read\n raise ValueError("Invalid field %r on model %r" % (name, self._name))\nValueError: Invalid field \'order\' on model \'hr.attendance\'\n', 'message': "Invalid field 'order' on model 'hr.attendance'", 'arguments': ["Invalid field 'order' on model 'hr.attendance'"], 'exception_type': 'internal_error'}}

is there any documentation or guide of proper odoo json structure for "read", "search", "edit", "write" all this operation. along with sort limit offset. i tried finding but got only one example of creating 'note'.

Mihran Thalhath

@shirsendudas.2011@gmail.com

You can check the official web services documentation of Odoo for more details. https://www.odoo.com/documentation/12.0/webservices/odoo.html

アバター
Mihran Thalhath
最善の回答

Hi,


You can try to use the search_read() method to sort the records by check-in or check-out date in descending order and then apply limit as '1' which will only retrieve the last record. I guess the below code fragment should work. Try and revert back    :)


temp = call(url, "object", "execute", DB, uid, PASS, 'hr.attendance', 'search_read', [['employee_id','=', int(eid)]], {'order': 'check_out desc', 'limit': 1})
1
アバター
破棄
アバター
Hilar Andikkadavath
最善の回答

Try to pass an argument for sorting according to id descending and limit to one record. This gives you the last record from db.

{'order': 'id desc', 'limit': 1}
0
アバター
破棄
アバター
shirsendudas.2011@gmail.com
著作者 最善の回答

Solved the issue using "execute_kw" instead "execute" 

call(url, "object", "execute_kw", DB, uid, PASS, 'hr.attendance', 'search', [[['employee_id','=', int(eid)]]],{'limit':1,'order': 'id desc'})
0
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

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

登録
関連投稿 返信 ビュー 活動
How to return a simple json instead object JsonRpc? (Odoo11)
json jsonrpc odoo11
アバター
アバター
1
9月 20
7245
JSON-RPC - define request parameters like limit or fields 解決済
json rpc jsonrpc
アバター
アバター
アバター
6
7月 20
13061
Return reponse as standard json
json jsonrpc odoo12
アバター
1
3月 20
4188
Selecting a specific db for a json request
json request jsonrpc
アバター
0
3月 17
5346
JSON-RPC dont use context (return datetime gmt and lang per default)
json mobile jsonrpc
アバター
アバター
1
6月 16
8451
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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