Odoo Help


How to add an independant field in partner categories and show all in partner form ?

Anne-Sylvie Burri
on 6/27/13, 6:32 AM 948 views

Hi everybody,

I have to work with partners categories. Here is the situation :

I have 3 levels of categories : "Category", "Subcategory" and "Year". "Category" and "Subcategory" are linked but "Year" is independant.

An example : M. Doe was at "School" (category) in "America" (subcategory) in year 2003. But he is currently following a training in this same "School" in "America" in year 2013.

I have two problems :

  • how to allow one partner to have several times the same category and subcategory ?
  • how to create a new field "Year" which is not linked to the category and subcategory but which must appear in the partner form ? (I think a solution could be to work like "article" in invoice. We can choose many times the same article and we can add other independant data)

I created a new page in the partner form named "Statuts". Now this page shows the module "partner.category". Indeed, I used the following code :

from openerp.osv import fields, osv

class res_partner(osv.osv):
_inherit = 'res.partner'
_order = 'x_nom asc'
_columns = {
    'x_nom': fields.char('Nom',size=64),
    'x_prenom': fields.char('Prenom',size=64),
    'x_category': fields.many2many('res.partner.category','res_partner_category_rel','partner_id','category_id','Statuts'),
    'x_date': fields.selection((('2000','2000'), ('2001','2001'), ('2002','2002'), ('2003','2003'), ('2004','2004'), ('2005','2005'), ('2006','2006'), ('2007','2007'), ('2008','2008'), ('2009','2009'), ('2010','2010'), ('2011','2011'), ('2012','2012'), ('2013','2013')),'Annee'),


and :

<?xml version="1.0" encoding="utf-8"?>
<record model="ir.ui.view" id="view_partner_form">
    <field name="name">res.partner.form.inherit</field>
    <field name="model">res.partner</field>
    <field name="type">form</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
            <field name="name" position="after">
                <field name="x_nom"/>
            <field name="x_nom" position="after">
                <field name="x_prenom"/>
<record model="ir.ui.view" id="view_partner_form2">
    <field name="name">res.partner.form.inherit2</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <notebook position="inside">
            <page string="Statuts">
                    <field name="x_category" widget="many2many"/>
                    <field name="x_date" style="width: 30%%"/>

Many thanks in advance for your answer.


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 6/27/13, 6:32 AM
Seen: 948 times
Last updated: 3/16/15, 8:10 AM