Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
2605 Vizualizări

Hello everyone, i have some problem here and got really stuck. so i want to add a button at customer invoice portal ( account.portal_invoice_page ) . i want that button to run a function create_midtrans_transaction(self) and then open the link at self.midtrans_redirect_url and both field and function is located at account.move . here is some explanation for the


create_midtrans_transaction(self)  : create a record at another model, link that record to account.move many2one field.

 self.midtrans_redirect_url : this field is related to field in previous created model

Both function and field is working and already tested, here is my current code for creating the code using action url and its not working.

python file :

def create_redirect_midtrans_transaction(self)

:print("Idk man, iam being called here")

return {'type': 'ir.actions.act_url',

'url': self.midtrans_redirect_url,

'target': 'new', }


xml file : 

<record id="unitek_midtrans_account_move_template" model="ir.ui.view">

<field name="name">Invoice Portal Templatefield>

<field name="inherit_id"ref="account.portal_invoice_page"/>

<field name="arch"type="xml">

<xpath expr="//div[@class='o_download_pdf btn-toolbar flex-sm-nowrap']"position="after">

<divclass="btn-group flex-grow-1 mb-1">

<buttonname="invoice.create_redirect_midtrans_transaction"string="Pay with Midtrans2"type="object"class="btn btn-primary"/>

div>

xpath>

field>

record>


any help is appreciated. Thanks!

Imagine profil
Abandonează
Cel mai bun răspuns

The code in your python file should be correct, but the code in your XML file has a few errors. Here's the corrected code:

  Invoice Portal Template
  account.move
  
  
    
      
Note that the name attribute of the button should be the name of the function create_redirect_midtrans_transaction, not invoice.create_redirect_midtrans_transaction. Also, the type attribute of the button should be action, not object.
This corrected code should create the button in the customer invoice portal as desired, and when clicked, it will run the function create_redirect_midtrans_transaction and open the link in the midtrans_redirect_url field in a new window.
Imagine profil
Abandonează
Autor

I am sorry, i cant see the corrected code. I only see

Invoice Portal Template
account.move

and for the invoice.create_redirect_midtrans_transaction , that invoice is for defining a single record for account.move. i will try without using invoice later and changing the object into action.

Autor

i tried it and its not working, maybe because its a qweb?