Hello,
I'm new to odoo and i use odoo 10 version. I created a field with the attribute fields.Binary reason being i want to be able to upload document from my local machine, which is working fine. But my challenge now is i want to be able to download the same document i uploaded. when i click the download icon shown after i save the record i get a False download that i cannot view. What do i need to do please.
BELOW IS PART OF THE WRITTEN CODE:
py file
class Send_Request(models.Model):
_name="send.memo.request"
_inherit = ['mail.thread', 'ir.needaction_mixin']
def _default_employee(self):
return self.env.context.get('default_employee_id') or self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
name = fields.Char('Memo Request Description')
date = fields.Datetime(string='Date',default=fields.Date.context_today, required=True, copy=False)
employee_id = fields.Many2one('hr.employee', string = 'Employee', default =_default_employee)
dept_ids = fields.Char(string ='Department', related='employee_id.department_id.name',readonly = True, store =True)
description = fields.Char('Note')
project_id = fields.Many2one('account.analytic.account', 'Project')
amountfig = fields.Float('Budget Amount', store=True)
description_two=fields.Text('Reasons')
reason_back=fields.Char('Return Reason')
file_upload = fields.Binary('File Upload')
views.xml
<record id ="internal_memo_request_form_view_3" model ="ir.ui.view">
<field name="name">Internal Memo Request</field>
<field name="model">send.memo.request</field>
<field eval="25" name="priority"/>
<field name ="arch" type="xml">
<form string="Internal Memo Request">
<header>
<button name="submit_manager" states="submit" string="Submit HOU" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_emp"/>
<button name="submitHouManager" states="headunit" string="Submit to GM" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_manager"/>
<button name="submitGmEdCoo" states="manager" string="ED/CEO" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_admin"/>
<button name="submitEdCoo" states="ed" string="Post to Approve/CEO" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_ed"/>
<button name="send_Gmanager_ed_coo_submit" states="submit" string="Submit ED/CEO" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_admin"/>
<button name="submitCooApp" states="coo" string="Approve" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_coo"/>
<button name="approval" states="approved" string="Register Procurement" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_account"/>
<button name="refuse_hou" states="headunit" string="Reject" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_manager"/>
<button name="refuse_gm" states="manager" string="Reject" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_admin"/>
<button name="refuse_ed" states="ed" string="Reject" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_ed"/>
<button name="refuse_coo" states="coo" string="Reject" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_coo"/>
<button name="set_draft" states="refused" string="Set Draft" type="object" class="btn-primary" groups="internal_memo_test.group_memo_xx_admin"/>
<field name="state" widget="statusbar" statusbar_visible="submit,headunit,manager,coo,approved" /><!--statusbar_visible="draft,reported,done,refused"-->
</header>
<sheet>
<div class="oe_button_box">
<button name="button_send_back"
class="oe_stat_button"
icon="fa-angle-double-left"
type="object" string="Return Memo">
</button>
</div>
<div class="oe_title">
<label for="name"/>
<h1>
<field name="name" placeholder="e.g. Description"/>
</h1>
</div>
<group>
<group>
<field name="employee_id" attrs="{'readonly':[('state','in',['headunit','manager','ed','coo','account','post','done'])]}"/>
<field name="dept_ids"/>
<field name="invoice_ref"/>
<field name = "users_followers" widget="many2many_tags" required="0"/>
<field name="direct_memo_user"/>
</group>
<group>
<field name="date"/>
<field name="amountfig" string="Amount" readonly="1" />
<field name="project_id"/>
<field widget="binary" height="64" name="file_upload" filename="file_namex"/>
<field name="status_progress" widget="progressbar" string="Progress(%)"/>
Thanks in anticipation.