跳至内容
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
关于此论坛区
帮助

error in migrating module v8 to v11

订阅

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

此问题已终结
11
3 回复
4334 查看
形象
NASHMIN YEGANEH

Hello dear members

I'm trying to port a module to v11 from v8 and here is the error log when i try to install it

please tell me if any one know where is the problem and how can i fix it

thanks in advance :)

 
Odoo Server Error

Traceback (most recent call last):
File "/opt/odoo/models.py", line 982, in _validate_fields
check(self)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 338, in _check_xml
self.postprocess_and_fields(view.model, view_doc, view.id)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 957, in postprocess_and_fields
self.raise_view_error(_('Model not found: %(model)s') % dict(model=model), view_id)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 506, in raise_view_error
raise ValueError(message)
ValueError: Model not found: res.letter

Error context:
View `Inbound Letter Tree`
[view_id: 1677, xml_id: n/a, model: res.letter, parent_id: n/a]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/odoo/tools/convert.py", line 741, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "/opt/odoo/tools/convert.py", line 651, in _tag_record
id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
File "/opt/odoo/addons/base/ir/ir_model.py", line 1469, in _update
record = record.create(values)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 401, in create
return super(View, self).create(self._compute_defaults(values))
File "/opt/odoo/models.py", line 3302, in create
self._fields[key].determine_inverse(record)
File "/opt/odoo/fields.py", line 1070, in determine_inverse
getattr(records, self.inverse)()
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 269, in _inverse_arch
view.write(data)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 417, in write
return super(View, self).write(self._compute_defaults(vals))
File "/opt/odoo/models.py", line 3024, in write
self._write(old_vals)
File "/opt/odoo/models.py", line 3177, in _write
self._validate_fields(vals)
File "/opt/odoo/models.py", line 986, in _validate_fields
raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
odoo.exceptions.ValidationError: ('Error while validating constraint\n\nModel not found: res.letter\n\nError context:\nView `Inbound Letter Tree`\n[view_id: 1677, xml_id: n/a, model: res.letter, parent_id: n/a]', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/odoo/http.py", line 647, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/http.py", line 307, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/opt/odoo/http.py", line 689, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/http.py", line 339, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/http.py", line 332, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/http.py", line 933, in __call__
return self.method(*args, **kw)
File "/opt/odoo/http.py", line 512, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/addons/web/controllers/main.py", line 934, in call_button
action = self._call_kw(model, method, args, {})
File "/opt/odoo/addons/web/controllers/main.py", line 922, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/api.py", line 689, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/api.py", line 680, in call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-40>", line 2, in button_immediate_install
File "/opt/odoo/addons/base/module/module.py", line 71, in check_and_log
return method(self, *args, **kwargs)
File "/opt/odoo/addons/base/module/module.py", line 448, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/opt/odoo/addons/base/module/module.py", line 541, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/opt/odoo/modules/registry.py", line 85, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/modules/loading.py", line 343, in load_modules
loaded_modules, update_module)
File "/opt/odoo/modules/loading.py", line 242, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/opt/odoo/modules/loading.py", line 156, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/opt/odoo/modules/loading.py", line 94, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/opt/odoo/tools/convert.py", line 788, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/opt/odoo/tools/convert.py", line 849, in convert_xml_import
obj.parse(doc.getroot(), mode=mode)
File "/opt/odoo/tools/convert.py", line 738, in parse
self.parse(rec, mode)
File "/opt/odoo/tools/convert.py", line 748, in parse
exc_info[2]
File "/opt/odoo/tools/pycompat.py", line 86, in reraise
raise value.with_traceback(tb)
File "/opt/odoo/tools/convert.py", line 741, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "/opt/odoo/tools/convert.py", line 651, in _tag_record
id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
File "/opt/odoo/addons/base/ir/ir_model.py", line 1469, in _update
record = record.create(values)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 401, in create
return super(View, self).create(self._compute_defaults(values))
File "/opt/odoo/models.py", line 3302, in create
self._fields[key].determine_inverse(record)
File "/opt/odoo/fields.py", line 1070, in determine_inverse
getattr(records, self.inverse)()
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 269, in _inverse_arch
view.write(data)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 417, in write
return super(View, self).write(self._compute_defaults(vals))
File "/opt/odoo/models.py", line 3024, in write
self._write(old_vals)
File "/opt/odoo/models.py", line 3177, in _write
self._validate_fields(vals)
File "/opt/odoo/models.py", line 986, in _validate_fields
raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
odoo.tools.convert.ParseError: "Error while validating constraint

Model not found: res.letter

Error context:
View `Inbound Letter Tree`
[view_id: 1677, xml_id: n/a, model: res.letter, parent_id: n/a]
None" while parsing /opt/odoo/addons/lettermgmt/views/res_letter_view.xml:10, near
<record model="ir.ui.view" id="res_letter_in_tree_view">
<field name="name">Inbound Letter Tree</field>
<field name="model">res.letter</field>
<field name="arch" type="xml">
<tree string="Letters">
<field name="name"/>
<field name="number"/>
<field name="move"/>
<field name="type"/>
<field name="class"/>
<field name="date"/>
<field name="recipient_partner_id"/>
<field name="state"/>
<field name="channel_id"/>
</tree>
</field>
</record>
0
形象
丢弃
形象
Cyril Gaspard (GEM)
最佳答案

Hi,

you must rewrite all your python code with the new api Odoo, see :

https://www.odoo.com/documentation/12.0/howtos/backend.html#

to resume what youhave to do with changes in new api :

1) in your __init__.py file, import your python file like this:

from . import my_python_file_name

2) All types names of fields start with upper:

name = fields.Text(string="My text")

3) You must use decorators for your functions (@api.model, @api.one, @api.multi, @api.onchange, @api.constraint ...), and no need to define cr, uid, context, you can have access to this variable using self._context, self._cr ..., this variables are automatically propgated.


@api.model

def _get_number(self):
        context = self._context or {}
        sequence_pool = self.env['ir.sequence']
        move_type = context.get('move', 'in')
        return sequence_pool.get('%s.letter' % move_type)

4) now context is a frozendict

to redifine context use with_context:

self.with_context({'key': value}).create(vals)

or

self.with_context(key=value}).create(vals)

5) _defaults is now an attribute to define in body field definition

_defaults = {
        'number': _get_number,}

is now:

number = fields.Char('Number', help="Auto Generated Number of letter.", required=True, default=lambda self: self._get_number())

6) Some new attributes to define fields are new like company_dependent=True, ..., see list line 133 her :

https://github.com/odoo/odoo/blob/10.0/odoo/fields.py

7) to browse a model:

self.pool.get('my.model')

is now :

self.env['my.model']

8) function self.search([('field', '=', 10)]) return now a recorset, not a list, same thing for function create ...

9) ....

Good luck, you have some efforts to make to learn new api

Regards

1
形象
丢弃
NASHMIN YEGANEH
编写者

Yes, the __init__.py file content is correct i think, here you can see it here

1) from . import (

letter_class,

letter_folder,

res_letter,

letter_type,

letter_reassignment,

letter_channel,

)

2) some of types names of fields didn't started with upper, i fixed them and for now i got below error log

2018-10-13 20:18:03,402 5311 ERROR ? werkzeug: Error on request:

Traceback (most recent call last):

File "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 270, in run_wsgi

execute(self.server.app)

File "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 258, in execute

application_iter = app(environ, start_response)

File "/opt/rstco/odoo/service/server.py", line 252, in app

return self.app(e, s)

File "/opt/rstco/odoo/service/wsgi_server.py", line 166, in application

return application_unproxied(environ, start_response)

File "/opt/rstco/odoo/service/wsgi_server.py", line 154, in application_unproxied

result = handler(environ, start_response)

File "/opt/rstco/odoo/http.py", line 1303, in __call__

self.load_addons()

File "/opt/rstco/odoo/http.py", line 1325, in load_addons

m = __import__('odoo.addons.' + module)

File "<frozen importlib._bootstrap>", line 971, in _find_and_load

File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked

File "<frozen importlib._bootstrap>", line 656, in _load_unlocked

File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible

File "/opt/rstco/odoo/modules/module.py", line 82, in load_module

exec(open(modfile, 'rb').read(), new_mod.__dict__)

File "<string>", line 23, in <module>

File "/opt/rstco/odoo/addons/lettermgmt/models/__init__.py", line 21, in <module>

from . import (

File "/opt/rstco/odoo/addons/lettermgmt/models/res_letter.py", line 27, in <module>

class res_letter(models.Model):

File "/opt/rstco/odoo/addons/lettermgmt/models/res_letter.py", line 46, in res_letter

('in', _('IN')),

NameError: name '_' is not defined

and now im working on step 3 :)

NASHMIN YEGANEH
编写者

@Cyril Gaspard (GEM)

Do this work for importing modules in __init__.py or i need to put each on per seperated line?

from . import (

letter_class,

letter_folder,

res_letter,

letter_type,

letter_reassignment,

letter_channel,

)

Cyril Gaspard (GEM)

Hi,

personnaly I use one line for each file to import.

For NameError: name '_' is not defined, you must import _ for translation like this

from odoo import models, fields, _

Bye

形象
Jainesh Shah(Aktiv Software)
最佳答案

Hello Berctain,

Please verify if you have migrated res.letter model or not.

it is showing that the model is not properly migrated.

Thanks.




Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

3
形象
丢弃
形象
NASHMIN YEGANEH
编写者 最佳答案

Thanks for replies, this is the res_letter.py python file... and what i did until now

from odoo import models, fields


class res_letter(models.Model):
"""A register class to log all movements regarding letters"""
_name = 'res.letter'
_description = "Log of Letter Movements"
_inherit = 'mail.thread'

def _get_number(self, cr, uid, context=None):
if context is None:
context = {}
sequence_pool = self.env.get('ir.sequence')
move_type = context.get('move', 'in')
return sequence_pool.get(
cr, uid, '%s.letter' % move_type, context=context)

name = fields.text('Subject', help='Comment for user explaining forward.')
folder_id = fields.Many2one('letter.folder', 'Folder', help='Folder which contains letter.')
number = fields.char('Number', help="Auto Generated Number of letter.", required=True)
move = fields.Selection(
[
('in', _('IN')),
('out', _('OUT')), help="Incoming or Outgoing Letter."
],
'Move', index=True, readonly=True, default='draft', )
type = fields.Many2one('letter.type', 'Type', help='Type of Letter, Depending upon size.')
class = fields.Many2one('letter.class', 'Class', help='Classification of Document.')
date = fields.datetime('Letter Date', help='The letter\'s date')
snd_rec_date = fields.datetime('Sent / Received Date', help='Created Date of Letter Logging.')
recipient_partner_id = fields.Many2one('res.partner', 'Recipient', track_visibility='onchange')
sender_partner_id = fields.Many2one('res.partner', 'Sender', track_visibility='onchange')
note = fields.text('Note')

state = fields.Selection(
[
('draft', _('Draft')),
('created', _('Created')),
('validated', _('Validated')),
('rec', _('Received')),
('sent', _('Sent')),
('rec_bad', _('Received Damage')),
('rec_ret', _('Received But Returned')),
('cancel', _('Cancelled'))],
],
'State', index = True, readonly = True, default = 'draft' track_visibility='onchange' )
parent_id = fields.Many2one('res.letter', 'Parent')
child_line = fields.Many2one('res.letter', 'parent_id', 'Letter Lines')
channel_id = fields.Many2one('letter.channel', 'Sent / Receive Source')
orig_ref = fields.char('Original Reference', help="Reference Number at Origin.")
expeditor_ref = fields.char('Expeditor Reference', help="Reference Number used by Expeditor.")
track_ref = fields.char('Tracking Reference', help="Reference Number used for Tracking.")
reassignment_ids = fields.One2many('letter.reassignment', 'letter_id', 'Reassignment lines', help='Reassignment users and comments')
extern_partner_ids = fields.Many2many('res.partner', 'Recipients')


}

_defaults = {
'number': _get_number,
'snd_rec_date': fields.datetime.now,
'move': lambda self, cr, uid, context: context.get('move', 'in'),
'state': 'draft',
}

def action_received(self, cr, uid, ids, context=None):
"""Put the state of the letter into Received"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(cr, uid, [letter.id], {'state': 'rec'}, context=context)
return True

def action_cancel(self, cr, uid, ids, context=None):
"""Put the state of the letter into Cancelled"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'cancel'}, context=context)
return True

def action_create(self, cr, uid, ids, context=None):
"""Put the state of the letter into Crated"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'created'}, context=context)
return True

def action_validate(self, cr, uid, ids, context=None):
"""Put the state of the letter into Validated"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'validated'}, context=context)
return True

def action_send(self, cr, uid, ids, context=None):
"""Put the state of the letter into sent"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id],
{
'state': 'sent',
'snd_rec_date': letter.snd_rec_date or
fields.datetime.now()
},
context=context)
return True

def action_rec_ret(self, cr, uid, ids, context=None):
"""Put the state of the letter into Received but Returned"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'rec_ret'}, context=context)
return True

def action_rec_bad(self, cr, uid, ids, context=None):
"""Put the state of the letter into Received but Damaged"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'rec_bad'}, context=context)
return True

def action_set_draft(self, cr, uid, ids, context=None):
"""Put the state of the letter into draft"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'draft'}, context=context)
return True
0
形象
丢弃
喜欢讨论吗?不要只阅读,加入进来!

立即创建账户,享受专属功能,与我们的精彩社区互动!

注册
相关帖文 回复 查看 活动
How to Disable edit option in form when the state is done 已解决
11
形象
形象
形象
2
2月 24
13947
Onchange function not loading values on form
11
形象
形象
2
10月 18
3512
Is Odoo a stateless web application?
11
形象
形象
1
3月 18
5127
[11.0] invoicing of timesheet for multiple salesorders
11
形象
0
11月 17
3197
how to eliminate the "Create/edit" option at the quotation 已解决
odoo 11
形象
形象
形象
2
4月 23
12823
社区
  • 教学视频
  • 文档
  • 论坛
开源
  • 下载
  • 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