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.
Javier
<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>
</record>
<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'}"/>
</button>
---------******-------
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