新建模块时models不能加载如何解决
-
@Siyuan
报错如下Traceback (most recent call last): File "D:\GOdoo10\source\odoo\http.py", line 638, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "D:\GOdoo10\source\odoo\http.py", line 675, in dispatch result = self._call_function(**self.params) File "D:\GOdoo10\source\odoo\http.py", line 331, in _call_function return checked_call(self.db, *args, **kwargs) File "D:\GOdoo10\source\odoo\service\model.py", line 119, in wrapper return f(dbname, *args, **kwargs) File "D:\GOdoo10\source\odoo\http.py", line 324, in checked_call result = self.endpoint(*a, **kw) File "D:\GOdoo10\source\odoo\http.py", line 933, in __call__ return self.method(*args, **kw) File "D:\GOdoo10\source\odoo\http.py", line 504, in response_wrap response = f(*args, **kw) File "D:\GOdoo10\source\addons\web\controllers\main.py", line 866, in call_button action = self._call_kw(model, method, args, {}) File "D:\GOdoo10\source\addons\web\controllers\main.py", line 854, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "D:\GOdoo10\source\odoo\api.py", line 681, in call_kw return call_kw_multi(method, model, args, kwargs) File "D:\GOdoo10\source\odoo\api.py", line 672, in call_kw_multi result = method(recs, *args, **kwargs) File "D:\GOdoo10\source\odoo\addons\base\module\module.py", line 527, in button_immediate_upgrade return self._button_immediate_function(type(self).button_upgrade) File "D:\GOdoo10\source\odoo\addons\base\module\module.py", line 484, in _button_immediate_function modules.registry.Registry.new(self._cr.dbname, update_module=True) File "D:\GOdoo10\source\odoo\modules\registry.py", line 78, in new odoo.modules.load_modules(registry._db, force_demo, status, update_module) File "D:\GOdoo10\source\odoo\modules\loading.py", line 333, in load_modules force, status, report, loaded_modules, update_module) File "D:\GOdoo10\source\odoo\modules\loading.py", line 235, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "D:\GOdoo10\source\odoo\modules\loading.py", line 156, in load_module_graph _load_data(cr, module_name, idref, mode, kind='data') File "D:\GOdoo10\source\odoo\modules\loading.py", line 95, in _load_data tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report) File "D:\GOdoo10\source\odoo\tools\convert.py", line 851, in convert_file convert_xml_import(cr, module, fp, idref, mode, noupdate, report) File "D:\GOdoo10\source\odoo\tools\convert.py", line 921, in convert_xml_import obj.parse(doc.getroot(), mode=mode) File "D:\GOdoo10\source\odoo\tools\convert.py", line 802, in parse self.parse(rec, mode) File "D:\GOdoo10\source\odoo\tools\convert.py", line 805, in parse self._tags[rec.tag](rec, de, mode=mode) File "D:\GOdoo10\source\odoo\tools\convert.py", line 443, in _tag_act_window id = self.env['ir.model.data']._update('ir.actions.act_window', self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode) File "D:\GOdoo10\source\odoo\addons\base\ir\ir_model.py", line 1159, in _update record = record.create(values) File "D:\GOdoo10\source\odoo\addons\base\ir\ir_actions.py", line 340, in create return super(IrActionsActWindow, self).create(vals) File "D:\GOdoo10\source\odoo\addons\base\ir\ir_actions.py", line 40, in create res = super(IrActions, self).create(vals) File "D:\GOdoo10\source\odoo\models.py", line 3798, in create record = self.browse(self._create(old_vals)) File "D:\GOdoo10\source\odoo\models.py", line 3954, in _create self._validate_fields(vals) File "D:\GOdoo10\source\odoo\models.py", line 1058, in _validate_fields check(self) File "D:\GOdoo10\source\odoo\addons\base\ir\ir_actions.py", line 248, in _check_model raise ValidationError(_('Invalid model name %r in action definition.') % action.res_model) ParseError: "Invalid model name u'shouhou.shouhoudan' in action definition. None" while parsing file:///D:/GOdoo10/myaddons/shouhou/views/views.xml:38, near <act_window id="action_shouhou_shouhoudan" name="售后单" res_model="shouhou.shouhoudan" view_mode="tree,form"/>
应该就是模型未被成功的导入,但是却不知的为什么会导入不了
-
学习odoo模块创建,
推荐官方文档:
https://www.odoo.com/documentation/10.0/howtos/backend.html
Building a Module
-_-
-
你的模块有以下几个问题:
- .\init.py ,如果你的模块里面没有controllers,这行删掉。
- .\manifest.py,如果你的模块里面没有'views/templates.xml',这行删掉。
- .\manifest.py,如果你的模块里面没有'demo/demo.xml',,这行删掉。
- .\models\models.py,文件里面有中文字符,那就在首行加上编码,# -- coding: utf-8 --
然后重启odoo服务更新模块,如果还是出错。你可以在启动odoo server的时候通过命令行参数更新模块 -d 数据库名 -u模块名或者你可以删掉旧数据库再重新安装。