This question has been flagged
1 Reply
8235 Views

 the part id={{invoice_id}} doesn't get the id of my invoice. Even though I declared it in the py.

is there a way to call id and put it in href/t-att-href?


I want to automatically open the form of the invoice  I created.


code:

<a href="/web?debug#id={{invoice_id}}&amp;view_type=form&amp;model=account.invoice&amp;action=249" >

                               <button  class="btn btn-danger" string="Create Invoice" name="create_invoice"  type="object"/>

                           </a>

Avatar
Discard
Best Answer

try this it should work for you

XML side

<button name="create_invoice" type="object" string="Create Invoice" />

Python side

def create_invoice(self):

	# your other code before open view
        
        return { 'name': 'invoice', # Lable 'type': 'ir.actions.act_window', 'view_type': 'form', 'view_mode': 'form', 'res_model': 'account.invoice', # your model 'target': 'new', # if you want popup 'context': ctx, # if you need     }

Avatar
Discard
Author

if I put the 'view_mode':'form'

it opens a new create form.. what should I do?

if you want a particular record to display then you have to put 'res_id': '' also

try to add this line it should work otherwise debug and find res_id of your current record

'res_id': self.id,

Author

thank you :)

Author

Hello.. what should I do, it displays as vendor bill instead customer invoice.