第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么“瀏覽”方法使用不存在的 id 返回錯(cuò)誤的記錄集?

為什么“瀏覽”方法使用不存在的 id 返回錯(cuò)誤的記錄集?

當(dāng)我使用該search方法并創(chuàng)建一個(gè)查找不存在的 id 的記錄集時(shí),結(jié)果是預(yù)期的空記錄集:>>> self.env['account.invoice'].search([('id', 'in', [23232323123123123, ])])account.invoice()但是如果我對(duì)browse方法做同樣的事情,結(jié)果是一個(gè)具有該 id 的記錄集,但實(shí)際上該記錄不存在:>>> o = self.env['account.invoice'].browse([23232323123123123])>>> oaccount.invoice(23232323123123123,)>>> o.id23232323123123123>>> o.numberTraceback (most recent call last):File "/path/to/odoo/odoo/fields.py", line 937, in __get__    value = record.env.cache.get(record, self)File "/path/to/odoo/odoo/api.py", line 960, in get    value = self._data[field][record.id][key]KeyError: (<odoo.sql_db.Cursor object at 0x7f4d2985e9e8>, 1)During handling of the above exception, another exception occurred:Traceback (most recent call last):File "/usr/lib/python3.5/code.py", line 91, in runcode    exec(code, self.locals)File "<console>", line 1, in <module>File "/path/to/odoo/odoo/fields.py", line 937, in __get__    value = record.env.cache.get(record, self)File "/path/to/odoo/odoo/api.py", line 961, in get    return value.get() if isinstance(value, SpecialValue) else valueFile "/path/to/odoo/odoo/api.py", line 993, in getter    raise exceptionFile "/usr/lib/python3.5/code.py", line 91, in runcode    exec(code, self.locals)File "<console>", line 1, in <module>File "/path/to/odoo/odoo/fields.py", line 937, in __get__    value = record.env.cache.get(record, self)File "/path/to/odoo/odoo/api.py", line 961, in get    return value.get() if isinstance(value, SpecialValue) else valueFile "/path/to/odoo/odoo/api.py", line 993, in getter    raise exceptionFile "/usr/lib/python3.5/code.py", line 91, in runcode    exec(code, self.locals)這是文檔中的解釋?zhuān)韩@取數(shù)據(jù)庫(kù) ID 或 ID 列表并返回記錄集,當(dāng)從 Odoo 外部獲取記錄 ID(例如通過(guò)外部系統(tǒng)往返)或調(diào)用舊 API 中的方法時(shí)很有用這是正常行為嗎?我覺(jué)得這種方法沒(méi)用我是否必須browse事先檢查數(shù)據(jù)庫(kù)中是否存在a中使用的所有記錄?
查看完整描述

1 回答

?
慕婉清6462132

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超2個(gè)贊

是的,這是正常行為。檢查眉毛方法。此行已注釋

assert all(isinstance(id, IdType) for id in ids), "Browsing invalid ids: %s" % ids

但是你有方法存在

exists() 返回一個(gè)新的記錄集,只包含數(shù)據(jù)庫(kù)中存在的記錄??捎糜跈z查記錄(例如從外部獲得)是否仍然存在:


查看完整回答
反對(duì) 回復(fù) 2021-09-25
  • 1 回答
  • 0 關(guān)注
  • 247 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)