Search code examples
pythonxmlodooseparator

i can't insert a separator or a notebook in a tree view


i'm having some trouble inserting a separator or a notebook in a tree view. is it even possible ?

The items are usually listed in the tree by the same specifics (name, adress, telphone number...). In my cas, i have two kninds of records (Personne morale and Personne Physique). The frist type should be listed by (nom, prénom, adresse), the second kind should be listed by (raison sociale, siège social,...).

Simply because,the user is given the choice to save the item either as (personne morale) or as personne physique), by hiding the fields related to the other type, so the user only fills the fields related to the type he chose.

    <div class="oe_center">                         
                        <sheet>
                            <h2>Demandeur:</h2>
                            <group>
                                <field name="state"/>
                            </group>
                            <group  attrs="{'invisible':[('state', '!=', 'p')],'required':[('state','!=','p')]}" col="4">                       
                                <field name="nom" />
                                <field name="prenom" />
                                <field name="cin" />
                                <field name="adresse" />
                                <!--<field name="dossier" />-->
                            </group>
                            <group attrs="{'invisible':[('state', '!=', 'm')],'required':[('state','!=','m')]}" col="4" >
                                <field name="raison_social" />
                                <field name="num_reg_comm" />
                                <field name="forme_social" />                                   
                                <field name="fax" />        
                            </group>
                            <group>
                                <field name="siege_social" attrs="{'invisible':[('state', '!=', 'm')]}" />
                            </group>
                            <group>
                                <field name="dossier" />
                                <field name="tel" /> <!-- je viens de l'ajouter -->                     
                                <field name="email" />
                            </group>

here is the class i'm talking about :

         class demandeur(osv.osv):
_name = 'sayoo.demandeur'
_rec_name = 'nom'

_columns = {
        'state': fields.selection((('p','Personne Physique'), ('m','Personne Morale')),'Statut', required= True),
        'nom': fields.char('Nom', size=100, required=False),
        'prenom': fields.char('Prenom', size=100, required=False),
        'cin': fields.char('Cin', size=100, required=False),
        'raison_social':fields.char('Raison Sociale', size=100, required=False),
        'siege_social':fields.char('Siège Social', size=100, required=False),
        'forme_social':fields.char('Forme Juridique', size=100, required=False),
        'num_reg_comm':fields.char('N° du Registre de Commerce', size=100, required=False),
        #'dossier': fields.many2one('sayoo.dossier', 'dossier'),
        'dossier': fields.one2many('sayoo.dossier','id_dossier','demande d\'autorisation' ),
        'adresse': fields.char('Adresse', size=100, required=False), #'date_naissance': fields.date('Date de naissance'),
        'description': fields.text('Description'),
        'tel': fields.char('Numéro de Téléphone', size=20),
        'fax': fields.char('Numéro de Fax', size=20),
        'email': fields.char('Adresse Electronqiue', size=20),
                }

demandeur()

and here is what i tried with the xml, but didn't work

    <record model="ir.ui.view" id="Demandeur_tree_view"><!-- d en D -->
        <field name="name">sayoo.demandeur.tree</field>
        <field name="model">sayoo.demandeur</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Demandeur Details"><!-- d en D -->
                <notebook>
                    <page string "Personne Physique">                       
                        <field name="nom" />
                        <field name="prenom" />
                        <field name="cin" /> <!-- je vient de l ajouter pour afficher la CIN dans la vue liste du demandeur -->
                        <field name="adresse" />
                    </page>
                    <page string "Personne Morale">
                        <field name="raison_social" />
                        <field name="siege_social" />
                        <field name="forme_social" />
                        <field name="num_reg_comm" />   
                    </page>
                </notebook>
            </tree>
        </field>
    </record>

Solution

  • There are two types of view: tree and form. The tree view is very simple, and does not handle notebooks, pages, groups. etc. It also does not handle having different fields/columns showing per record -- in other words, you could list all eight fields, and have only the four correct fields show the data, but all eight columns would always show.

    What you probably want to do is have two different tree views (one for Physique and one for Morale) and let the user choose which one to view from a menu selection (the menu xml can have a domain set so it only shows the correct records).