2

我是odoo的新手,如果这是一个菜鸟问题,我很抱歉。

如何授予未登录网站用户对模型的读取权限?

哪个是网站用户群?

为什么 odoo 8.0 的文档那么差?

我制作了一个模块 website_downloads:

楷模:

class Files(models.Model):
    _name = 'website_downloads.files'
    name = fields.Char()
    file = fields.Binary('File')
    filename = fields.Char()

控制器:

class website_downloads(http.Controller):
    @http.route('/downloads/', auth='public', website=True)
    def index(self, **kw):
        files = http.request.env['website_downloads.files']
        return http.request.render('website_downloads.index', {
            'files': files.search([]),
        })

网站模板:

<template id="index" name="Website Downloads Index">
  <t t-call="website.layout">
    <div id="wrap" style="margin-top:50px;margin-bottom:50px">
      <div class="container text-center">
    <table class="table table-striped">
      <t t-foreach="files" t-as="f">
        <tr>
          <td align="left"><t t-esc="f.name"/></td>
          <td><t t-esc="f.filename"/></td>
          <td><a t-attf-href="/web/binary/saveas?model=website_downloads.files&amp;field=file&amp;filename_field=filename&amp;id={{ f.id }}"> <i class="fa fa-download"></i> Download</a></td>
        </tr>
      </t>
    </table>
      </div>
    </div>
  </t>
</template>

安全

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_website_downloads_user,website_downloads.files,model_website_downloads_files,base.group_user,1,0,0,0
access_website_downloads_manager,website_downloads.files,model_website_downloads_files,base.group_sale_manager,1,1,1,1
4

1 回答 1

1

“base.group_public”

我解决了将其添加到安全文件中

access_website_downloads_public,website_downloads.files,model_website_downloads_files,base.group_public,1,0,0,0
于 2015-09-03T17:57:51.620 回答