2013-01-15 91 views
0

我在創建新按鈕以更改新學生的狀態時遇到問題。創建一個新按鈕來更改新學生的狀態

首先我創建了一個XML文件:

... 
<record model="ir.ui.view" id="student_form"> 
<field name="name">sim.student.form</field> 
<field name="model">sim.student</field> 
<field name="type">form</field> 
<field name="arch" type="xml"> 
<form string="Student"> 
<field name="name"/> 
<field name="student_name"/> 
<field name="father_name"/> 
<field name="gender"/> 
<field name="contact_no"/> 
<button name="setuju" states="draft" string="Approve" type="object"/> 
</form> 
</field> 
</record> 
... 

接下來,我創建了一個Python文件:

from osv import fields, osv 
import time 
import netsvc 
import pooler 

class sim_student(osv.osv): 
    _name = "sim.student" 
    _description = "Data Siswa" 

    def setuju(self, cr, uid, ids, context=None): 
     workflow = netsvc.LocalService('workflow') 

     for name in ids: 
      workflow.trg_create(uid, self._name, name, cr) 

     return self.write(cr, uid, ids, {'state': 'confirmed'}, context=context) 

    _columns = { 
     'name': fields.char('Registration Number',size=256,required=True), 
     'student_name': fields.char('Student Name',size=256,required=True), 
     'father_name': fields.char('Father Name',size=256), 
     'gender':fields.selection([('male','Male'),('female','Female')],'Gender'), 
     'contact_no':fields.char('Contact Number',size=256), 
     'state': fields.selection([('new', 'New'), \ 
            ('confirmed', 'Received'), \ 
            ('cancelled', 'Cancelled')], \ 
           'Status', readonly=True, select=True) 
    } 

sim_student() 

然後我createe的初始化 .py文件:

import sim 

最後,我創建了一個openerp .py文件:

{ 
'name': 'Student Information Management', 
'version': '0.1', 
'category': 'Tools', 
'description': """Data Siswa.""", 
'author': 'Wasis Lukito', 
'summary': 'Test, Test, dan Test', 
'website': 'http://wasis.wordpress.com/', 
'depends': ['base'], 
#'init_xml': [], 
#'update_xml': ['sim_view.xml'], 
#'demo_xml': [], 
#'installable': True, 
'data': ['sim_view.xml',], 
'css':['static/src/css/lunch.css'], 
'demo': [], 
'installable': True, 
'application' : True, 
'certificate' : '001292377792581874189', 
'images': [], 
} 

當我執行的代碼,但是,它產生此錯誤消息:

No handler found. 

這是從控制檯錯誤:

C:\Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\.\pytz\tzinfo.py 
:5: DeprecationWarning: the sets module is deprecated 
ERROR: couldn't create the logfile directory. Logging to the standard output. 
2013-01-15 15:21:39,977 2136 ←[1;32m←[1;49mINFO←[0m ? openerp: OpenERP version 7 
.0alpha-20121206-000102 
2013-01-15 15:21:39,994 2136 ←[1;32m←[1;49mINFO←[0m ? openerp: addons paths: C:\ 
Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\openerp\addons 
2013-01-15 15:21:40,023 2136 ←[1;32m←[1;49mINFO←[0m ? openerp: database hostname 
: localhost 
2013-01-15 15:21:40,039 2136 ←[1;32m←[1;49mINFO←[0m ? openerp: database port: 54 
32 
2013-01-15 15:21:40,055 2136 ←[1;32m←[1;49mINFO←[0m ? openerp: database user: op 
enpg 
ERROR: couldn't create the logfile directory. Logging to the standard output. 
2013-01-15 15:21:40,799 2136 ←[1;33m←[1;49mWARNING←[0m ? openerp.addons.google_d 
ocs.google_docs: Please install latest gdata-python-client from http://code.goog 
le.com/p/gdata-python-client/downloads/list 
2013-01-15 15:21:41,548 2136 ←[1;37m←[1;41mCRITICAL←[0m ? openerp.modules.module 
: Couldn't load module web 
2013-01-15 15:21:41,568 2136 ←[1;37m←[1;41mCRITICAL←[0m ? openerp.modules.module 
: unexpected indent (sim.py, line 10) 
2013-01-15 15:21:41,585 2136 ←[1;31m←[1;49mERROR←[0m ? openerp.service: Failed t 
o load server-wide module `web`. 
The `web` module is provided by the addons found in the `openerp-web` project. 
Maybe you forgot to add those addons in your addons_path configuration. 
Traceback (most recent call last): 
    File "C:\Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\.\opener 
p\service\__init__.py", line 53, in load_server_wide_modules 
    File "C:\Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\.\opener 
p\modules\module.py", line 414, in load_openerp_module 
    File "C:\Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\openerp\ 
addons\web\http.py", line 593, in wsgi_postload 
    File "C:\Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\openerp\ 
addons\web\http.py", line 482, in __init__ 
    File "C:\Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\openerp\ 
addons\web\http.py", line 549, in _load_addons 
    File "C:\Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\.\opener 
p\modules\module.py", line 133, in load_module 
    File "C:\Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\openerp\ 
addons\sim\__init__.py", line 1, in <module> 
    File "C:\Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\openerp\ 
addons\sim\sim.py", line 10 
    def setuju(self, cr, uid, ids, context=None): 
    ^
IndentationError: unexpected indent 
2013-01-15 15:21:41,849 2136 ←[1;32m←[1;49mINFO←[0m ? openerp.service.netrpc_ser 
ver: starting NET-RPC service on 0.0.0.0:8070 
2013-01-15 15:21:41,877 2136 ←[1;32m←[1;49mINFO←[0m ? openerp.netsvc: Starting 1 
services 
2013-01-15 15:21:41,897 2136 ←[1;32m←[1;49mINFO←[0m ? openerp: OpenERP server is 
running, waiting for connections... 
2013-01-15 15:21:41,913 2136 ←[1;32m←[1;49mINFO←[0m ? openerp.service.wsgi_serve 
r: HTTP service (werkzeug) running on 0.0.0.0:8069 

的錯誤似乎來自「def setuju(...」)。我的腳本有什麼問題?

+0

我試着給你的代碼和它的工作沒有任何錯誤。你能提供控制檯上的錯誤嗎? –

+0

我使用Windows,我不知道它是否在Linux中工作,如何從控制檯(CMD)提供錯誤..? –

+0

我使用openerp 7 alpha,我真的空白這個問題.. –

回答

1

請從openerp文件中刪除鑰匙'證書'如果你的模塊沒有證書。另請從setuju()功能中刪除工作流程。我沒有看到爲你的班級定義的工作流程。

從日誌中發現錯誤是因爲縮進錯誤。請檢查您是否有正確的空格數量def setuju()

+0

我已經編輯它與控制檯的錯誤消息,我現在必須做什麼..? –

+0

我做你的命令,然後我得到新的錯誤.. 文件「C:\ Program Files \ OpenERP 7.0alpha-20121206-000102 \ Server \ server \ openerp \ addons \ sim \ sim.py」,第8行 工作流程= netsvc.LocalService('workflow') ^ IndentationError:預期一個縮進塊 –

+0

@ ws_123,正如DReispt所說,請移除標籤並給出空格。 – OmaL

1

要在OpenERP上開發,即使有經驗,您也會經常發現類似情況。這是一個必須瞭解你的日誌文件檢查他們的錯誤。

這將取決於您如何安裝服務器,但根據documentation它應該在C:\Program Files\OpenERP X.X\Server\openerp-server.log.。如果沒有,請在服務器配置文件中查找它。

如果你是認真的OpenERP發展,我會建議你:

  1. 停止服務器服務,並在控制檯端手動啓動它來代替。它不僅爲您提供有關警告和錯誤的即時信息,而且還會顯示python print聲明的結果,並讓您進入(Pdb)debug mode

  2. 安裝您的OpenERP server in an Ubuntu Server虛擬機。它可能有使用Linux的學習曲線,但有很多可用的幫助,從長遠來看,您會發現在該平臺上獲得幫助和解決問題要容易得多。

+0

我已經編輯它與控制檯的錯誤消息,現在我必須做什麼..? –

+0

'CRITICAL:意外縮進(sim.py,第10行)'檢查是否有製表符而不是空格。 –

+0

歡迎您。很高興知道@AnomA找到了解決問題的辦法。 –