我正在尝试从网站上获取文件的下载和文件名.
模型
class Files(models.Model):
_name = 'website_downloads.files'
name = fields.Char()
file = fields.Binary('File')
Run Code Online (Sandbox Code Playgroud)
CONTROLER
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([]),
})
Run Code Online (Sandbox Code Playgroud)
模板
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<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><t t-esc="f.name"/></td>
**<td>Download</td>**
</tr>
</t>
</table>
</div>
</div>
</t>
</template>
</data>
</openerp>
Run Code Online (Sandbox Code Playgroud)
如何获取下载链接,以及将文件保存在db save de original filename中
我正在尝试使用与Django相同的功能:
<div class="item {% if condition == True %}active{% endif %}">
Run Code Online (Sandbox Code Playgroud)
在Odoo我有:
<t t-foreach="list" t-as="l">
<a t-attf-href="/downloads/{{l.id}}" class="list-group-item"><t t-esc="l.name"/></a>
</t>
Run Code Online (Sandbox Code Playgroud)
如果"c.id = cat_id",我需要附加类"active"
怎么在Odoo完成?
我正在使用:
<t t-foreach="categories" t-as="c">
<t t-if="c.id == category_id">
<a t-attf-href="/downloads/{{c.id}}" class="list-group-item active"><t t-esc="c.name"/></a>
</t>
<t t-if="c.id != category_id">
<a t-attf-href="/downloads/{{c.id}}" class="list-group-item"><t t-esc="c.name"/></a>
</t>
</t>
Run Code Online (Sandbox Code Playgroud)
但寻找更加蟒蛇的方式
我已经能够通过激活开发者模式来更改General Odoo徽标.然后单击自己的徽标和"编辑公司数据",选择徽标.
但这不适用于POS.徽标仍然是默认的Odoo徽标.怎么改呢?
如何更改POS /销售点的徽标?
如果任何人都知道什么是外部id,以及它的用途,我会感激他.
我没有在网上找到有关该资源的资源.
提前致谢.
我已经使用左上角的EDIT按钮对ODOO网站的主页进行了一些编辑.过了一段时间,我决定通过将XML模板继承到我的模块并在模板中完成更改来对主页进行一些更改.但这些变化并未在网页中反映出来.我在ODOO的网站建设者上定制模板时多次遇到这个问题.我注意到这些更改直接应用于XML视图,可以看到,Settings->Technical Settings->User Interface->Views
即使模块已升级,也不会更改为以前的状态.在这种情况下,有什么方法可以通过在我的模块中继承模板来自定义模板吗?自定义适用于我在网站构建器中未进行任何编辑的所有模板.