[已解决]oe6.1.1 打开会计凭证行报错,bug?
-
Client Traceback (most recent call last):
File "d:\OpenERP 6.1-20120615-233338\Server\server\openerp\addons\web\common\http.py", line 180, in dispatch
File "d:\OpenERP 6.1-20120615-233338\Server\server\openerp\addons\web\controllers\main.py", line 1204, in load
File "d:\OpenERP 6.1-20120615-233338\Server\server\openerp\addons\web\controllers\main.py", line 1086, in fields_view_get
File "d:\OpenERP 6.1-20120615-233338\Server\server\openerp\addons\web\common\openerplib\main.py", line 250, in proxy
File "d:\OpenERP 6.1-20120615-233338\Server\server\openerp\addons\web\common\openerplib\main.py", line 117, in proxy
File "d:\OpenERP 6.1-20120615-233338\Server\server\openerp\addons\web\common\http.py", line 611, in send
Server Traceback (most recent call last):
File "d:\OpenERP 6.1-20120615-233338\Server\server\openerp\addons\web\common\http.py", line 592, in send
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\netsvc.py", line 360, in dispatch_rpc
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\service\web_services.py", line 586, in dispatch
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\osv\osv.py", line 167, in execute_kw
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\osv\osv.py", line 121, in wrapper
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\osv\osv.py", line 176, in execute
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\osv\osv.py", line 164, in execute_cr
File "d:\OpenERP 6.1-20120615-233338\Server\server\openerp\addons\account\account_move_line.py", line 972, in fields_view_get
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\osv\orm.py", line 2153, in fields_view_get
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\osv\orm.py", line 1793, in __view_look_dom_arch
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\osv\orm.py", line 1695, in __view_look_dom
File "d:\OpenERP 6.1-20120615-233338\Server\server\openerp\addons\account\account_move_line.py", line 935, in view_header_get
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\sql_db.py", line 152, in wrapper
File "d:\OpenERP 6.1-20120615-233338\Server\server.\openerp\sql_db.py", line 212, in execute
DataError: invalid input syntax for integer: "07/2012"
系统为xp,可能为日期格式问题,但在6.1.1 版本找不到。 -
在"大柘"和"mrshelly"的帮助和鼓励下,对上面问题进行了简单的分析。
---------------------------------------------------------------
环境:
oe版本:OpenERP 6.1-20120718-233405
操作系统:windows xp sp3
---------------------------------------------------------------
第一步:引发错误
引发错误出现的操作:会计->客户->会计凭证行
---------------------------------------------------------------
第二步:分析比较错误提示
错误提示见下图"oe6.1.1 打开会计凭证行报错.png"
通过我的得到的错误提示信息与"大柘"楼上提供的信息进行比较,发现在最后一行存在不同之处
"大柘":DataError: invalid input syntax for integer: "07/2012"
我的:DataError: invalid input syntax for integer: "X 08/2012"
注意到两个"会计期间"的格式不同,一个是"07/2012",一个是"X 08/2012"
-----------------------------------------------------------------------------
第三步:查看"会计凭证行"结果显示页面,找出"会计期间"文本框id和name
结果如下图"会计凭证行页面.fw.png"
从页面HTML源码中得"会计期间"文本框的id="search_input_many2one_period_id_471"和name="period_id"
(说明:该页面中的"会计期间"文本框所取的是会计期间的名称,而不是会计期间的编码)
-----------------------------------------------------------------------------
第四步:分析数据库中account_period表结构
结果如下图"数据库中account_period表结构.fw.png"
通过比较数据库中"表account_period的结构及内容"和oe中"会计->设置->财务会计->会计期间->会计期间"的内容得知两者字段的对应关系如下:
name->会计期间名称
code->编码
(其中account_period表中的"id"字段是serial类型,表示的是表中记录行的序列号)
--------------------------------------------------------------------------------------------
第五步:account_move_line.py原码修改
将语句cr.execute('SELECT code FROM account_period WHERE id = %s', (context['period_id'], ))中的"id"改成"name" -
1、通过银行和现金,凭证行,传入period_id的是会计期间,如:08/2012
2、通过会计凭证,会计凭证,会计凭证行,右边的连接,会计凭证行,传入传入period_id的是account_period表的id
而比较两者的context,2的情况下context的name值存在,而1的情况则不存在,我的修改方法为:
一治标、<br /> j = cr.fetchone()[0] or ''<br /> if(context.get('name', False)):<br /> cr.execute('SELECT code FROM account_period WHERE id = %s', (context['period_id'], ))<br /> else:<br /> cr.execute('SELECT code FROM account_period WHERE name = %s', (context['period_id'], )) <br /> p = cr.fetchone()[0] or ''<br />
二治本(参考论坛的帖子 [检测到链接无效,已移除] br /><br /> if context.get('period_id', False):<br /> period_id = context.get('period_id')<br /> if type(period_id) == str or type(period_id) == unicode:<br /> ids = period_obj.search(cr, uid, [('name', 'ilike', period_id)])<br /> context.update({<br /> 'period_id': ids[0]<br /> })<br /> return context<br />