Here is my .py file
class Associateaccounts_respartner(models.Model):
_inherit = 'res.partner'
@api.multi
def associate_count():
# I need to count how many associate account is there based on one particular contact
associate_count = fields.Integer(compute="associate_count", string='# of Associate', store='true')
associate_id = fields.One2many('sale.associateaccounts', 'associate_partner_id', string='Associate Accounts')
here is my .xml file<openerp>
<data>
<record id="count_associateaccounts_respartner" model="ir.ui.view">
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button class="oe_stat_button" type="action" name="%(associateaccounts.associateaccounts_action)d" attrs="{'invisible': [('customer', '=', False)]}" icon="fa-star">
<field string="Associates" name="associate_count" widget="statinfo"/>
</button>
</div>
</field>
</record>
</data>
</openerp>