2017-07-28 1 views
1

Je travaille avec odoo 10-e. J'ai créé module personnalisé et dans ce module, je veux montrer one2many dossiers comme celui-ciOdoo - Combiner deux champs en rubrique one2many

---------------- 
| Long Cell | 
---------------- 
| 1 | 2  | 
---------------- 

en ce moment par défaut chaque colonne a sa propre position qui est en fait la valeur string=. Je veux remplacer le comportement par défaut.

+0

vous voulez fonctionnalité comme dans la table html pour colspan dans odoo listview. droite ? –

Répondre

4

Commencez par créer le fichier XML qui étend le modèle ListView comme ceci pour ajouter une fonction colspan dans le modèle de vue de liste de base.

colspan.xml

<?xml version="1.0" encoding="UTF-8"?> 
<templates id="template" xml:space="preserve"> 
<div t-extend="ListView"> 
    <t t-jquery="table" t-operation="replace"> 
     <table class="o_list_view table table-condensed table-striped"> 
     <t t-set="columns_count" t-value="visible_columns.length + (options.selectable ? 1 : 0) + (options.deletable ? 1 : 0)"/> 
     <thead> 
      <tr t-if="options.header"> 
       <t t-foreach="columns" t-as="column"> 
        <th t-if="column.meta"> 
         <t t-esc="column.string"/> 
        </th> 
       </t> 
       <th t-if="options.selectable" class="o_list_record_selector" width="1"> 
        <div class="o_checkbox"> 
         <input type="checkbox"/><span/> 
        </div> 
       </th> 
       <t t-set="col" t-value="0"/> 
       <t t-foreach="columns" t-as="column"> 
        <t t-if="col == 0"> 
        <th t-if="!column.meta and column.invisible !== '1'" t-att-data-id="column.id" 
         t-attf-class="text-center #{((options.sortable and column.sortable and column.tag !== 'button') ? 'o_column_sortable' : '')}" 
          t-att-width="column.width()" t-att-colspan="column.colspan" > 
         <t t-set="col" t-value="column.colspan or 1"/>  
         <t t-if="column.tag !== 'button'"><t t-raw="column.heading()"/></t> 
        </th> 
        </t> 
        <t t-if="col !== 0" t-set="col" t-value="col - 1"/> 
       </t> 
       <th t-if="options.deletable" class="o_list_record_delete"/> 
      </tr> 
     </thead> 
     <tfoot> 
      <tr> 
       <td t-if="options.selectable"/> 
       <td t-foreach="aggregate_columns" t-as="column" t-att-data-field="column.id" t-att-title="column.label"> 
       </td> 
       <td t-if="options.deletable" class="o_list_record_delete"/> 
      </tr> 
     </tfoot> 
    </table> 
    </t> 
</div> 
</template> 

Ajouter au __manifest__.py

... 
'qweb': [ 
     "static/src/xml/colspan.xml", 
    ], 
... 

Voilà.

Vous pouvez utiliser colspan dans n'importe quel champ. dans Listview.

Par exemple.

<tree> 
    <field name="any_field" colspan="2"/> 
</tree> 

Essayez-le.

J'espère que cela fonctionnera pour vous.

+0

J'ai eu cette erreur: 'odoo.tools.convert: Le fichier XML ne correspond pas au schéma requis' – Ancient

+0

En fait, c'était de ma faute. Maintenant, cela fonctionne parfaitement. Merci beaucoup – Ancient

+0

Pouvez-vous m'aider un peu plus pour me faire savoir où je peux trouver ci-dessus des choses dans la documentation odoo. Je veux dire est-ce défini n'importe où que comment personnaliser des choses comme ça – Ancient