跳至內容
選單
此問題已被標幟
2 回覆
3577 瀏覽次數

Hello,

should it be possible to add tabs(notebook/page) in detail view dynamically ?

I defined some entities in a custom module : 

class site(models.Model):
_name = 'my.site'
  _description = 'Sites'
  name = fields.Char()
  # some other fields        
  env_ids = fields.One2many('my.env', 'site_id')

class env(models.Model):
_name = 'my.env'
_description = 'Environments'
  name = fields.Char()
  # some other fields
site_id = fields.Many2one('my.site', string="Site")

I'd like on the Site detail view (and why not in form view as well) to add one tab by Env and display under this tab the fields of related Env.

I've tried :

<record model="ir.ui.view" id="my.sites_form"> 
  <field name="name">site.form</field>      
  <field name="model">my.site</field>      
  <field name="arch" type="xml">        
    <form string="Site Form">          
      <sheet>            
        <group string="general">              
          <field name="name"/>
        </group>            
        <group string="envs"> 
          <!-- I'd like to have as many tabs as my site has envs, this is obviously not working -->
          <notebook>                
            <page string="name of env">                    
              <field name="description of env"/>                    
            </page>
          </notebook>             
          <!-- The following code is working, I want to enhance its presentation -->        
          <field name="env_ids" widget="one2many_list" context="{'site_id': active_id}">                
            <tree string="Environments">                 
              <field name="name"/>                  
            </tree>              
          </field>            
        </group>          
      </sheet>        
    </form>      
  </field>
</record>​

Is it something possible with Odoo ?

Thank you,

Alain


頭像
捨棄
最佳答案

Normally it is not possible but it is possible by web. You need to create a some kind of web widget to display the tabs for each O2m records.

Odoo Web Documentation may help you.

頭像
捨棄
作者 最佳答案

Thank you for the help, I'll give it a try.

I'll also see how the contact form has been designed (contacts and addresses section), it could fit my need.

頭像
捨棄