MAHI
MAHI

Reputation: 10163

openerp cutomer tree view

here is my code for my module, i have inherited res.partner table and added a column partner_ref. what i need is in myproject i have to show which customer is referred by whom. and list of referred customer by the current customer.

here is my table definition:

from osv import fields, osv
import logging
_logger = logging.getLogger('realty')
class cust_ref(osv.osv):
    _description = "Reference"
    _inherit = 'res.partner'
    _columns = {
       'partref_id' : fields.many2one('res.partner', 'Referred by', required=False),
    }
cust_ref()

and here is xml code :

<?xml version="1.0"?>
<insignierp>
        <data>
            <record id="partner_reference_ref_form" model="ir.ui.view">
                <field name="name">realty.res.partner.form.inherit</field>
                <field name="model">res.partner</field>
                 <field name="arch" type="xml"> 
                    <xpath expr="/form/notebook/page[@string='Accounting']" position='after'>
                        <page string='References'>

                        </page>
                    </xpath>
                 </field> 
            </record>
        </data>
</insignierp>

enter image description here

now, i in this reference page i need to list in tree view, list of customers referred by this customer. i do know how to implement this. guide me to solve this. or any suggestion and ideas will be very helpful. thanks all.

Upvotes: 0

Views: 728

Answers (2)

user1576199
user1576199

Reputation: 3207

Yes you can do like this:

<field name="ref_partner_ids">
    <tree string="Ref">
        <field name="one"/>
        <field name="two"/>
        <field name="three"/>
        ...................
        ..................
     </tree>
</field>

Upvotes: 2

user1576199
user1576199

Reputation: 3207

You have to create another field one2many to get list of partners, which referenced by partner. Like:

'partref_id': fields.many2one('res.partner', 'Related Company'),
'ref_partner_ids': fields.one2many('res.partner', 'partref_id', 'Refrence partner'),

And you have to show this ref_partner_ids in your view, then partner who reference by 'partref_id' this partner show in fields ref_partner_ids.

Upvotes: 2

Related Questions