2014-04-15 1 views
2

자동으로 생성 된 파일을 다운로드하는 작업으로 사용자 정의 컨트롤러를 만들었습니다. 현재 직면하고있는 문제는 양식 태그를 사용하지 않고보기에서이 컨트롤러에 연결하는 방법입니다. 나는를 다운로드 할 URL에 대한 링크를 배치 할모듈 openerp의 사용자 정의 컨트롤러에 연결

class MyController(http.Controller): 
    _cp_path = '/sc' 

    @http.httprequest 
    def some_html(self, req, s_action=None, **kw): 
    return req.make_response(open('path_of_file').read(), 
      [('Content-Type', 'application/octet-stream; charset=binary'), 
      ('Content-Disposition', content_disposition('1.docx', req))], 
     ) 

우는 소리가 XML 뷰입니다 : 나는) 형태로보기 안에 이미 원하는 링크/버튼의 장소는, 울부 짖는 소리 내 컨트롤러 주어진 docx (자동 생성되는 정적 파일이 아닙니다.) :

<record model="ir.ui.view" id="view_sefarer_applicant_form"> 
    .... 
    <field name="arch" type="xml"> 
     <form string="Jobs - Recruitment Form" version="7.0"> 
     ..... 
     <sheet> 
      <div class="oe_right oe_button_box"> 
      ... 
      <button 
       name="action_download_form" 
       type="object" 
       string="P014 Drug/Alcohol Delcaration" 
       attrs="{'invisible':[('state','!=','done')]}" 
       <!-- this is where the link to the download url 
        {sc/some_html} should be called --> 
       /> 
      ... 
     </sheet> 
     </form> 

    </field> 
</record> 

도움이나 제안을 주시면 감사하겠습니다.

+0

야는 u는 질문 엔 위의이 같은 원하는에 대한 해결책을 얻을 않았다. 도와주세요. – nitesh

답변

0

OpenERP는 컨트롤러를 인정 받기 위해, 당신은 당신의 모듈 디렉토리에 static 디렉토리가 있어야합니다

/.../openerp/addons/MyModule/ 
    |-- __init__.py 
    |-- __openerp__.py 
    |-- controllers.py 
    |-- static/