gpt4 book ai didi

model-view-controller - ir.ui.view 中 iframe 的 Odoo 8 src 变量

转载 作者:行者123 更新时间:2023-12-02 03:24:53 25 4
gpt4 key购买 nike

模型

class ItemStocks(models.Model):
_name = 'item.stocks'

item_url = fields.Char('View Item')
ItemStocks()

查看

<record id="view_item_stocks_form" model="ir.ui.view">
<field name="name">item.stocks.form</field>
<field name="model">item.stocks</field>
<field name="arch" type="xml">
<form string="Item Stocks">
...
<page string="Live Site">
<form string="Embedded Webpage" version="7.0" edit="false">
<iframe marginheight="0" marginwidth="0" frameborder="0"
src="{Variable for this.item_url}" width="100%" height="1000"/>
</form>
</page>
...
</form>
</field>
</record>

如何用模型中字段的有效表达式替换 {Variable for this.item_url}?有更好的方法吗?您希望用什么来解决动态显示嵌入式网页的要求?

上下文:Odoo 8、新 API、ir.ui.view

最佳答案

  **`Image Url wise Set Dynamic Iframe In Odoo`**
# v11 odoo community
you need to create fields like this :
image_url = fields.Char('Image Url')
img_attach = fields.Html('Image Html')


# set image_url in iframe
@api.onchange('image_url')
def onchange_image_url(self):
if self.image_url:
self.img_attach = '<img id="img" src="%s"/>' % self.image_url
# set image_url in form view
<field name="image_url" />
# after added script
<script>
if(document.getElementById("img")){
var value= document.getElementById("img").src;
document.getElementById("custom_src").src=value;
}
</script>


# also set iframe in form view
<iframe id="custom_src" src="" width="200" height="200" />

#output
show the image : /image/0x7et.png

关于model-view-controller - ir.ui.view 中 iframe 的 Odoo 8 src 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30984561/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com