Review: Needs Fixing

Functionally it is ok, but I have a few remarks about the code.

1. Choose better field names ('total' refers to a sum of numbers, not a count 
of elements):
    - total_oppo -> opportunity_count
    - total_meeting -> meeting_count
    - total_sale -> sale_order_count
    - total_reception -> reception_count
    - total_delivery -> delivery_count

2. In the function fields, avoid calling search() inside a loop: it generates 
many queries to the db.  Use something like the following, which generates a 
constant number of queries:

    def _meeting_count(self, cr, uid, ids, field_name, arg, context=None):
        count = dict.fromkeys(ids, 0)
        meeting_pool=self.pool.get('crm.meeting')
        meeting_ids = meeting_pool.search(cr, uid, [('partner_id', 'in', ids)])
        for meeting in meeting_pool.browse(cr, uid, meeting_ids):
            count[meeting.partner_id.id] += 1
        return count

3. Don't comment out XML.  If it has to be removed, then remove it.

4. In crm/res_partner_view.xml, don't overcomplicate stuff with singular/plural 
distinction.  Keep it simple: "Opportunities (N)".  The link goes to the 
opportunities, the number in parentheses is indicative only.

5. In the same file, can't you replace the method 'get_opportunity' by an 
action in XML?  Just mimic the action 'sale.act_res_partner_2_sale_order', it 
does the job.  Same remark for 'get_receptions' and 'get_deliveries'.

Thanks,
Raphael

-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-all-home-page-dbr/+merge/103692
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-all-home-page-dbr.

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to