Odoo Help

Welcome!

This community 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.

2

many2many bidirectional example

By
Soohoo
on 1/14/14, 2:09 AM 6,018 views

can any give many2many bidirectional good example

solved my self

Soohoo
on 1/14/14, 3:09 AM
4
Soohoo
On 1/14/14, 3:08 AM

py file

class dev_person(osv.osv):
    _name = "dev.person"
    _description = "Person"
    _columns = {
        'name': fields.char('Parent Note', size=32),
        'prop': fields.many2many('dev.property', 'pre_prop_rel', 'person_id', 'prop_id', 'Prop'),
    }

#dev_person()

class dev_property(osv.osv):
    _name = "dev.property"
    _description = "Property"
    _columns = {
       'name':fields.char('temp',size=32),
       'person': fields.many2many('dev.person', 'pre_prop_rel', 'prop_id', 'person_id', 'Person'),
    }

View file .xml

<?xml version="1.0"?>
<openerp>
<data>
    <record model="ir.ui.view" id="view_person_form">
        <field name="name">dev.person.form</field>
        <field name="model">dev.person</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="dev.person">
                <field name="name" select="1"/>

                <field name="prop">
                    <tree string="Tax Mapping" editable="bottom">
                        <field name="name"/>
                    </tree>
                    <form string="Tax Mapping">
                        <field name="name"/>
                    </form>
                </field>
            </form>
        </field>
    </record>

    <record model="ir.ui.view" id="view_person_tree">
        <field name="name">dev.person.tree</field>
        <field name="model">dev.person</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="dev.person">
                <field name="name"/>
                <field name="prop"/>
            </tree>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_person">
        <field name="name">Person</field>
        <field name="res_model">dev.person</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>


<!--<menuitem id="menu_item_abi_notes" parent="menu_section_ramport" name="Abi Results" action="action_abi_results" />-->
<menuitem id="dev_menu" name="dev" />
 <menuitem id="menu_section_test" parent="dev_menu" name="Test" />
<menuitem id="menu_person" parent="menu_section_test" name="person" action="action_person" />
<!--<menuitem id="menu_prop" parent="dev_menu" name="prop" action="action_property" />-->

    <record model="ir.ui.view" id="view_property_form">
        <field name="name">dev.property.form</field>
        <field name="model">dev.property</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="dev.property">
                <field name="name" select="1"/>
                <field name="person" select="1"/>
            </form>
        </field>
    </record>

    <record model="ir.ui.view" id="view_property_tree">
        <field name="name">dev.property.tree</field>
        <field name="model">dev.property</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="dev.property">
                <field name="name"/>
                <field name="person"/>
            </tree>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_property">
        <field name="name">Person</field>
        <field name="res_model">dev.property</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>
<menuitem id="menu_prop" parent="menu_section_test" name="Property" action="action_property" />

</data>

</openerp>

is this working for you? what version do you have? it is not working for me...

Stefan Reisich
on 1/14/14, 9:55 AM

please give the error i will fix it its working for me windows and ubuntu openerp version 7

Abhishek
on 1/16/14, 3:34 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/14/14, 2:09 AM
Seen: 6018 times
Last updated: 3/16/15, 8:10 AM