Join the Odoo Inner Circle to view the premium video below.
How to create custom Smart Buttons in Odoo 8
Introduction: Learn how to create custom smart buttons using the Odoo framework
Overview of creating a smart button that displays customer payments
Creating a basic module from scaffolding and a blank module template
Creating the basic template for our smart button in XML
Using developer mode to locate the external id for Odoo forms and views
Use inheritance and xpath to find and place our smart button on the sales form
Hiding and showing a smart button dynamically using the attrs property
Specifying the qweb required to display the payment count in our smart button
Writing the Python code to create the compute field to count the payment vouchers
Setting up our related many2one field to count the payment vouchers for the customer
Installing and troubleshooting our module
Testing and discussion of the overall process of creating smart buttons

How to create custom Smart Buttons in Odoo 8

Odoo Inner Circle Only

This intermediate Odoo developer video shows you step by step how to create your own custom smart buttons in Odoo.

Video Length:   37 minutes
Free With Odoo Inner Circle

Learn how you can create your own custom smart buttons

In this exciting new video, learn about Odoo 8 Smart Buttons! New in Odoo 8 are the powerful smart buttons that allow you to both display important information and tie the buttons to interactive content. 
Below are example smart buttons with a custom 'Payments' button we develop in this video.

Learn to use Odoo 8's compute and @depends in your module

With Odoo 8, developers have a powerful new set of tools to create funcational fields. In this video we demonstrated exactly how to create a functional field that calculates customer payments. Included is Odoo 8's new API for creating one2many fields. 

The path to becoming an experienced Odoo developer

This 35 minute video ties together a lot of important Odoo developer topics. Model inheritence, view inheritence, functional fields, new 8.0 API decorators, xpath, and even some troubleshooting on how Odoo handles changes you make to the model and how to recover from issues you may face working with functional fields. 

New Video Update

In this video we use much of the new Odoo 8 features for defining the functional fields and triggering them... but we use the old style Odoo 7 code for actual processing of the recordset. View our new video on Odoo 8 API  Recordsets and learn how to update the payment buttons to use the new Odoo 8 API for processing.

Steps to creating Smart Buttons in Odoo 8

When creating smart buttons in Odoo 8 you must tie together several aspects of Odoo development. Below are the basic steps to creating a smart button with example code segments located below.

1. Add required fields to the model so you can store your calculations

    voucher_count = fields.Integer(compute='_voucher_count', string='# of Vouchers')
    account_voucher_ids = fields.One2many('account.voucher', 'partner_id', 'Voucher History')

2. Create a custom view template and use the interhit id that matches the external id of the form

    <record id="view_partners_form_crm2" model="ir.ui.view">
            <field name="name">view.res.partner.form.crm.inherited2</field>
            <field name="model">res.partner</field>
            <field name="priority" eval="200"/>
            <field name="inherit_id" ref="base.view_partner_form"/>

3. Use xpath in the template to tell the Odoo framework where to place your button

<xpath expr="//div[@name='buttons']" position="inside">

4. Add your Odoo smart button code to the view

<button class="oe_inline oe_stat_button" type="action" name="%(pay_view_voucher_tree)d"
               attrs="{'invisible': [('customer', '=', False)]}"
        <field string="Payments" name="voucher_count" widget="statinfo"/>

5. Create a python function to calcuate the functional field (voucher_count)
    def _voucher_count(self):
        vouchers = self.env['account.voucher'].search([('partner_id', '=',])
        self.voucher_count = len(vouchers)  

6. Create a view for the action to display your results (payments in this case) when the user clicks the button

          <record model="ir.actions.act_window" id="pay_view_voucher_tree">
            <field name="name">Payments</field>
            <field name="res_model">account.voucher</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,graph</field>
            <field name="context">{'search_default_partner_id': active_id}</field>
            <field name="arch" type="xml">
                <tree string="Payments">
                    <field name="date"/>
                    <field name="number"/>
                    <field name="reference"/>
                    <field name="partner_id"/>
                    <field name="type" invisible="context.get('visible', True)"/>
                    <field name="amount" sum="Total Amount"/>
                    <field name="state"/>