跳至内容
Odoo 菜单
  • 登录
  • 免费试用
  • 应用程序
    财务
    • 会计
    • 发票
    • 费用
    • 电子表格 (BI)
    • 文档
    • 电子签名
    销售
    • 客户关系管理
    • 销售
    • POS 销售点管理-零售
    • POS 销售点管理 - 餐厅
    • 订阅
    • 租赁
    网站
    • 网站设计
    • 电子商务
    • 博客
    • 论坛
    • 在线客服
    • 在线学习
    供应链
    • 库存
    • 制造
    • 产品生命周期
    • 采购
    • 维护保养
    • 品控
    人力资源
    • 员工
    • 招聘
    • 休假
    • 评价
    • 内部推荐
    • 车队
    营销
    • 社媒营销
    • 电邮营销
    • 短信营销
    • 近期活动
    • 营销自动化
    • 网上调查
    服务
    • 项目管理
    • 工时单
    • 现场服务
    • 服务台
    • 排期
    • 预约
    生产力
    • 讨论
    • 批核
    • 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:

  • 客户关系管理
  • e-Commerce
  • 会计
  • 库存
  • PoS
  • 项目
  • MRP
All apps
只限注册用戶才可与社群互动。
所有帖文 人 徽章
标签 (查看所有)
odoo accounting v14 pos v15
关于此论坛区
只限注册用戶才可与社群互动。
所有帖文 人 徽章
标签 (查看所有)
odoo accounting v14 pos v15
关于此论坛区
帮助

ondelete error/confusion in Odoo 14 repost

订阅

此帖文有活动时,接收通知

此问题已终结
2616 查看
形象
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致力于为企业管理提供高效智能的开源解决方案,是全球业内高速成长的软件服务商之一,逾七百五十万用户选择Odoo进行数字化升级。通过一系列全业务链覆盖、高度集成、简单易用的商业应用,助力企业实现信息化改革、降本增效并释放公司增长潜力。

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