콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
10994 화면

Model

class ItemStocks(models.Model):

    _name = 'item.stocks'

    item_url = fields.Char('View Item')

    ItemStocks()


View:

<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>


How can I replace {Variable for this.item_url} with a valid expression for the field in model?

Is there a better way to do like this?

What would you prefer to solve the requirement of showing dynamically an embedded webpage?

아바타
취소
베스트 답변

I'm not sure to have well understood the question.
But if you want a generic iframe preview,
a tricky way can be to use a template and store the computed template in a field.

Here an example of how it could be made (to test)...


from openerp import api, fields, models

Model :

class ItemStocks(models.Model):
    _name = 'item.stocks'
     item_url = fields.Char('View Item')
     ItemStocks()

     iframe = fields.Html('Embedded Webpage', compute='_compute_iframe', sanitize=False, strip_style=False )
  
    @api.multi
     def _compute_iframe(self):
        for item_stock in self:
            url = item_stock.item_url
            template = self.env.ref('<your_module_name>.framed_page')
            item_stock.framed_page_rendered = template.render({ 'url' : url })  

View:

<template id='framed_page'>
     <iframe t-att-src="url"
     marginheight="0" marginwidth="0" frameborder="0"
     width="100%" height="1000"></iframe>
</template>


<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">
                <field name="framed_page_rendered" widget="html"/>
                 </form>
         </page> ...
        </form>
     </field>
</record>

아바타
취소
베스트 답변

Also Refer this site:

@V11 odoo Community

https://www.odoo.com/forum/help-1/question/i-want-to-add-an-iframe-in-openerp-with-a-dynamic-src-36038

아바타
취소
관련 게시물 답글 화면 활동
6
9월 17
8113
0
7월 17
4713
1
4월 16
5430
1
3월 15
4394
2
3월 15
9899