整理了一部非常适合新手入门的开发手册
-
-
赞,杨总写的非常棒
-
按照手册一步一步做,在到第二章时自定义模块出了以下
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"/> -
@Joshua
_manifest.py# -*- coding: utf-8 -*- { 'name': "shouhou", 'summary': """ 售后模块""", 'description': """ 售后模块 """, 'website': "http://www.yourcompany.com", # Categories can be used to filter modules in modules listing # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml # for the full list 'category': 'Uncategorized', 'version': '0.1', # any module necessary for this one to work correctly 'depends': ['base'], # always loaded 'data': [ # 'security/ir.model.access.csv', 'views/views.xml', 'views/templates.xml', ], # only loaded in demonstration mode 'demo': [ 'demo/demo.xml', ], }
-
from odoo import models, fields, api class shouhoudan(models.Model): _name = 'shouhou.shouhoudan' name = fields.Char(string="报修人") days = fields.Integer(string="预计处理时长") startdate = fields.Date(string="报修日期日期") reason = fields.Text(string="售后事由")
view.xml
<openerp> <data> <!-- tree视图 --> <record id="view_tree_shouhou_shouhoudan" model="ir.ui.view"> <field name="name">售后单列表</field> <field name="model">shouhou.shouhoudan</field> <field name="arch" type="xml"> <tree> <field name="name"/> <field name="days"/> <field name="startdate"/> </tree> </field> </record> <!-- form视图 --> <record id="view_form_shouhou_shouhoudan" model="ir.ui.view"> <field name="name">售后单</field> <field name="model">shouhou.shouhoudan</field> <field name="arch" type="xml"> <form> <sheet> <group name="group_top" string="售后单"> <field name="name"/> <field name="days"/> <field name="startdate"/> <field name="reason"/> </group> </sheet> </form> </field> </record> <!-- 视图动作 --> <act_window id="action_shouhou_shouhoudan" name="售后单" res_model="shouhou.shouhoudan" view_mode="tree,form" /> <!-- 顶级菜单 --> <menuitem name="售后" id="menu_shouhou"/> <!-- 二级菜单 --> <menuitem name="售后单" id="menu_shouhou_shouhoudan" parent="menu_shouhou" action="action_shouhou_shouhoudan"/> </data> </openerp>
-
帮你编辑了一下帖子,请用```包住你的代码,这样就能保持代码格式,并且有语法加亮了。
你在
__init__.py
中有import 你的model.py
吗? -
如果你这样修改后还要重启服务器,并更新模块
可以手动重启(因为报错无法进入系统更新模块了):
odoo-bin -d YourDB -u 请假单模块