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

ondelete error/confusion in Odoo 14 repost

購読

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

この質問にフラグが付けられました
2644 ビュー
アバター
Ashley

My previous post got broken by adding hyperlinks, here's a hopefully amended version.

Hi alI!

I haven't used this forum before so bear with me if I make any noob mistakes or I seem a bit dense. I'm very new to Odoo, been using it for about a week in an attempt to migrate a clients' database over to it. This has obviously presented quite a steep learning curve but so far I've been more or less able to figure things out as I go along. Or so I thought. Some context: I've been tasked with figuring out some functionality to allow staff in a shop to tare the scale using POS. Obviously, being completely new to this I thought I'd look on the module store. I ended up finding a module called "pos_tare" that's maintained by OCA. The only issue with the module is that it's only updated to Odoo 12. Being naive and completely new to Odoo, I tried to add this module to the SaaS instance of the project that my colleague had been working on for a number of days. There'll be backups, right? Of course, no backups, so uploading the outdated module to the online version of Odoo obviously broke the database.

On my local server running a restored version of the broken database and on SaaS, I get this error message upon trying to access the POS configuration screen.

 
Odoo Server Error
Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch result = request.dispatch() File "/usr/lib/python3/dist-packages/odoo/http.py", line 683, in dispatch result = self._call_function(**self.params) File "/usr/lib/python3/dist-packages/odoo/http.py", line 359, in _call_function return checked_call(self.db, *args, **kwargs) File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper return f(dbname, *args, **kwargs) File "/usr/lib/python3/dist-packages/odoo/http.py", line 347, in checked_call result = self.endpoint(*a, **kw) File "/usr/lib/python3/dist-packages/odoo/http.py", line 912, in __call__ return self.method(*args, **kw) File "/usr/lib/python3/dist-packages/odoo/http.py", line 531, in response_wrap response = f(*args, **kw) File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1389, in call_kw return self._call_kw(model, method, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1381, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/api.py", line 396, in call_kw result = _call_kw_multi(method, model, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/api.py", line 383, in _call_kw_multi result = method(recs, *args, **kwargs) File "/usr/lib/python3/dist-packages/odoo/models.py", line 3009, in read raise ValueError("Invalid field %r on model %r" % (name, self._name)) Exception The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/http.py", line 639, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python3/dist-packages/odoo/http.py", line 315, in _handle_exception raise exception.with_traceback(None) from new_cause ValueError: Invalid field 'iface_tare_method' on model 'pos.config' 

This obviously points to the fact that the module hasn't installed properly from the web version, but the error message is the same after retrying installation locally. It's also the same if I try to import the module from a database with just the dependencies installed. My first question is, is there any way I can recover the data I already have on here from the database, just excluding (what I assume to be) the bad pos.config model? Or just the parts of the database that have been affected by the module. Quite a lot of work has already gone into the website and importing stock lists and I'll be in a spot of hot water if I'm unable to recover the data. I tried adding the field manually into pos.config using pgAdmin but that proved to be well beyond my understanding.

I came to the potentially erroneous conclusion that I could simply update the module and install it in the broken database and my woes would be remedied. I decided to try my hand at updating this module using OCA's guides on updating modules from Odoo \12\ to\ 13\\ and\ then\ \13 to 14. This was essentially all going well, until I got to adding ondelete parameters to the selection fields in some of the config functionality. Before adding these parameters, Odoo threw this error on module installation:

Error:
Odoo Server Error

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/usr/lib/python3/dist-packages/odoo/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 347, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 912, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 531, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1393, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1381, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 396, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 383, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-71>", line 2, in button_immediate_install
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 73, in check_and_log
return method(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 474, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 592, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 455, in load_modules
loaded_modules, update_module, models_to_check)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 348, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 197, in load_module_graph
registry.setup_models(cr)
File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 273, in setup_models
model._setup_base()
File "/usr/lib/python3/dist-packages/odoo/models.py", line 2791, in _setup_base
self._add_field(name, field.new())
File "/usr/lib/python3/dist-packages/odoo/models.py", line 404, in _add_field
field.setup_base(self, name)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 278, in setup_base
self._setup_attrs(model, name)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 2328, in _setup_attrs
"containing the specified option." % self
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
ValueError: barcode.rule.type: required selection fields must define an ondelete policy that implements the proper cleanup of the corresponding records upon module uninstallation. Please use one or more of the following policies: 'set default' (if the field has a default defined), 'cascade', or a single-argument callable where the argument is the recordset containing the specified option.

This error is identical when installing on to the broken database or a blank database with the dependent modules. This break is obviously due to the selection field in barcode_rule.py being incorrect since Odoo 14 made ondelete a requirement for selection fields. Here's the code in barcode_rule.py:

from odoo import models, fields


class BarcodeRule(models.Model):
_inherit = 'barcode.rule'

type = fields.Selection(selection_add=[
('tare', 'Tare')
])

And now OCA's guideline for ondelete syntax:

"If you add new values in a selection field through selection_add, you have to define a new ondelete= attribute setting the value to assign for each previous value in case of uninstallation. More info at [github link breaks my post] Example: selection_field = fields.Selection(selection_add=[("foo", "Foo")], ondelete={"foo": "set null"})."

Finally Odoo docs example:\

Since Odoo 14.0 you have to specify ondelete
attribute.ondelete provides a fallback mechanism for any overridden field with a selection_add. It is a dict that maps every option from the selection_add to a fallback action. This fallback action will be applied to all records whose selection_add option maps to it. The actions can be any of the following:•'set null'– the default, all records with this option will have their selection value set to False.•'cascade'– all records with this option will be deleted along with the option itself.•'set default'– all records with this option will be set to the default of the field definition•<callable>– a callable whose first and only argument will be the set of records containing the specified Selection option, for custom processing. e.g.:my_selection = fields.Selection(selection_add=[('bacon', "Bacon"),], ondelete={'bacon':lambda records: record.write({'my_selection': 'bar'})})

My programming knowledge is, admittedly, fairly limited. I have no idea how to implement Odoo's explanation of the ondelete rule. However, when editing the code in barcode_rule.py to account for the OCA explanation, which I interpreted as:

from odoo import models, fields


class BarcodeRule(models.Model):
_inherit = 'barcode.rule'

type = fields.Selection(selection_add=[
("tare", "Tare")],
ondelete={"tare": "cascade"})

Apologies for the ugly code, I reformatted it to look just like the documentation example in case I was making a typing error. What confounds me now, and what has led me to seek out help, is that this completely breaks any database it's loaded on. I have to drop the database from pgAdmin,  The whole page goes white and outputs this error message:

Error:


Traceback:
Error: QWeb2: Can't clone undefined template PosTicket
exception@http://localhost:8069/web/content/510-9d5c618/web.assets_common.js:4394:7
add_template@http://localhost:8069/web/content/510-9d5c618/web.assets_common.js:4411:361
load_qweb/lock</<@http://localhost:8069/web/content/510-9d5c618/web.assets_common.js:4861:6
mightThrow@http://localhost:8069/web/content/510-9d5c618/web.assets_common.js:1616:18
resolve/</process<@http://localhost:8069/web/content/510-9d5c618/web.assets_common.js:1618:89

Googling this has not yielded any results, and so I'm completely stuck at the moment. My questions are: have I formatted ondelete correctly? If not, how do I format it? And if I haven't, what is up with this really strange error message? My theory at the moment is that Odoo crashes for some mercurial reason when it finds one fixed piece of the module but encounters another piece that is broken in the same way. Either that or the module is more broken than I thought. Odoo ostensibly interprets the ondelete successfully and then gets stuck on another, more difficult, error. I find this unlikely though, because there are other selection_fields that are broken in the same way.

I'm running Odoo 14.0+e-20210512 on a Debian server hosted locally, although this affects both my Debian and Windows servers.

This became somewhat of a novel! I really appreciate any and all help I can get on this, I've tried to provide as much info as possible with this. If I've missed anything I'll be more than willing to provide more. Of course if I've made any errors or this isn't the place to post this then I'll happily accept a point in the right direction.

Thanks again!
0
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

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

登録
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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