Odoo Help


How to use two specific views (tree and form view) when using ir.actions.act_window

on 3/28/16, 4:39 PM 1,217 views

Hello everybody,

I am trying to call account.invoice_tree and account.invoice_form views as tree and form views respectively from another view. The behaviour I would like to have is that all related invoices (to a lead record, for which I defined a button  to get them) be shown, first  in a list (using account.invoice_tree view),  and then after one of the invoices is clicked, I want the invoice displayed in account.invoice_form view). I attempted to get tha behavior by using the views field inside the ir.actions.act_window record as shown below, but it does'n work (ie the app always shows invoice_supplier_form . Can anybody provide guidance on it.

Thanks a lot in advance. I apreciate your response.


<record id="action_invoice_receivable_attach" model="ir.actions.act_window">

<field name="name">Sale Invoices</field>

<field name="res_model">account.invoice</field>

<field name="view_type">form</field>

<field name="view_mode">tree,form</field>

<field name="views">[[%(account.invoice_tree)d, "tree"], [%(account.invoice_form)d, "form"]</field>

 <field name="domain">[('lead_id', '=', lead_id), '|', ('type', '=', 'out_invoice'), ('type', '=', 'out_refund')]</field>

<field name="context">{'default_lead_id': lead_id}</field>

<field name="target">current</field>


<button class="oe_stat_button" type="action" name="%(action_invoice_receivable_attach)d"

context="{'lead_id': active_id}" icon="fa-clipboard">

<field string="Sale Invoices" name="invoice_receivable_count" widget="statinfo" options="{'label_field': 'INVOICE_RECEIVABLE'}"/>



class crmLead(models.Model):

_inherit = 'crm.lead'

def _invoice_receivable_count(self):

invoices = 0

for invoice in self.invoices:

if 'out_invoice' == invoice.type or 'out_refund' == invoice.type:

invoices += 1

self.invoice_receivable_count = invoices


Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 3/29/16, 2:37 AM

Hi @Javier

There are two ways of doing that, assuming that you have a field invoices in the crm.lead and that you wanna display the invoices for the lead partner(you could change it to match your concept).

1- You could use the invoice search filters in conjunction with the button context to show the list view filtered by default with the partner of the lead. 

<button class="oe_stat_button" type="action" name="%(action_invoice_receivable_attach)d" context="{'search_default_partner_id': partner_id}" icon="fa-clipboard">

<field string="Sale Invoices" name="invoice_receivable_count" widget="statinfo" options="{'label_field': 'INVOICE_RECEIVABLE'}"/>


2- The other way involve changing the button type to "object" and in the method action for the button return the invoice action with a domain that filter all the invoice results

On 3/29/16, 1:43 PM

Thank you Axel. I appreciate your response.


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/28/16, 4:39 PM
Seen: 1217 times
Last updated: 3/29/16, 1:43 PM