Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

初次开发OE请假模块安装时报错了,求大神指导



  • 从《笨办法学Python(完整书签)》了解Python,基于OE官方的《OpenERP_Technical_Memento_v0.7.3.pdf》、《openerp-technical-training-v7-exercises.pdf》、老肖的《OpenERP开发教程.pdf》再加上OE源码尝试开发老肖教程中的请假模块。。。

    模块结构:
    [attachimg=1]

    openerp.py

    <br />{<br />&nbsp; &nbsp; &quot;name&quot;: &quot;yx_qingjd&quot;,<br />&nbsp; &nbsp; &quot;version&quot;: &quot;1.0&quot;,<br />&nbsp; &nbsp; &quot;depends&quot;: [&quot;base&quot;],<br />&nbsp; &nbsp; &quot;author&quot;: &quot;zhaocjiang&quot;,<br />&nbsp; &nbsp; &quot;category&quot;: &quot;other&quot;,<br />&nbsp; &nbsp; &quot;description&quot;: &quot;&quot;&quot;<br />&nbsp; &nbsp; 请假单<br />&nbsp; &nbsp; &quot;&quot;&quot;,<br />&nbsp; &nbsp; &quot;data&quot;: &#91;&#039;yx_qingj_view.xml&#039;,],<br />&nbsp; &nbsp; &quot;demo&quot;: &#91;],<br />&nbsp; &nbsp; &quot;test&quot;: &#91;],<br />&nbsp; &nbsp; &quot;installable&quot;: True,<br />&nbsp; &nbsp; &quot;auto_install&quot;: False,<br />&nbsp; &nbsp; &quot;license&quot;: &quot;GPL-3&quot;<br />}<br />
    



    yx_qingj.py

    <br />from openerp.osv import osv, fields<br /><br />class yx_qingj_qingjd(osv):<br />&nbsp; &nbsp; &#039;&#039;&#039;<br />&nbsp; &nbsp; classdocs<br />&nbsp; &nbsp; &#039;&#039;&#039;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; _name = &#039;yx_qingj.qingjd&#039;<br />&nbsp; &nbsp; _description = u&#039;请假单&#039;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;shenqr&#039;: fields.many2one(&#039;res.users&#039;, u&#039;申请人&#039;, required = True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;tians&#039;: fields.float(u&#039;天数&#039;,digits=(3,1), required = True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;kaisrq&#039;: fields.date(u&#039;开始日期&#039;, required = True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;shiyou&#039;: fields.text(u&#039;事由&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;state&#039;: fields.selection([<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (&#039;draft&#039;, u&#039;草稿&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (&#039;wait_prove&#039;, u&#039;待批&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (&#039;proved&#039;, u&#039;已批&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (&#039;rejected&#039;, u&#039;被拒&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ], u&#039;状态&#039;, readonly = True)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; _defauts = {&#039;state&#039;: &#039;draft&#039;}<br /><br />yx_qingj_qingjd()<br />
    



    yx_qingj_view.xml

    <br />&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br /><br />&lt;openerp&gt;<br /><br />	&lt;data&gt;<br />	<br />		&lt;!-- 顶部菜单 --&gt;<br />		&lt;menuitem id = &#039;menu_yx_qingj_root&#039; name = &#039;请假单&#039; sequence = &#039;0&#039;/&gt;<br />		<br />		&lt;menuitem id = &#039;menu_yx_qingj_mgmt&#039; name = &#039;请假单&#039; sequence = &#039;1&#039; parent = &#039;menu_yx_qingj_root&#039;/&gt;<br />		<br />		&lt;!-- menuitem --&gt;<br />		&lt;menuitem id = &#039;menu_action_picking_tree&#039; action = &#039;action_qingjd_form&#039; sequence = &#039;3&#039; parent = &#039;menu_yx_qingj_mgmt&#039;/&gt;<br />		<br />		&lt;!-- actions --&gt;<br />		&lt;record id = &#039;action_qingjd_form&#039; model = &#039;ir.actions.act_windows&#039;&gt;<br />		<br />			&lt;field name = &#039;name&#039;&gt;请假单&lt;/field&gt;<br />			<br />			&lt;field name = &#039;type&#039;&gt;ir.actions.act_windows&lt;/field&gt;<br />			<br />			&lt;field name = &#039;res_model&#039;&gt;yx_qingj.qingjd&lt;/field&gt;<br />			<br />			&lt;field name = &#039;view_type&#039;&gt;form&lt;/field&gt;<br />			<br />			&lt;field name = &#039;view_model&#039;&gt;tree, form&lt;/field&gt;<br />			<br />			&lt;field name = &#039;view_id&#039; ref = &#039;yx_qingjd_tree&#039;/&gt;<br />		<br />		&lt;/record&gt;<br />	<br />		&lt;!-- form 视图 --&gt;<br />		&lt;record id = &quot;yx_qingjd_form&quot; model=&quot;ir.ui.view&quot;&gt;<br />		<br />			&lt;field name = &quot;name&quot;&gt; yx.qingjd.form &lt;/field&gt;<br />			<br />			&lt;field name = &quot;model&quot;&gt; yx_qingj.qingjd &lt;/field&gt;<br />			<br />			&lt;field name = &#039;type&#039;&gt; form &lt;/field&gt;<br />			<br />			&lt;field name = &#039;arch&#039; type = &#039;xml&#039;&gt;<br />			<br />				&lt;form string = &#039;QingJiaDan&#039; vision = &#039;7.0&#039;&gt;<br />				<br />					&lt;header&gt;<br />					<br />						&lt;button string = &#039;送批&#039; name = &#039;action_to_prove&#039; states = &#039;draft&#039;/&gt;<br />						<br />						&lt;button string = &#039;批准&#039; name = &#039;action_proved&#039; states = &#039;wait_prove&#039;/&gt;<br />						<br />						&lt;button string = &#039;拒绝&#039; name = &#039;action_rejected&#039; sates = &#039;wait_prove&#039;/&gt;<br />					<br />						&lt;field name = &#039;state&#039; widget = &#039;statusbar&#039; statusbar_visible = &#039;draft,wait_prove,proved&#039; statusbar_colors = &#039;{&quot;wait_prove&quot;:&quot;red&quot;,&quot;proved&quot;:&quot;blue&quot;}&#039;<br />					&lt;/header&gt;<br />					<br />					&lt;sheet&gt;<br />					<br />						&lt;group&gt;<br />						<br />							&lt;group&gt;<br />							<br />								&lt;field name = &#039;shenqr&#039;/&gt;<br />								<br />								&lt;field name = &#039;tians&#039;/&gt;<br />								<br />								&lt;field name = &#039;kaisrq&#039;/&gt;<br />							<br />							&lt;/group&gt;<br />						<br />							&lt;group&gt;<br />							<br />								&lt;field name = &#039;shiyou&#039;/&gt;<br />							<br />							&lt;/group&gt;<br />						&lt;/group&gt;<br />					<br />					&lt;/sheet&gt;<br />				<br />				&lt;/form&gt;<br />			<br />			&lt;/field&gt;<br />		<br />		&lt;/record&gt;<br />	<br />		&lt;!-- tree 视图 --&gt;<br />		&lt;record id = &#039;yx_qingjd_tree&#039; model = &#039;ir.ui.view&#039;&gt;<br />		<br />			&lt;field name = &#039;name&#039;&gt;yx.qingjd.tree&lt;/field&gt;<br />		<br />			&lt;field name = &quot;model&quot;&gt; yx_qingj.qingjd &lt;/field&gt;<br />			<br />			&lt;field name = &#039;type&#039;&gt; form &lt;/field&gt;<br />			<br />			&lt;field name = &#039;priority&#039; eval = &#039;16&#039; /&gt;<br />			<br />			&lt;field name = &#039;arch&#039; type = &#039;xml&#039;&gt;<br />			<br />				&lt;tree string = &#039;QingJiaDan&#039;&gt;<br />				<br />					&lt;field name = &#039;shenqr&#039; select = &#039;1&#039;/&gt;<br />					<br />					&lt;field name = &#039;tians&#039;/&gt;<br />					<br />					&lt;field name = &#039;kaisrq&#039; select = &#039;1&#039;/&gt;<br />					<br />					&lt;field name = &#039;shiyou&#039;/&gt;<br />					<br />					&lt;field name = &#039;state&#039; select = &#039;1&#039;/&gt;<br />					<br />				&lt;/tree&gt;<br />			<br />			&lt;/field&gt;<br />			<br />		&lt;/record&gt;<br />	&lt;/data&gt;<br /><br />&lt;/openerp&gt;<br />
    



    但是安装模块的时候出现了错误。

    <br />Client Traceback (most recent call last):<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\addons\web\http.py&quot;, line 204, in dispatch<br />&nbsp; &nbsp; response[&quot;result&quot;] = method(self, **self.params)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\addons\web\controllers\main.py&quot;, line 1129, in call_button<br />&nbsp; &nbsp; action = self._call_kw(req, model, method, args, {})<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\addons\web\controllers\main.py&quot;, line 1117, in _call_kw<br />&nbsp; &nbsp; return getattr(req.session.model(model), method)(*args, **kwargs)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\addons\web\session.py&quot;, line 42, in proxy<br />&nbsp; &nbsp; result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\addons\web\session.py&quot;, line 30, in proxy_method<br />&nbsp; &nbsp; result = self.session.send(self.service_name, method, *args)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\addons\web\session.py&quot;, line 103, in send<br />&nbsp; &nbsp; raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)<br /><br /><br />Server Traceback (most recent call last):<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\addons\web\session.py&quot;, line 89, in send<br />&nbsp; &nbsp; return openerp.netsvc.dispatch_rpc(service_name, method, args)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\netsvc.py&quot;, line 292, in dispatch_rpc<br />&nbsp; &nbsp; result = ExportService.getService(service_name).dispatch(method, params)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\service\web_services.py&quot;, line 626, in dispatch<br />&nbsp; &nbsp; res = fn(db, uid, *params)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\osv\osv.py&quot;, line 188, in execute_kw<br />&nbsp; &nbsp; return self.execute(db, uid, obj, method, *args, **kw or {})<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\osv\osv.py&quot;, line 131, in wrapper<br />&nbsp; &nbsp; return f(self, dbname, *args, **kwargs)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\osv\osv.py&quot;, line 197, in execute<br />&nbsp; &nbsp; res = self.execute_cr(cr, uid, obj, method, *args, **kw)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\osv\osv.py&quot;, line 185, in execute_cr<br />&nbsp; &nbsp; return getattr(object, method)(cr, uid, *args, **kw)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\addons\base\module\module.py&quot;, line 424, in button_immediate_install<br />&nbsp; &nbsp; return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\addons\base\module\module.py&quot;, line 475, in _button_immediate_function<br />&nbsp; &nbsp; _, pool = pooler.restart_pool(cr.dbname, update_module=True)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\pooler.py&quot;, line 39, in restart_pool<br />&nbsp; &nbsp; registry = RegistryManager.new(db_name, force_demo, status, update_module)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\modules\registry.py&quot;, line 218, in new<br />&nbsp; &nbsp; openerp.modules.load_modules(registry.db, force_demo, status, update_module)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\modules\loading.py&quot;, line 345, in load_modules<br />&nbsp; &nbsp; processed = load_marked_modules(cr, graph, states_to_load, force, status, report, loaded_modules, update_module)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\modules\loading.py&quot;, line 256, in load_marked_modules<br />&nbsp; &nbsp; loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\modules\loading.py&quot;, line 188, in load_module_graph<br />&nbsp; &nbsp; load_data(module_name, idref, mode)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\modules\loading.py&quot;, line 76, in &lt;lambda&gt;<br />&nbsp; &nbsp; load_data = lambda *args: _load_data(cr, *args, kind=&#039;data&#039;)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\modules\loading.py&quot;, line 124, in _load_data<br />&nbsp; &nbsp; tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)<br />&nbsp; File &quot;E:\GreenOpenERP-7.0-20130628-231051\openerp\tools\convert.py&quot;, line 941, in convert_xml_import<br />&nbsp; &nbsp; doc = etree.parse(xmlfile)<br />&nbsp; File &quot;lxml.etree.pyx&quot;, line 3196, in lxml.etree.parse (src\lxml\lxml.etree.c:64039)<br />&nbsp; File &quot;parser.pxi&quot;, line 1571, in lxml.etree._parseDocument (src\lxml\lxml.etree.c:91476)<br />&nbsp; File &quot;parser.pxi&quot;, line 1601, in lxml.etree._parseFilelikeDocument (src\lxml\lxml.etree.c:91798)<br />&nbsp; File &quot;parser.pxi&quot;, line 1484, in lxml.etree._parseDocFromFilelike (src\lxml\lxml.etree.c:90682)<br />&nbsp; File &quot;parser.pxi&quot;, line 1047, in lxml.etree._BaseParser._parseDocFromFilelike (src\lxml\lxml.etree.c:87736)<br />&nbsp; File &quot;parser.pxi&quot;, line 565, in lxml.etree._ParserContext._handleParseResultDoc (src\lxml\lxml.etree.c:83101)<br />&nbsp; File &quot;parser.pxi&quot;, line 656, in lxml.etree._handleParseResult (src\lxml\lxml.etree.c:84083)<br />&nbsp; File &quot;parser.pxi&quot;, line 596, in lxml.etree._raiseParseError (src\lxml\lxml.etree.c:83407)<br />XMLSyntaxError: error parsing attribute name, line 54, column 1<br />
    


  • 53行缺了 />



  • 怎么不用系统带的那个 hr模块



  • 很不错了,已经进步了,向你学习



  • 51 行 有拼写错误



  • _name = 'yx_qingj.qingjd'

    下划线 使用错误



  • 顺序不对,
    先 form/tree,然后 action,menu
    后面的会引用前面的定义,所以 顺序不能错



  • 系统那个还是不错的啊


Log in to reply