跳至內容
Odoo 選單
  • 登入
  • 免費試用
  • 應用程式
    財政
    • 會計
    • 發票
    • 開支報銷
    • 試算表 (BI)
    • 文件管理
    • 電子簽名
    銷售
    • 客戶關係
    • 銷售
    • POS 銷售點管理 - 零售
    • POS 銷售點管理 - 餐廳
    • 訂閱
    • 租賃
    網站
    • 網站製作
    • 電子商務
    • 網誌
    • 討論區
    • 線上客服
    • 網上學習
    供應鏈
    • 庫存
    • 製造管理
    • 產品生命周期
    • 採購
    • 保養維護
    • 品質管理
    人力資源
    • 員工管理
    • 招聘
    • 休假
    • 工作表現評核
    • 內部推薦
    • 車隊管理
    市場推廣
    • 社交媒體推廣
    • 電郵推廣
    • 短訊營銷
    • 活動
    • 自動化推廣
    • 網上調查
    服務
    • 專案管理
    • 工時管理
    • 外勤服務管理
    • 技術支援
    • 工作規劃
    • 預約管理
    生產力
    • 聊天
    • 批核
    • 物聯網
    • VoIP
    • 知識庫
    • WhatsApp
    第三方應用程式 Odoo Studio Odoo 雲端平台
  • 行業
    零售
    • 書店
    • 服裝店
    • 家具店
    • 食品雜貨店
    • 五金店
    • 玩具店
    餐飲及款待
    • 酒吧及酒館
    • 餐廳
    • 快餐
    • 賓館
    • 飲品分銷商
    • 酒店
    房地產
    • 地產代理公司
    • 建築師事務所
    • 建造業
    • 物業管理
    • 園藝
    • 業主聯會
    顧問服務
    • 會計公司
    • Odoo 合作夥伴
    • 市場推廣公司
    • 律師事務所
    • 人才招募
    • 審計及認證
    製造管理
    • 紡織
    • 金屬
    • 家具
    • 食品
    • 啤酒廠
    • 企業禮品
    保健與健身
    • 運動俱樂部
    • 眼鏡店
    • 健身中心
    • 健康從業人員
    • 藥房
    • 髮型屋
    技術行業
    • 雜工
    • IT 硬體與支援
    • 太陽能系統
    • 鞋匠
    • 清潔服務
    • 暖通空調服務
    其他
    • 非牟利組織
    • 環境保護機構
    • 廣告板租賃
    • 攝影服務
    • 自行車租賃
    • 軟體經銷商
    瀏覽所有行業
  • 社群
    學習
    • 教學影片
    • 使用說明
    • 認證
    • 培訓
    • 網誌
    • Podcast
    增強教學效能
    • 教育計劃
    • 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:

  • 客戶關係
  • e-Commerce
  • 會計
  • 庫存
  • PoS
  • 專案管理
  • MRP
All apps
只限註冊用戶才可與社群互動。
所有帖文 人 獎章
標籤 (查看所有)
odoo accounting v14 pos v15
關於此討論區
只限註冊用戶才可與社群互動。
所有帖文 人 獎章
標籤 (查看所有)
odoo accounting v14 pos v15
關於此討論區
支援

ondelete error/confusion in Odoo 14 repost

訂閱

此帖文有活動時,接收通知

此問題已被標幟
2623 瀏覽次數
頭像
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 網頁寄存
  • 支援
  • 升級
  • 自訂功能開發
  • 教育及培訓
  • 尋找會計服務
  • 尋找合作夥伴
  • 成為合作夥伴
關於我們
  • 關於 Odoo 公司
  • 品牌資產
  • 聯絡我們
  • 招聘
  • 活動
  • Podcast
  • 網誌
  • 客戶
  • 法律 • 私隱政策
  • 安全性
الْعَرَبيّة 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)、電子商務、會計、庫存管理、POS(銷售點管理)、專案管理等應用程式。

Odoo 的獨特價值是非常簡單易用,同時將不同應用程式完美整合。

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