コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
3574 ビュー

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.

アバター
破棄