This question has been flagged
1 Reply
3839 Views

I wrote a customer module and I want to display the website address of the partner in my view. I am storing partner_id in my custom module.

I realize that I could store the website in my custom module, but i think that is duplicative, a waste of hard drive space and gets much more complicated as you want to display more fields from different modules.

What can I put in my xml view for my custom module to retrieve the website of the partner_id I am presently viewing in the form?

Avatar
Discard
Author Best Answer

i couldn't get this to work exactly the way i wanted to, but i did come up with a solution. I added a function to my customer module which will retrieve the website from the partner record, but not store it.

    def _get_website(self, cr, uid, ids, partner_id, args, context=None):
        res={}
        context = {}
        partner_obj = self.pool.get('res.partner')
        for record in self.browse(cr, uid, ids, context=context):
            res[record.id] = {}
            website_ids=partner_obj.search(cr, uid, [('id','=',record.partner_id.id)])
            for website_brw in partner_obj.browse(cr, uid, website_ids, context=context):
                res[record.id] = website_brw.website
        return res

_columns = {
        'website': fields.function(_get_website, type="char", string='Website', store=False),
}
Avatar
Discard